Home > vbmeg > demo > tutorial_for_vbmeg2 > easy_VBMEG > estimate_source_current_eeg.m

estimate_source_current_eeg

PURPOSE ^

Estimate source currents from EEG data

SYNOPSIS ^

function estimate_source_current_eeg(p)

DESCRIPTION ^

 Estimate source currents from EEG data

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function estimate_source_current_eeg(p)
0002 % Estimate source currents from EEG data
0003 %
0004 % Copyright (C) 2011, ATR All Rights Reserved.
0005 % License : New BSD License(see VBMEG_LICENSE.txt)
0006 
0007 disp(mfilename);
0008 
0009 % Set parameters
0010 time_signal = [0 0.3]; % Period for stimulus-evoked activity [s]
0011 time_noise = [-0.3 0]; % Period for baseline [s]
0012 
0013 % Make directory to save current
0014 current_dir = fullfile(p.proj_root, p.eeg_dirname, ['standard_' p.current_dirname]);
0015 if exist(current_dir, 'dir') ~= 7
0016     mkdir(current_dir);
0017 end
0018 
0019     
0020 %% Estimate current variance
0021 clear bp
0022 bayes_parm = vb_set_bayes_default_parameters;
0023 
0024 % Set input files (relative path from proj_root)
0025 bayes_parm.brainfile = ['../../../../../cbi-data20/common/software/internal/vbmeg/vbmeg2_0_0_b_4/'...
0026     'standard_brain/mni_icbm152_t1_tal_nlin_asym_09c_10000/mni_icbm152_t1_tal_nlin_asym_09c_10000.brain.mat'];
0027 bayes_parm.areafile = ['../../../../../cbi-data20/common/software/internal/vbmeg/vbmeg2_0_0_b_4/'...
0028     'standard_brain/mni_icbm152_t1_tal_nlin_asym_09c_10000/mni_icbm152_t1_tal_nlin_asym_09c_10000.area.mat'];
0029 bayes_parm.actfile = ['../../../../../cbi-data20/common/software/internal/vbmeg/vbmeg2_0_0_b_4/'...
0030     'standard_brain/mni_icbm152_t1_tal_nlin_asym_09c_10000/mni_icbm152_t1_tal_nlin_asym_09c_10000.act.mat'];
0031 
0032 bayes_parm.megfile = fullfile(p.eeg_dirname, p.trial_dirname, 'cribr_s1.eeg.mat');
0033 bayes_parm.basisfile = fullfile(p.eeg_dirname, p.leadfield_dirname, ['standard_' p.struct_name '.basis.mat']);
0034 bayes_parm.megfile_baseline = bayes_parm.megfile;
0035 
0036 % Specify current area and fMRI activity
0037 bayes_parm.area_key  = 'Cortex';% Current area
0038 bayes_parm.act_key = 'Uniform';% Prior for current variance
0039 bayes_parm.prior_weight = p.prior_weight;% Relative influence of prior information (0-1)
0040 
0041 % Load time information
0042 [~, ~, time_info] = vb_load_meg_data(fullfile(p.proj_root, bayes_parm.megfile));
0043 time = time_info.time;
0044 
0045 % Set time window for stimulus-evoked activity
0046 [~, from] = min(abs(time-time_signal(1)));
0047 [~, to] = min(abs(time-time_signal(2)));
0048 bayes_parm.twin_meg = [from to]; % Time window for analysis
0049 bayes_parm.Tperiod = to-from+1; % Time period for current estimation
0050 bayes_parm.Tnext = to-from+1; % Time step for next period
0051 
0052 % Set time window for baseline
0053 [~, from] = min(abs(time-time_noise(1)));
0054 [~, to] = min(abs(time-time_noise(2)));
0055 bayes_parm.twin_noise = [from to];
0056 bayes_parm.twin_baseline = [from to];
0057 
0058 bayes_parm.patch_norm = ON;% Patch area normalization is applied
0059 
0060 % Set output file
0061 bayes_parm.bayesfile = fullfile(p.eeg_dirname, ['standard_' p.current_dirname, 's.bayes.mat']);
0062 
0063 % Set parameters for noise covariance estimation
0064 bayes_parm = vb_set_noise_estimation_model(bayes_parm, p.proj_root);
0065 
0066 % Estimate current variance
0067 vb_job_vb(p.proj_root, bayes_parm)
0068 
0069 
0070 %% Estimate source current
0071 
0072 % Set input files (relative path from proj_root)
0073 current_parm.megfile = bayes_parm.megfile;
0074 current_parm.bayesfile = bayes_parm.bayesfile;
0075 
0076 % Trial-averaged current will be estimated.
0077 current_parm.trial_average = ON;
0078 
0079 % Set time window for estimating current
0080 a = vb_load_meg_data(fullfile(p.proj_root, current_parm.megfile));
0081 current_parm.twin_meg = [1 size(a, 2)];
0082 current_parm.Tperiod = size(a, 2);
0083 
0084 % Set output file (relative path from proj_root)
0085 current_parm.currfile = fullfile(p.eeg_dirname, ['standard_' p.current_dirname, 's.curr.mat']);
0086 
0087 % Estimate source current
0088 vb_job_current(p.proj_root, current_parm);
0089 end
0090 
0091 
0092 
0093 
0094

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005