Home > vbmeg > functions > tool_box > meeg_open_code > vb_current_reconstruct_z_meeg.m

vb_current_reconstruct_z_meeg

PURPOSE ^

Current reconstruction using Bayesian inverse filter.

SYNOPSIS ^

function [Zact,Jinfo,bayes_parm,vb_parm,MEGinfo,Jext,Pointlist]= vb_current_reconstruct_z_meeg(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.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-03-16 rhayashi
  spatial_smoother is added.
 2017-12-8 rhayashi
  [debug] The specified eegfile not used.
 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_meeg(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.twin_meg
0042 %  curr_parm.Tperiod
0043 %  curr_parm.Tnext
0044 %  curr_parm.extra.basisfile (for extra dipole)
0045 % ---
0046 %
0047 % [output]
0048 % Zact    : active current
0049 %
0050 % Zact(n,t,:) is the current at the vertex 'ix_act(n)' & the time 't'
0051 % Zact(Nact,Nsample)          for trial_average = ON
0052 % Zact(Nact,Nsample,Ntrials)  for trial_average = OFF
0053 %   Nact     : # of active region,
0054 %   Nsample  : # of time sample,
0055 %   Ntrials  : # of trials in all session]
0056 % --- fields of Jinfo
0057 %  version   : <<string>> Version of cortical current file.
0058 %  curr_type : <<string>> 'Z-current'. It can be 'J-current' for VBMEG
0059 %              version 0.8 or older.
0060 %  Wact      : <<float matrix>> Smoothing Gaussian filter, mapping from
0061 %              Z-current to J-current.
0062 %  ix_act    : <<int vector>>: Vertex indices of Z-current.
0063 %  ix_act_ex : <<int vector>>: Vertex indices of J-current.
0064 %  Lact      : <<int>> Number of current direction at one vertex.
0065 %  Tsample   : <<int vector>> Time sample indices of the original MEG
0066 %              data. length(Tsample) == size(Zact,2) == size(Jact,2).
0067 %  Tmsec     : <<float vector>> Time in msec.
0068 %  SampleFreq: <<float>> Sample frequency of cortical current, not
0069 %              original M/EEG signal [Hz].
0070 %  Pretrigger: <<int>> Time points of the length of the pretrigger
0071 %              period of cortical current data. It is neither actual time
0072 %              nor time points of the original M/EEG signal.
0073 %  Ntrial    : <<int>> Number of trials of estimated current.
0074 %  patch_norm: <<bool>> Cortical current is patch size normalized
0075 %              (Am/m^2) or not (Am).
0076 %  Tix       : <<L x 1 cell>> Time sample indices of each time window.
0077 %              Zact(:,Tix{n},:) is the set of Z-current within the n-th
0078 %              time window.
0079 % ---
0080 %
0081 % * Inverse filter calculation is done in vb_invfilter_calc
0082 %
0083 % [history]
0084 % 2006-09-03 M. Sato
0085 % * Non-overlapped concatenation mode is added for spectral analysis
0086 % 2008-08-19 Taku Yoshioka
0087 %   Extra dipole support
0088 % 2008-09-30 Taku Yoshioka
0089 %   Minor change for variables in Jinfo
0090 % 2008-10-23 Taku Yoshioka
0091 %  Bug fix for current estimation without extra dipoles
0092 % 2009-04-02 Taku Yoshioka
0093 %  Parameter name changed within this code for readability
0094 %  (just replacing 'resultfile' to bayesfile)
0095 % 2010-03-01 M. Sato
0096 %  Bug fix for Wact index and fieldname(tsubsamp->tsubsmpl)
0097 % 2010-12-06 taku-y
0098 %  [enhancement] curr_parm.dsampf supported.
0099 %  [minor]       Following fields of Jinfo set in this function:
0100 %                 SampleFreq
0101 %                 Pretrigger
0102 %                 Tmsec
0103 %  [trivial]     Jinfo.version = vb_version.
0104 % 2010-12-07 taku-y
0105 %  [trivial] Jinfo.version = vbmeg('version');
0106 % 2011-05-11 takiu-y
0107 %  [debug] Jinfo.Tmsec corrected.
0108 % 2011-06-28 taku-y
0109 %  [minor] Jinfo.Tix added.
0110 % 2017-03-16 rhayashi
0111 %  spatial_smoother is added.
0112 % 2017-12-8 rhayashi
0113 %  [debug] The specified eegfile not used.
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 = fullfile(proj_root, 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 [bayes_parm,ix_area,trial_average,tsubsamp,overlap_mode,dsampf] ...
0153     = check_arg(bayes_parm, curr_parm);
0154 
0155 if ~isempty(proj_root)
0156   bayes_parm_abs = vb_parm_absolute_path(proj_root, bayes_parm);
0157 else
0158   bayes_parm_abs = bayes_parm;
0159 end
0160 
0161 %
0162 % MEG data preparation
0163 % B      : MEG data
0164 %
0165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0166 [B0,Ntrials,Nch,Tsample,Twindow,Tmsec] ...
0167     = vb_megdata_preparation(bayes_parm_abs);
0168 MEGinfo = vb_load_meg_info(bayes_parm_abs.megfile{1});
0169 
0170 % EEG data
0171 for n = 1:length(bayes_parm_abs.eegfile)
0172     bayes_parm_abs.eegfile{n} = fullfile(proj_root, bayes_parm_abs.eegfile{n});
0173 end
0174 tmp_parm = bayes_parm_abs;
0175 tmp_parm.megfile = tmp_parm.eegfile;
0176 E   = vb_megdata_preparation(tmp_parm);
0177 
0178 for n = 1:length(B0)
0179     B{n} = [B0{n}./Model.bsnorm_meg; E{n}./Model.bsnorm_eeg];
0180 end
0181 %
0182 % Preparation of lead fields
0183 % Gact   : leadfield of focal window
0184 % ix_act : Vertex index corresponding to active current Zact
0185 % ix_act_ex : Vertex index corresponding to active current Jact
0186 % Wact   : Spatial smoothing matrix of focal window
0187 %
0188 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0189 
0190 % Focal window
0191 vb_disp('--- Lead field matrix of focal window');
0192 
0193 %MEG
0194 lf_parm.basisfile = fullfile(proj_root, bayes_parm_abs.basisfile_meg);
0195 
0196 lf_parm.brainfile = bayes_parm_abs.brainfile;
0197 lf_parm.areafile = bayes_parm_abs.areafile;
0198 lf_parm.patch_norm = bayes_parm_abs.patch_norm;
0199 lf_parm.expand_spatial_filter = bayes_parm_abs.expand_spatial_filter;
0200 lf_parm.spatial_smoother = bayes_parm_abs.spatial_smoother;
0201 lf_parm.area_key = bayes_parm_abs.area_key;
0202 lf_parm.reduce = bayes_parm_abs.reduce;
0203 lf_parm.Rfilt = bayes_parm_abs.Rfilt;
0204 lf_parm.remove_area_key = [];
0205 
0206 [Gact_b, ix_act, ix_act_ex, Wact, Lact] = vb_leadfield_preparation(lf_parm);
0207 
0208 %EEG
0209 lf_parm.basisfile = fullfile(proj_root, bayes_parm_abs.basisfile_eeg);
0210 Gact_e = vb_leadfield_preparation(lf_parm);
0211 
0212 for n = 1:length(Gact_b)
0213     Gact{n} = [Gact_b{n}./Model.bsnorm_meg; Gact_e{n}./Model.bsnorm_eeg];
0214 end
0215 
0216 % Extra dipole
0217 if isfield(bayes_parm_abs,'extra') & ~isempty(bayes_parm_abs.extra), 
0218   vb_struct2vars(bayes_parm_abs,{'extra'});
0219   fprintf('--- Lead field matrix of extra dipoles \n');
0220   for n=1:length(extra.basisfile)
0221     tmp = vb_load_basis(extra.basisfile{n});
0222     Gext{n} = tmp';
0223   end
0224 else
0225   Gext = [];
0226 end
0227 
0228 %
0229 % Area index in which current is calculated
0230 %
0231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0232 if ~isempty(ix_area),
0233   % Select vertex index 'ix_area' within the active current region
0234   [jx_area_ex, ix_area_ex] = vb_index2indexsub(ix_area, ix_act_ex);
0235 else
0236   jx_area_ex = 1:length(ix_act_ex);
0237 end
0238 
0239 Wact   = Wact(jx_area_ex,:);
0240 jx_act = find( sum(Wact, 1) > 0);
0241 Wact   = Wact(:,jx_act);
0242 
0243 % active index of Z-current
0244 ix_act = ix_act(jx_act);
0245 % active index of J-current
0246 ix_act_ex = ix_act_ex(jx_area_ex);
0247 
0248 % # of active vertex
0249 Njact_area = length(jx_act);
0250 
0251 % # of extra dipoles
0252 if ~isempty(Gext), Njext = size(Gext{1},2);
0253 else Njext = 0; end
0254 
0255 %
0256 % Constant
0257 %
0258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0259 Nsession = length(B);     % Number of sessions
0260 Ntotal   = sum(Ntrials); % Total number of trials in all sessions
0261 
0262 %
0263 % Temporal subsampling index
0264 %
0265 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0266 sampf = MEGinfo.SampleFreq;
0267 
0268 if ~isempty(dsampf), 
0269   tsubsamp = ceil(1:sampf/dsampf:Tsample);
0270   Jinfo.SampleFreq = dsampf;
0271 else
0272   if isempty(tsubsamp), tsubsamp = 1:Tsample; end
0273   Jinfo.SampleFreq = sampf;
0274 end
0275 
0276 %Jinfo.Tmsec = Tmsec(tsubsamp);
0277 [tmp,ix] = min(abs(Tmsec(tsubsamp)));
0278 Jinfo.Pretrigger = ix;
0279 
0280 %
0281 % Temporal smoothing window weight
0282 %
0283 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0284 [Tweight ,Tindex, Nindex, Nsample] = ...
0285     vb_overlapped_timewindow_weight(Twindow, Tsample, tsubsamp, overlap_mode);
0286 
0287 Nwindow   = length(Nindex);       % # of time window
0288 Jinfo.Tix = Nindex;
0289 
0290 if overlap_mode == 1,
0291   vb_disp('Non-overlapped concatenation mode'); 
0292 end
0293 
0294 %
0295 % Initialization
0296 %
0297 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0298 if trial_average == ON
0299   % Current averaged over trials
0300   Zact = zeros(Njact_area,Nsample);
0301   Jext = zeros(Njext,Nsample);
0302 else 
0303   % Current for each trial
0304   Zact = zeros(Njact_area,Nsample,Ntotal);
0305   Jext = zeros(Njext,Nsample,Ntotal);
0306 end
0307 
0308 %
0309 % Estimated current variance
0310 %
0311 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0312 a_inv = Model.a;
0313 Cov = Model.Cov;
0314 if ~isempty(Model_ext), e_inv = Model_ext.a;
0315 else e_inv = []; end
0316 
0317 %
0318 % Time window loop
0319 %
0320 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0321 for j=1:Nwindow
0322   % Subsampling time index
0323   Tid = Tindex{j};    % subsampled time index
0324   Nid = Nindex{j};    % index in the total subsampled data
0325   Nt  = length(Tid);
0326     
0327   if Nt == 0, continue; end
0328     
0329   % Session loop
0330   ntrial = 1;
0331     
0332   for n=1:Nsession
0333     Ntry = Ntrials(n);
0334 
0335     G     = Gact{n};    % Ga
0336     if ~isempty(Gext), Ge = Gext{n}; else Ge = []; end
0337     Covs = Cov{n};     % Sg
0338     Nch     = size(G,1);
0339 
0340     %%%% Calculate Inverse filter for current reconstruction
0341     if ~isempty(e_inv), 
0342       [KW,KW_ext] ...
0343           = vb_invfilter_z(a_inv(:,j),G,Covs,jx_act,e_inv(:,j),Ge);
0344     else
0345       [KW,KW_ext] ...
0346           = vb_invfilter_z(a_inv(:,j),G,Covs,jx_act,[],[]);
0347     end
0348         
0349     %%%% Time window smoothing
0350     weight = Tweight{j};
0351 
0352     if trial_average == ON
0353       % MEG trial_average
0354       Bt = vb_repmultiply(B{n}(:,Tid), weight); 
0355       % Current reconstruction
0356       Zact(:,Nid) = Zact(:,Nid) + (KW  * Bt);
0357       if ~isempty(KW_ext), Jext(:,Nid) = Jext(:,Nid) + (KW_ext * Bt); end
0358     else
0359       % MEG for each trial
0360       Bt = B{n}(:,Tid,:);    
0361       for m=1:Ntry
0362         Bt(:,:,m) = vb_repmultiply(Bt(:,:,m) , weight);
0363       end
0364       % Trial index
0365       ix_try = [ntrial:ntrial+Ntry-1];
0366       ntrial = ntrial+Ntry;
0367 
0368       % Current reconstruction
0369       Zact(:,Nid,ix_try) = Zact(:,Nid,ix_try) ...
0370           + reshape( KW * reshape( Bt, [Nch, Nt*Ntry]), ...
0371                      [Njact_area, Nt, Ntry]);
0372       if ~isempty(KW_ext),
0373         Jext(:,Nid,ix_try) = Jext(:,Nid,ix_try) ...
0374             + reshape( KW_ext * reshape( Bt, [Nch, Nt*Ntry]), ...
0375                        [Njext, Nt, Ntry]);
0376       end
0377     end
0378   end % Session loop END
0379 end % Timewindow loop END
0380 
0381 if trial_average == ON
0382   Zact = Zact/Nsession;
0383   Jext = Jext/Nsession;
0384 end
0385 
0386 %
0387 % Current Info
0388 %
0389 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0390 Jinfo.version   = '2.0-0.b.9'; %vbmeg('version');
0391 Jinfo.curr_type = 'Z-current';
0392 
0393 Jinfo.Lact      = Lact;
0394 Jinfo.Wact      = Wact;
0395 Jinfo.ix_act    = ix_act;
0396 Jinfo.ix_act_ex = ix_act_ex;
0397 Jinfo.NJact     = Njact_area;
0398 Jinfo.Nsession  = Nsession;
0399 Jinfo.jactdir   = [];
0400 Jinfo.Ntrial    = Ntrials; 
0401 
0402 % ix_act : Vertex index corresponding to active current Zact
0403 % ix_act_ex : Vertex index corresponding to active current Jact
0404 % Wact   : Spatial smoothing matrix of focal window
0405 % Jact   = Wact * Zact
0406 
0407 % Actual time corresponding to columns of Zact, supporting overlap mode
0408 % and non-overlapped concatenation mode
0409 Tid_all = [];
0410 Nid_all = [];
0411 for j=1:Nwindow
0412   Tid_all = [Tid_all Tindex{j}];
0413   Nid_all = [Nid_all Nindex{j}];
0414 end
0415 
0416 if overlap_mode==false,
0417   ix          = unique(Tid_all);
0418   Jinfo.Tmsec = Tmsec(ix);
0419 else
0420   Jinfo.Tmsec = Tmsec(Tid_all);
0421 end
0422 
0423 %Tstart  = bayes_parm.twin_meg(1);
0424 %Tend    = bayes_parm.twin_meg(2);
0425 %if isempty(tsubsamp)
0426 %  Jinfo.Tsample = Tstart:Tend;
0427 %else
0428 %  Jinfo.Tsample = tsubsamp + Tstart - 1;
0429 %end
0430 
0431 return;
0432 
0433 %%%% ---------------
0434 function [bayes_parm, ix_area, trial_average, tsubsamp, overlap_mode,dsampf] = ...
0435     check_arg(bayes_parm,curr_parm)
0436 
0437 if isfield(curr_parm,'basisfile'), 
0438   bayes_parm.basisfile = curr_parm.basisfile;
0439 end;
0440 if isfield(curr_parm,'megfile'), 
0441   bayes_parm.megfile   = curr_parm.megfile  ;
0442 end;
0443 if isfield(curr_parm,'eegfile'),
0444     bayes_parm.eegfile = curr_parm.eegfile  ;
0445 end;
0446 if isfield(curr_parm,'twin_meg'), 
0447   bayes_parm.twin_meg  = curr_parm.twin_meg ;
0448 end;
0449 if isfield(curr_parm,'Tperiod'), 
0450   bayes_parm.Tperiod   = curr_parm.Tperiod  ;
0451 end;
0452 if isfield(curr_parm,'Tnext'), 
0453   bayes_parm.Tnext     = curr_parm.Tnext    ;
0454 end;
0455 
0456 if ~isfield(curr_parm,'trial_average'), 
0457   trial_average = ON; 
0458 else
0459   trial_average = curr_parm.trial_average; 
0460 end;
0461 
0462 bayes_parm.trial_average = trial_average;
0463 
0464 if ~isfield(curr_parm,'ix_area'),  
0465   ix_area = []; 
0466 else
0467   ix_area = curr_parm.ix_area; 
0468 end;
0469 if ~isfield(curr_parm,'tsubsmpl'), 
0470   tsubsamp = []; 
0471 else
0472   tsubsamp = curr_parm.tsubsmpl; 
0473 end;
0474 if ~isfield(curr_parm,'overlap_mode'),     
0475   overlap_mode = 0; 
0476 else
0477   overlap_mode = curr_parm.overlap_mode; 
0478 end;
0479 
0480 if isfield(curr_parm,'extra'),
0481   if isfield(curr_parm.extra,'basisfile'), 
0482     bayes_parm.extra.basisfile = curr_parm.extra.basisfile;
0483   end;
0484 end;
0485 
0486 if ~isfield(curr_parm,'dsampf'), 
0487   dsampf = [];
0488 else
0489   dsampf = curr_parm.dsampf;
0490 end;
0491 
0492 return;

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