Estimate current time course by using inverse filter. (VBMEG public function) [syntax] [Zact,Jinfo,Jext] = vb_job_current_dynamics(curr_parm) [Zact,Jinfo,Jext] = vb_job_current_dynamics(proj_root,curr_parm) [old style] [input] proj_root: <<string>> VBMEG project root directory. curr_parm: <<struct>> Current estimation parameters. --- fields of curr_parm dbayesfile : <<string>> Dynamics estimation filename (.dbayes.mat). This file is required for current estimation and obtained by vb_job_vb_dynamics. currfile : <<string>> Cortical current filename (.curr.mat), specifying the file to which current estimation result is saved. area_key : !! currently unconfirmed. <optional> <<string>> Area ID on which cortical current is estimated. This parameter will be useful if you have some knowledge about region of interested. areafile : !! currently unconfirmed. <optional> <<string>> Required if cortical area is specified by field 'area_key'. trial_average: !! currently unconfirmed. <optional> <<bool>> If true (default), cortical current averaged across all trials. If false, cortical current is estimated for all trials. jactdir : !! currently unconfirmed. <optional> <<string>> Directory for saving trial current files. This is the relative path from the cortical current file. If trial_average == false & jactdir is specified, current for each trial is saved as trial current file. dsampf : !! currently unconfirmed. <optional> <<int>> Specify frequency of downsampling. This value must be smaller than the original sampling frequency of M/EEG data. overlap_mode : !! currently unconfirmed. <optional> <<bool>> If false (default), cortical current is averaged over overlapped time windows. Otherwise, current is not averaged over overlapped time windows; current time series of each time windows are concatenated sequentially for spectral analysis. !! currently unconfirmed. If following fields are given, these values are used instead of bayes_parm field in result file (see vb_job_vb): basisfile megfile twin_meg Tperiod Tnext extra.basisfile (for extra dipole) --- [output] Zact : <<float matrix>> Z-current. Zact(n,t,:) is the current at the vertex 'ix_act(n)' & the time 't'. Zact(Nact,Nsample) for trial_average = true. Zact(Nact,Nsample,Ntrials) for trial_average = false. Nact : # of active region, Nsample : # of time sample, Ntrials : # of trials in all session] Jinfo: <<struct>> Information of cortical current. Jext : <<double matrix>> Extra dipole current. [example] >> parm.dbayesfile = './NG/result/result3_col.dbayes.mat'; >> parm.currfile = './result/result3_col_fMTl_1.curr.mat'; >> vb_job_current_dynamics(parm); Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [Zact, Jinfo, Jext] = vb_job_current_dynamics(varargin) 0002 % Estimate current time course by using inverse filter. 0003 % (VBMEG public function) 0004 % 0005 % [syntax] 0006 % [Zact,Jinfo,Jext] = vb_job_current_dynamics(curr_parm) 0007 % [Zact,Jinfo,Jext] = vb_job_current_dynamics(proj_root,curr_parm) [old style] 0008 % 0009 % [input] 0010 % proj_root: <<string>> VBMEG project root directory. 0011 % curr_parm: <<struct>> Current estimation parameters. 0012 % --- fields of curr_parm 0013 % dbayesfile : <<string>> Dynamics estimation filename (.dbayes.mat). This 0014 % file is required for current estimation and obtained by 0015 % vb_job_vb_dynamics. 0016 % currfile : <<string>> Cortical current filename (.curr.mat), 0017 % specifying the file to which current estimation result 0018 % is saved. 0019 % area_key : !! currently unconfirmed. 0020 % <optional> <<string>> Area ID on which cortical current 0021 % is estimated. This parameter will be useful if you have 0022 % some knowledge about region of interested. 0023 % areafile : !! currently unconfirmed. 0024 % <optional> <<string>> Required if cortical area is 0025 % specified by field 'area_key'. 0026 % trial_average: !! currently unconfirmed. 0027 % <optional> <<bool>> If true (default), cortical current 0028 % averaged across all trials. If false, cortical current 0029 % is estimated for all trials. 0030 % jactdir : !! currently unconfirmed. 0031 % <optional> <<string>> Directory for saving trial 0032 % current files. This is the relative path from the 0033 % cortical current file. If trial_average == false & 0034 % jactdir is specified, current for each trial is saved 0035 % as trial current file. 0036 % dsampf : !! currently unconfirmed. 0037 % <optional> <<int>> Specify frequency of 0038 % downsampling. This value must be smaller than the 0039 % original sampling frequency of M/EEG data. 0040 % overlap_mode : !! currently unconfirmed. 0041 % <optional> <<bool>> If false (default), cortical 0042 % current is averaged over overlapped time 0043 % windows. Otherwise, current is not averaged over 0044 % overlapped time windows; current time series of each 0045 % time windows are concatenated sequentially for spectral 0046 % analysis. 0047 % !! currently unconfirmed. 0048 % If following fields are given, these values are used instead of 0049 % bayes_parm field in result file (see vb_job_vb): 0050 % basisfile 0051 % megfile 0052 % twin_meg 0053 % Tperiod 0054 % Tnext 0055 % extra.basisfile (for extra dipole) 0056 % --- 0057 % 0058 % [output] 0059 % Zact : <<float matrix>> Z-current. 0060 % Zact(n,t,:) is the current at the vertex 'ix_act(n)' & the time 't'. 0061 % Zact(Nact,Nsample) for trial_average = true. 0062 % Zact(Nact,Nsample,Ntrials) for trial_average = false. 0063 % Nact : # of active region, 0064 % Nsample : # of time sample, 0065 % Ntrials : # of trials in all session] 0066 % Jinfo: <<struct>> Information of cortical current. 0067 % Jext : <<double matrix>> Extra dipole current. 0068 % 0069 % [example] 0070 % >> parm.dbayesfile = './NG/result/result3_col.dbayes.mat'; 0071 % >> parm.currfile = './result/result3_col_fMTl_1.curr.mat'; 0072 % >> vb_job_current_dynamics(parm); 0073 % 0074 % 0075 % Copyright (C) 2011, ATR All Rights Reserved. 0076 % License : New BSD License(see VBMEG_LICENSE.txt) 0077 0078 % 0079 % check input arguments 0080 % 0081 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0082 if length(varargin) == 1 0083 proj_root = []; 0084 curr_parm = varargin{1}; 0085 elseif length(varargin) == 2 0086 proj_root = varargin{1}; 0087 curr_parm = varargin{2}; 0088 else 0089 error('Error: invalid usage of job_current_dynamics.'); 0090 end; 0091 0092 proj_root = vb_rm_trailing_slash(proj_root); 0093 0094 if ~isfield(curr_parm,'trial_average'), 0095 curr_parm.trial_average = true; 0096 end 0097 0098 if ~isfield(curr_parm,'areafile'), 0099 curr_parm.areafile = []; 0100 end 0101 0102 % 0103 % set absolute path 0104 % 0105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0106 if ~isempty(proj_root) 0107 currfile = fullfile(proj_root, filesep, curr_parm.currfile); % current file 0108 dbayesfile = fullfile(proj_root, filesep, curr_parm.dbayesfile); 0109 if isfield(curr_parm, 'areafile') 0110 areafile = fullfile(proj_root, filesep, curr_parm.areafile); % vb_get_area 0111 end 0112 else 0113 currfile = curr_parm.currfile; 0114 dbayesfile = curr_parm.dbayesfile; 0115 0116 if isfield(curr_parm, 'areafile') 0117 areafile = curr_parm.areafile; 0118 end 0119 end 0120 0121 % 0122 % Current estimation 0123 % 0124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0125 vb_disp('Start current estimation') 0126 0127 if ~isempty(areafile) ... 0128 & isfield(curr_parm, 'area_key') & ~isempty(curr_parm.area_key), 0129 Area = vb_get_area(areafile, curr_parm.area_key); 0130 ix_area = Area.Iextract; 0131 else 0132 ix_area = []; 0133 end 0134 0135 parm = curr_parm; 0136 parm.ix_area = ix_area; 0137 if curr_parm.trial_average == false ... 0138 error('Currently we assumes with trial average = ON'); 0139 % && isfield(curr_parm,'jactdir') && ~isempty(curr_parm.jactdir) 0140 % [Zact ,Jinfo, bayes_parm, vb_parm, MEGinfo, Jext, Pointlist] ... 0141 % = vb_current_reconstruct_z_tr(proj_root, parm); 0142 else 0143 [Zact, Jinfo, bayes_parm, vb_parm, MEGinfo, Jext, Pointlist] ... 0144 = vb_current_reconstruct_z_dynamics(proj_root, parm); 0145 end 0146 0147 % load brain vertex number 0148 brain_file = fullfile(proj_root, bayes_parm.brainfile); 0149 Nvertex = vb_load_cortex_info(brain_file); 0150 0151 % 0152 % Save result 0153 % 0154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0155 vb_disp(sprintf('--- Save estimated current: %s\n',currfile)); 0156 load(dbayesfile, 'dbayes_parm'); 0157 vb_fsave(currfile,'Zact','Jinfo','MEGinfo', 'Nvertex', 'curr_parm','vb_parm', 'bayes_parm', 'dbayes_parm'); 0158 0159 % 0160 % project_file save 0161 % 0162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0163 proj_file = get_project_filename; 0164 if isempty(proj_file) 0165 return; 0166 end 0167 0168 project_file_mgr('load', proj_file); 0169 project_file_mgr('add', 'current_parm', curr_parm); 0170 0171 return;