Home > vbmeg > functions > estimation > bayes > vb_current_reconstruct_z.m

vb_current_reconstruct_z

PURPOSE ^

Current reconstruction using Bayesian inverse filter.

SYNOPSIS ^

function [Zact,Jinfo,bayes_parm,vb_parm,MEGinfo,Jext,Pointlist]= vb_current_reconstruct_z(proj_root, curr_parm)

DESCRIPTION ^

 Current reconstruction using Bayesian inverse filter.

 [syntax]
  [Zact,Jinfo,bayes_parm,vb_parm,MEGinfo,Jext,Pointlist] ...
          = vbmeg_current_reconstruct_z(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. 
  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
  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
  curr_parm.extra.basisfile (for extra dipole)
 ---

 [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]
 --- 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.
 ---

 * Inverse filter calculation is done in vb_invfilter_calc

 [history]
 2006-09-03 M. Sato
 * Non-overlapped concatenation mode is added for spectral analysis
 2008-08-19 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-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.
 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)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

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

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