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