Current reconstruction using Bayesian inverse filter. [syntax] [Zact,Jinfo,bayes_parm,vb_parm,MEGinfo] ... = vbmeg_current_reconstruct_z_tr(proj_root,curr_parm) [input] proj_root: <<string>> VBMEG project root directory. curr_parm: <<struct>> Parameters for current estimation. --- fields of curr_parm bayesfile : <<string>> Model parameter file (.bayes.mat). currfile : <<string>> Cortical current file (.curr.mat), created by this function. jactdir : <<string>> Directory for saving trial current files. Relative path from cortical current file. trial_average: <optional> <<bool>> If true, = [ON] : average current over all sessions = OFF : current for each session ix_area : <optional> Vertex indices to calculate estimated current. If 'ix_area' is empty or not given, cortical currents in the active region are calculated. tsubsmpl : <optional> <bosolete> Specify subsampled time index. If 'tsubsmpl' is empty or not given, time subsampling is not done. dsampf : <optional> <<int>> Specify frequency of downsampling. This value must be smaller than the original sampling frequency of M/EEG data. overlap_mode : <optional> <<int>> = 0 : current is averaged over overlapped time window = 1 : current is not averaged for overlapped window current time series of each time windows are concatenated sequentially for spectral analysis ix_trial : <optional> Trial indices for which currents are reconstructed. verbose : <<bool>> Verbose flag. --- [note] If following field is given, these values are used instead of bayes_parm field in result file: --- curr_parm.basisfile curr_parm.megfile curr_parm.megfile_baseline curr_parm.twin_meg curr_parm.Tperiod curr_parm.Tnext --- [output] Zact : active current Zact(n,t,:) is the current at the vertex 'ix_act(n)' & the time 't' Zact(Nact,Nsample) for trial_average = ON Zact(Nact,Nsample,Ntrials) for trial_average = OFF Nact : # of active region, Nsample : # of time sample, Ntrials : # of trials in all session] Jinfo: <<struct>> Information of cortical current. --- fields of Jinfo version : <<string>> Version of cortical current file. curr_type : <<string>> 'Z-current'. It can be 'J-current' for VBMEG version 0.8 or older. Wact : <<float matrix>> Smoothing Gaussian filter, mapping from Z-current to J-current. ix_act : <<int vector>>: Vertex indices of Z-current. ix_act_ex : <<int vector>>: Vertex indices of J-current. Lact : <<int>> Number of current direction at one vertex. Tsample : <<int vector>> Time sample indices of the original MEG data. length(Tsample) == size(Zact,2) == size(Jact,2). Tmsec : <<float vector>> Time in msec. SampleFreq: <<float>> Sample frequency of cortical current, not original M/EEG signal [Hz]. Pretrigger: <<int>> Time points of the length of the pretrigger period of cortical current data. It is neither actual time nor time points of the original M/EEG signal. Ntrial : <<int>> Number of trials of estimated current. patch_norm: <<bool>> Cortical current is patch size normalized (Am/m^2) or not (Am). Tix : <<L x 1 cell>> Time sample indices of each time window. Zact(:,Tix{n},:) is the set of Z-current within the n-th time window. --- [history] 2006-09-03 M. Sato * Non-overlapped concatenation mode is added for spectral analysis 2008-08-25 Taku Yoshioka Extra dipole support 2008-09-30 Taku Yoshioka Minor change for variables in Jinfo 2008-10-23 Taku Yoshioka Bug fix for current estimation without extra dipoles 2009-04-02 Taku Yoshioka Parameter name changed within this code for readability (just replacing 'resultfile' to bayesfile) 2010-03-01 M. Sato Bug fix for Wact index and fieldname(tsubsamp->tsubsmpl) 2010-05-26 Taku Yoshioka Message display changed 2010-12-06 taku-y [enhancement] curr_parm.dsampf supported. [minor] Following fields of Jinfo set in this function: SampleFreq Pretrigger Tmsec [trivial] Jinfo.version = vb_version. 2010-12-07 taku-y [trivial] Jinfo.version = vbmeg('version'); 2011-05-11 takiu-y [debug] Jinfo.Tmsec corrected. 2011-06-28 taku-y [minor] Jinfo.Tix added. 2012-02-15 taku-y [debug] Jinfo.SampleFreq could be empty in a certain case. This bug was fixed. 2017-10-25 Yusuke Takeda Modified for dipoles with multiple orientations Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [Zact_ave,Jinfo,bayes_parm,vb_parm,MEGinfo,Jext_ave,Pointlist] ... 0002 = vb_current_reconstruct_z_tr(proj_root,curr_parm); 0003 % Current reconstruction using Bayesian inverse filter. 0004 % 0005 % [syntax] 0006 % [Zact,Jinfo,bayes_parm,vb_parm,MEGinfo] ... 0007 % = vbmeg_current_reconstruct_z_tr(proj_root,curr_parm) 0008 % 0009 % [input] 0010 % proj_root: <<string>> VBMEG project root directory. 0011 % curr_parm: <<struct>> Parameters for current estimation. 0012 % --- fields of curr_parm 0013 % bayesfile : <<string>> Model parameter file (.bayes.mat). 0014 % currfile : <<string>> Cortical current file (.curr.mat), created 0015 % by this function. 0016 % jactdir : <<string>> Directory for saving trial current 0017 % files. Relative path from cortical current file. 0018 % trial_average: <optional> <<bool>> If true, 0019 % = [ON] : average current over all sessions 0020 % = OFF : current for each session 0021 % ix_area : <optional> Vertex indices to calculate estimated 0022 % current. If 'ix_area' is empty or not given, cortical 0023 % currents in the active region are calculated. 0024 % tsubsmpl : <optional> <bosolete> Specify subsampled time 0025 % index. If 'tsubsmpl' is empty or not given, time 0026 % subsampling is not done. 0027 % dsampf : <optional> <<int>> Specify frequency of 0028 % downsampling. This value must be smaller than the 0029 % original sampling frequency of M/EEG data. 0030 % overlap_mode : <optional> <<int>> 0031 % = 0 : current is averaged over overlapped time window 0032 % = 1 : current is not averaged for overlapped window 0033 % current time series of each time windows 0034 % are concatenated sequentially for spectral analysis 0035 % ix_trial : <optional> Trial indices for which currents are 0036 % reconstructed. 0037 % verbose : <<bool>> Verbose flag. 0038 % --- 0039 % 0040 % [note] If following field is given, these values are used instead of 0041 % bayes_parm field in result file: 0042 % --- 0043 % curr_parm.basisfile 0044 % curr_parm.megfile 0045 % curr_parm.megfile_baseline 0046 % curr_parm.twin_meg 0047 % curr_parm.Tperiod 0048 % curr_parm.Tnext 0049 % --- 0050 % 0051 % [output] 0052 % Zact : active current 0053 % 0054 % Zact(n,t,:) is the current at the vertex 'ix_act(n)' & the time 't' 0055 % Zact(Nact,Nsample) for trial_average = ON 0056 % Zact(Nact,Nsample,Ntrials) for trial_average = OFF 0057 % Nact : # of active region, 0058 % Nsample : # of time sample, 0059 % Ntrials : # of trials in all session] 0060 % Jinfo: <<struct>> Information of cortical current. 0061 % --- fields of Jinfo 0062 % version : <<string>> Version of cortical current file. 0063 % curr_type : <<string>> 'Z-current'. It can be 'J-current' for VBMEG 0064 % version 0.8 or older. 0065 % Wact : <<float matrix>> Smoothing Gaussian filter, mapping from 0066 % Z-current to J-current. 0067 % ix_act : <<int vector>>: Vertex indices of Z-current. 0068 % ix_act_ex : <<int vector>>: Vertex indices of J-current. 0069 % Lact : <<int>> Number of current direction at one vertex. 0070 % Tsample : <<int vector>> Time sample indices of the original MEG 0071 % data. length(Tsample) == size(Zact,2) == size(Jact,2). 0072 % Tmsec : <<float vector>> Time in msec. 0073 % SampleFreq: <<float>> Sample frequency of cortical current, not 0074 % original M/EEG signal [Hz]. 0075 % Pretrigger: <<int>> Time points of the length of the pretrigger 0076 % period of cortical current data. It is neither actual time 0077 % nor time points of the original M/EEG signal. 0078 % Ntrial : <<int>> Number of trials of estimated current. 0079 % patch_norm: <<bool>> Cortical current is patch size normalized 0080 % (Am/m^2) or not (Am). 0081 % Tix : <<L x 1 cell>> Time sample indices of each time window. 0082 % Zact(:,Tix{n},:) is the set of Z-current within the n-th 0083 % time window. 0084 % --- 0085 % 0086 % [history] 0087 % 2006-09-03 M. Sato 0088 % * Non-overlapped concatenation mode is added for spectral analysis 0089 % 2008-08-25 Taku Yoshioka 0090 % Extra dipole support 0091 % 2008-09-30 Taku Yoshioka 0092 % Minor change for variables in Jinfo 0093 % 2008-10-23 Taku Yoshioka 0094 % Bug fix for current estimation without extra dipoles 0095 % 2009-04-02 Taku Yoshioka 0096 % Parameter name changed within this code for readability 0097 % (just replacing 'resultfile' to bayesfile) 0098 % 2010-03-01 M. Sato 0099 % Bug fix for Wact index and fieldname(tsubsamp->tsubsmpl) 0100 % 2010-05-26 Taku Yoshioka 0101 % Message display changed 0102 % 2010-12-06 taku-y 0103 % [enhancement] curr_parm.dsampf supported. 0104 % [minor] Following fields of Jinfo set in this function: 0105 % SampleFreq 0106 % Pretrigger 0107 % Tmsec 0108 % [trivial] Jinfo.version = vb_version. 0109 % 2010-12-07 taku-y 0110 % [trivial] Jinfo.version = vbmeg('version'); 0111 % 2011-05-11 takiu-y 0112 % [debug] Jinfo.Tmsec corrected. 0113 % 2011-06-28 taku-y 0114 % [minor] Jinfo.Tix added. 0115 % 2012-02-15 taku-y 0116 % [debug] Jinfo.SampleFreq could be empty in a certain case. This bug 0117 % was fixed. 0118 % 2017-10-25 Yusuke Takeda 0119 % Modified for dipoles with multiple orientations 0120 % 0121 % Copyright (C) 2011, ATR All Rights Reserved. 0122 % License : New BSD License(see VBMEG_LICENSE.txt) 0123 0124 if ~isempty(proj_root) 0125 bayesfile = [proj_root filesep curr_parm.bayesfile]; 0126 else 0127 bayesfile = curr_parm.bayesfile; 0128 end 0129 0130 % 0131 % Verbose level setting 0132 % (note: 'verbose_level' is not related to input variable 0133 % 'curr_parm.verbose'. So two configurations relating to message display 0134 % are coexisting in this function.) 0135 % 0136 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0137 global vbmeg_inst 0138 verbose_const = vb_define_verbose; 0139 0140 if isempty(vbmeg_inst) | ~isfield(vbmeg_inst,'verbose_level'), 0141 verbose_level = verbose_const.VERBOSE_LEVEL_NOTICE; 0142 else 0143 verbose_level = vbmeg_inst.verbose_level; 0144 end 0145 0146 % 0147 % load VBMEG estimated result 0148 % 0149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0150 load(bayesfile, 'bayes_parm','Model','vb_parm','Model_ext','Pointlist'); 0151 0152 % 0153 % check parameter of 'curr_parm' 0154 % 0155 % Values of 'curr_parm' fields dominates over 0156 % those of 'bayes_parm' in bayesfile 0157 % 0158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0159 % save trial_average setting of bayse.mat for Cov 0160 bayes_trial_average = bayes_parm.trial_average; 0161 [bayes_parm,ix_area,trial_average,tsubsamp,overlap_mode,verbose,dsampf] ... 0162 = check_arg(bayes_parm,curr_parm); 0163 0164 if ~isempty(proj_root); 0165 bayes_parm_abs = vb_parm_absolute_path(proj_root, bayes_parm); 0166 else 0167 bayes_parm_abs = bayes_parm; 0168 end 0169 0170 % current file directory 0171 if ~isempty(proj_root) 0172 currfile = fullfile(proj_root, curr_parm.currfile); 0173 else 0174 currfile = [curr_parm.currfile]; 0175 end 0176 0177 % jactdir is relative path from current file 0178 jactdir = curr_parm.jactdir; 0179 curr_root = fileparts(currfile); 0180 jactdir_ab = fullfile(curr_root, jactdir); 0181 0182 %check directory 0183 if exist(jactdir_ab,'dir') ~= 0 0184 if verbose_level>=verbose_const.VERBOSE_LEVEL_NOTICE, 0185 msg = [ 'jact_dir : ' jactdir_ab ' exists. Do you over write?']; 0186 btn = questdlg(msg, 'confirm', 'Yes', 'No', 'Yes'); 0187 if strcmp(btn, 'No') 0188 error('processing aborted.'); 0189 return; 0190 end 0191 else 0192 vb_disp(['jact_dir : ' jactdir_ab ' exists. So files in this ' ... 0193 'directory are overwritten with new ones.'], ... 0194 verbose_const.VERBOSE_LEVEL_WARNING); 0195 end 0196 else 0197 res = mkdir(curr_root, jactdir); 0198 if res~= 1, error('mkdir failed.'); end 0199 end 0200 0201 % Trial indices 0202 if isfield(bayes_parm_abs,'ix_trial'), 0203 bayes_parm_abs.ix_trial = bayes_parm_abs.ix_trial; 0204 elseif isfield(curr_parm,'ix_trial'), 0205 bayes_parm_abs.ix_trial = curr_parm.ix_trial; 0206 else 0207 bayes_parm_abs.ix_trial = []; 0208 end 0209 0210 % 0211 % MEG data preparation 0212 % B : MEG data 0213 % 0214 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0215 [B,Ntrials,Nch,Tsample,Twindow,Tmsec] ... 0216 = vb_megdata_preparation(bayes_parm_abs); 0217 MEGinfo = vb_load_meg_info(bayes_parm_abs.megfile{1}); 0218 0219 % 0220 % Preparation of lead fields 0221 % Gact : leadfield of focal window 0222 % ix_act : Vertex index corresponding to active current Zact 0223 % ix_act_ex : Vertex index corresponding to active current Jact 0224 % Wact : Spatial smoothing matrix of focal window 0225 % 0226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0227 0228 % Focal window 0229 vb_disp('Lead field matrix of focal window'); 0230 0231 lf_parm.brainfile = bayes_parm_abs.brainfile; 0232 lf_parm.areafile = bayes_parm_abs.areafile; 0233 lf_parm.patch_norm = bayes_parm_abs.patch_norm; 0234 lf_parm.expand_spatial_filter = bayes_parm_abs.expand_spatial_filter; 0235 lf_parm.spatial_smoother = bayes_parm_abs.spatial_smoother; 0236 lf_parm.basisfile = bayes_parm_abs.basisfile; 0237 lf_parm.area_key = bayes_parm_abs.area_key; 0238 lf_parm.reduce = bayes_parm_abs.reduce; 0239 lf_parm.Rfilt = bayes_parm_abs.Rfilt; 0240 lf_parm.remove_area_key = []; 0241 0242 Norient = vb_parm.Norient; % Number of current orientation component 0243 Norient_var = vb_parm.Norient_var;% Number of current orientation component 0244 % for variance estimation 0245 Ratio = Norient/Norient_var; % = (# of orientation) 0246 % /(# of orientation in variance) 0247 0248 [Gact, ix_act, ix_act_ex, Wact, Lact] = ... 0249 vb_leadfield_preparation(lf_parm); 0250 0251 % Extra dipole 0252 if isfield(bayes_parm_abs,'extra') & ~isempty(bayes_parm_abs.extra), 0253 vb_struct2vars(bayes_parm_abs,{'extra'}); 0254 vb_disp('Lead field matrix of extra dipoles'); 0255 for n=1:length(extra.basisfile) 0256 tmp = vb_load_basis(extra.basisfile{n}); 0257 Gext{n} = tmp'; 0258 end 0259 else 0260 Gext = []; 0261 end 0262 0263 % 0264 % Area index in which current is calculated 0265 % 0266 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0267 if ~isempty(ix_area), 0268 % Select vertex index 'ix_area' within the active current region 0269 [jx_area_ex, ix_area_ex] = vb_index2indexsub(ix_area, ix_act_ex); 0270 else 0271 jx_area_ex = 1:length(ix_act_ex); 0272 end 0273 0274 Wact = Wact(jx_area_ex,:); 0275 jx_act = find( sum(Wact, 1) > 0); 0276 Wact = Wact(:,jx_act); 0277 0278 % active index of Z-current 0279 ix_act = ix_act(jx_act); 0280 % active index of J-current 0281 ix_act_ex = ix_act_ex(jx_area_ex); 0282 0283 % # of active vertex 0284 Njact_area = length(jx_act); 0285 0286 % # of extra dipoles 0287 if ~isempty(Gext), Njext = size(Gext{1},2); 0288 else Njext = 0; end 0289 0290 % 0291 % Constant 0292 % 0293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0294 Nsession = length(B); % Number of sessions 0295 Ntotal = sum(Ntrials); % Total number of trials in all sessions 0296 0297 % 0298 % Temporal subsampling index 0299 % 0300 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0301 sampf = MEGinfo.SampleFreq; 0302 0303 if ~isempty(dsampf), 0304 tsubsamp = ceil(1:sampf/dsampf:Tsample); 0305 Jinfo.SampleFreq = dsampf; 0306 else 0307 if isempty(tsubsamp), tsubsamp = 1:Tsample; end 0308 Jinfo.SampleFreq = sampf; 0309 end 0310 0311 Jinfo.Tmsec = Tmsec(tsubsamp); 0312 [tmp,ix] = min(abs(Tmsec(tsubsamp))); 0313 Jinfo.Pretrigger = ix; 0314 0315 % 0316 % Temporal smoothing window weight 0317 % 0318 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0319 [Tweight,Tindex,Nindex,Nsample] = ... 0320 vb_overlapped_timewindow_weight(Twindow,Tsample,tsubsamp, ... 0321 overlap_mode); 0322 0323 Nwindow = length(Nindex); % # of time window 0324 Jinfo.Tix = Nindex; 0325 0326 if overlap_mode == 1, 0327 vb_disp('Non-overlapped concatenation mode'); 0328 end 0329 0330 % 0331 % Initialization 0332 % 0333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0334 0335 % Current averaged over trials 0336 Zact_ave = zeros(Njact_area*Ratio,Nsample); 0337 Jext_ave = zeros(Njext*Ratio,Nsample); 0338 0339 % 0340 % Estimated current variance 0341 % 0342 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0343 a_inv = Model.a; 0344 if ~isempty(Model_ext), e_inv = Model_ext.a; 0345 else e_inv = []; end 0346 0347 % Modified by M. Sato 2015-12-25 0348 %Cov = Model.Cov; 0349 % Cov = Normalized noise covariance matrix 0350 bayes_parm_abs.trial_average = bayes_trial_average; 0351 [Cov] = vb_observation_noise_specification(bayes_parm_abs); 0352 0353 % 0354 % Time window loop 0355 % 0356 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0357 Ntrial_all = 0; 0358 0359 % Current Info 0360 Jinfo.version = '2.0-0.b.9'; %vbmeg('version'); 0361 Jinfo.curr_type = 'Z-current'; 0362 0363 Jinfo.tindex = tsubsamp; 0364 Jinfo.Lact = Lact; 0365 Jinfo.Wact = Wact; 0366 Jinfo.ix_act = ix_act; 0367 Jinfo.ix_act_ex = ix_act_ex; 0368 Jinfo.NJact = Njact_area; 0369 0370 % MEG time window index 0371 Tstart = bayes_parm.twin_meg(1); 0372 Tend = bayes_parm.twin_meg(2); 0373 if isempty(tsubsamp) 0374 Jinfo.Tsample = Tstart:Tend; 0375 else 0376 Jinfo.Tsample = tsubsamp + Tstart - 1; 0377 end 0378 0379 % Session loop 0380 for n=1:Nsession 0381 Ntry = size(B{n},3); 0382 Ntrials(n) = Ntry; 0383 0384 % Lead field for each session 0385 G = Gact{n}; % Ga 0386 if ~isempty(Gext), Ge = Gext{n}; else Ge = []; end 0387 Covs = Cov{n}; % Sg 0388 Nch = size(G,1); 0389 0390 %%%% Calculate Inverse filter for all time window 0391 for j=1:Nwindow 0392 Nid = Nindex{j}; % index in the total subsampled data 0393 if isempty(Nid), continue; end 0394 0395 if ~isempty(e_inv), 0396 [KW{j},KW_ext{j}] ... 0397 = vb_invfilter_z(a_inv(:,j),G,Covs,jx_act,e_inv(:,j),Ge); 0398 else 0399 [KW{j},KW_ext{j}] ... 0400 = vb_invfilter_z(a_inv(:,j),G,Covs,jx_act,[],[]); 0401 end 0402 end % Timewindow loop END 0403 0404 %%%% Current reconstruction 0405 for m=1:Ntry 0406 Zact = zeros(Njact_area*Ratio,Nsample); 0407 Jext = zeros(Njext*Ratio,Nsample); 0408 0409 for j=1:Nwindow 0410 % Subsampling time index 0411 Tid = Tindex{j}; % subsampled time index 0412 Nid = Nindex{j}; % index in the total subsampled data 0413 0414 if isempty(Nid), continue; end 0415 0416 %%%% Time window smoothing 0417 Bt = vb_repmultiply( B{n}(:,Tid,m) , Tweight{j}); 0418 0419 Zact(:,Nid) = Zact(:,Nid) + (KW{j} * Bt); 0420 if ~isempty(KW_ext{j}), 0421 Jext(:,Nid) = Jext(:,Nid) + (KW_ext{j} * Bt); 0422 end 0423 end % Timewindow loop END 0424 0425 % Trial average current 0426 Zact_ave = Zact_ave + Zact; 0427 Jext_ave = Jext_ave + Jext; 0428 Ntrial_all = Ntrial_all + 1; 0429 0430 fname = sprintf('data_s%04dt%04d',n,m); 0431 vb_fsave([jactdir_ab '/' fname], 'Zact','Jinfo','Jext','Pointlist', ... 0432 'MEGinfo','bayes_parm','vb_parm'); 0433 if verbose==1, 0434 fprintf('.') 0435 if rem(m, 20) == 0 % linefeed per 20 0436 fprintf('\n'); 0437 end 0438 elseif verbose==2, 0439 fprintf('progress... session:%04d/%04d, trial:%04d/%04d\n',... 0440 n,Nsession,m,Ntry); 0441 end 0442 end % Trial loop END 0443 end % Session loop END 0444 0445 Zact_ave = Zact_ave/Ntrial_all; 0446 Jext_ave = Jext_ave/Ntrial_all; 0447 0448 Jinfo.Ntrial = Ntrials; 0449 Jinfo.Nsession = Nsession; 0450 Jinfo.jactdir = jactdir; 0451 0452 % ix_act : Vertex index corresponding to active current Zact 0453 % ix_act_ex : Vertex index corresponding to active current Jact 0454 % Wact : Spatial smoothing matrix of focal window 0455 % Jact = Wact * Zact 0456 0457 % Actual time corresponding to columns of Zact, supporting overlap mode 0458 % and non-overlapped concatenation mode 0459 Tid_all = []; 0460 Nid_all = []; 0461 for j=1:Nwindow 0462 Tid_all = [Tid_all Tindex{j}]; 0463 Nid_all = [Nid_all Nindex{j}]; 0464 end 0465 0466 if overlap_mode==false, 0467 ix = unique(Tid_all); 0468 Jinfo.Tmsec = Tmsec(ix); 0469 else 0470 Jinfo.Tmsec = Tmsec(Tid_all); 0471 end 0472 0473 %Tstart = bayes_parm.twin_meg(1); 0474 %Tend = bayes_parm.twin_meg(2); 0475 %if isempty(tsubsamp) 0476 % Jinfo.Tsample = Tstart:Tend; 0477 %else 0478 % Jinfo.Tsample = tsubsamp + Tstart - 1; 0479 %end 0480 0481 if verbose==1, 0482 fprintf('\n') 0483 end 0484 0485 return; 0486 0487 %%%% --------------- 0488 function [bayes_parm,ix_area,trial_average,tsubsamp,overlap_mode,verbose,dsampf]= ... 0489 check_arg(bayes_parm,curr_parm) 0490 0491 if isfield(curr_parm,'basisfile'), 0492 bayes_parm.basisfile = curr_parm.basisfile; 0493 end; 0494 if isfield(curr_parm,'megfile'), 0495 bayes_parm.megfile = curr_parm.megfile ; 0496 end; 0497 if isfield(curr_parm,'twin_meg'), 0498 bayes_parm.twin_meg = curr_parm.twin_meg ; 0499 end; 0500 if isfield(curr_parm,'Tperiod'), 0501 bayes_parm.Tperiod = curr_parm.Tperiod ; 0502 end; 0503 if isfield(curr_parm,'Tnext'), 0504 bayes_parm.Tnext = curr_parm.Tnext ; 0505 end; 0506 if isfield(curr_parm,'megfile_baseline'), 0507 bayes_parm.megfile_baseline = curr_parm.megfile_baseline ; 0508 end; 0509 0510 if ~isfield(curr_parm,'trial_average'), 0511 trial_average = ON; 0512 else 0513 trial_average = curr_parm.trial_average; 0514 end; 0515 0516 bayes_parm.trial_average = trial_average; 0517 0518 if ~isfield(curr_parm,'ix_area'), 0519 ix_area = []; 0520 else 0521 ix_area = curr_parm.ix_area; 0522 end; 0523 if ~isfield(curr_parm,'tsubsmpl'), 0524 tsubsamp = []; 0525 else 0526 tsubsamp = curr_parm.tsubsmpl; 0527 end; 0528 if ~isfield(curr_parm,'overlap_mode'), 0529 overlap_mode = 0; 0530 else 0531 overlap_mode = curr_parm.overlap_mode; 0532 end; 0533 if ~isfield(curr_parm,'verbose'), 0534 verbose = 1; 0535 else 0536 verbose = curr_parm.verbose; 0537 end; 0538 0539 if isfield(curr_parm,'extra'), 0540 if isfield(curr_parm.extra,'basisfile'), 0541 bayes_parm.extra.basisfile = curr_parm.extra.basisfile; 0542 end; 0543 end; 0544 0545 if ~isfield(curr_parm,'dsampf'), 0546 dsampf = []; 0547 else 0548 dsampf = curr_parm.dsampf; 0549 end 0550 0551 return;