Home > vbmeg > functions > job > vb_job_current.m

vb_job_current

PURPOSE ^

Estimate current time course by using inverse filter.

SYNOPSIS ^

function [Zact, Jinfo, Jext] = vb_job_current(varargin)

DESCRIPTION ^

 Estimate current time course by using inverse filter. 
 (VBMEG public function)

 [syntax]
 [Zact,Jinfo,Jext] = vb_job_current(curr_parm)
 [Zact,Jinfo,Jext] = vb_job_current(proj_root,curr_parm) [old style]

 [input]
 proj_root: <<string>> VBMEG project root directory. 
 curr_parm: <<struct>> Current estimation parameters. 
 --- fields of curr_parm
  bayesfile    : <<string>> Model parameter filename (.bayes.mat). This
                 file is required for current estimation and obtained by
                 vb_job_vb before running this function. 
  currfile     : <<string>> Cortical current filename (.curr.mat),
                 specifying the file to which current estimation result
                 is saved. 
  area_key     : <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     : <optional> <<string>> Rquired if cortical area is
                 specified by field 'area_key'. 
  trial_average: <optional> <<bool>> If true (default), cortical current
                 averaged across all trials. If false, cortical current
                 is estimated for all trials. 
  jactdir      : <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       : <optional> <<int>> Specify frequency of
                 downsampling. This value must be smaller than the
                 original sampling frequency of M/EEG data. 
  tsubsmpl     : <obsolete> <optional> <<int vector>> Specify subsampled
                 time index. If 'tsubsmpl' is empty or not given, time
                 subsampling is not done. Instead of this, 'dsampf'
                 parameter is recommended for downsampling. 
  overlap_mode : <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. 
  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.areafile = './NG/data/100009d.area.mat';
 >> parm.bayesfile = './NG/result/result3_col.bayes.mat';
 >> parm.trial_average = OFF;
 >> parm.area_key = 'fMTl';
 >> parm.currfile = './result/result3_col_fMTl_1.curr.mat';
 >> vb_job_current(parm);

 2005-03-31 Taku Yoshioka
 2005/08/22 O. Yamashita ver.30b
 2005/08/24 O. Yamashita Modified
 2006/03/24 M. Sato Modified
   Eliminate zero variance point in current reconstruction
 2006/04/06 D. Kawawaki modified  
   'project root' problem was solved.
 2006/07/19 O. Yamashita Modified
 2006/09/01 M. Sato
 2008/07/01 M. Sato
  alpha is scaled back by bsnorm before saving in new vb_job_vb
  Then, current is calculated by using leadfield without normalization
  Leadfield different from that used in VB estimation can be used
 2008-08-19 Taku Yoshioka
  Extended dipole was supported. 
 2009-04-02 Taku Yoshioka
  Parameter name changed within this code for readability
  (just replacing 'resultfile' to bayesfile)
 2009-03-01 rhayashi
  bugfix(ix_area was not given to vbmeg_reconstruct functions)
 2010-12-03 taku-y
  [trivial] Comment modified.
  [trivial] Struct 'curr_parm' available without field 'areafile'. 
 2010-12-06 taku-y
  [trivial] Comment modified.
 2011-05-11 taku-y
  [minor] 'vbmeg_current_reconstruct_z(_tr)' was replaced by
  'vb_current_reconstruct_z(_tr)', which is the same excepting
  Jinfo.Tmsec corresponds to overlaped time windows.

 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:

SOURCE CODE ^

0001 function [Zact, Jinfo, Jext] = vb_job_current(varargin)
0002 % Estimate current time course by using inverse filter.
0003 % (VBMEG public function)
0004 %
0005 % [syntax]
0006 % [Zact,Jinfo,Jext] = vb_job_current(curr_parm)
0007 % [Zact,Jinfo,Jext] = vb_job_current(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 %  bayesfile    : <<string>> Model parameter filename (.bayes.mat). This
0014 %                 file is required for current estimation and obtained by
0015 %                 vb_job_vb before running this function.
0016 %  currfile     : <<string>> Cortical current filename (.curr.mat),
0017 %                 specifying the file to which current estimation result
0018 %                 is saved.
0019 %  area_key     : <optional> <<string>> Area ID on which cortical current
0020 %                 is estimated. This parameter will be useful if you have
0021 %                 some knowledge about region of interested.
0022 %  areafile     : <optional> <<string>> Rquired if cortical area is
0023 %                 specified by field 'area_key'.
0024 %  trial_average: <optional> <<bool>> If true (default), cortical current
0025 %                 averaged across all trials. If false, cortical current
0026 %                 is estimated for all trials.
0027 %  jactdir      : <optional> <<string>> Directory for saving trial
0028 %                 current files. This is the relative path from the
0029 %                 cortical current file. If trial_average == false &
0030 %                 jactdir is specified, current for each trial is saved
0031 %                 as trial current file.
0032 %  dsampf       : <optional> <<int>> Specify frequency of
0033 %                 downsampling. This value must be smaller than the
0034 %                 original sampling frequency of M/EEG data.
0035 %  tsubsmpl     : <obsolete> <optional> <<int vector>> Specify subsampled
0036 %                 time index. If 'tsubsmpl' is empty or not given, time
0037 %                 subsampling is not done. Instead of this, 'dsampf'
0038 %                 parameter is recommended for downsampling.
0039 %  overlap_mode : <optional> <<bool>> If false (default), cortical
0040 %                 current is averaged over overlapped time
0041 %                 windows. Otherwise, current is not averaged over
0042 %                 overlapped time windows; current time series of each
0043 %                 time windows are concatenated sequentially for spectral
0044 %                 analysis.
0045 %  If following fields are given, these values are used instead of
0046 %  bayes_parm field in result file (see vb_job_vb):
0047 %   basisfile
0048 %   megfile
0049 %   twin_meg
0050 %   Tperiod
0051 %   Tnext
0052 %   extra.basisfile (for extra dipole)
0053 % ---
0054 %
0055 % [output]
0056 % Zact : <<float matrix>> Z-current.
0057 %  Zact(n,t,:) is the current at the vertex 'ix_act(n)' & the time 't'.
0058 %  Zact(Nact,Nsample)          for trial_average = true.
0059 %  Zact(Nact,Nsample,Ntrials)  for trial_average = false.
0060 %   Nact     : # of active region,
0061 %   Nsample  : # of time sample,
0062 %   Ntrials  : # of trials in all session]
0063 % Jinfo: <<struct>> Information of cortical current.
0064 % Jext : <<double matrix>> Extra dipole current.
0065 %
0066 % [example]
0067 % >> parm.areafile = './NG/data/100009d.area.mat';
0068 % >> parm.bayesfile = './NG/result/result3_col.bayes.mat';
0069 % >> parm.trial_average = OFF;
0070 % >> parm.area_key = 'fMTl';
0071 % >> parm.currfile = './result/result3_col_fMTl_1.curr.mat';
0072 % >> vb_job_current(parm);
0073 %
0074 % 2005-03-31 Taku Yoshioka
0075 % 2005/08/22 O. Yamashita ver.30b
0076 % 2005/08/24 O. Yamashita Modified
0077 % 2006/03/24 M. Sato Modified
0078 %   Eliminate zero variance point in current reconstruction
0079 % 2006/04/06 D. Kawawaki modified
0080 %   'project root' problem was solved.
0081 % 2006/07/19 O. Yamashita Modified
0082 % 2006/09/01 M. Sato
0083 % 2008/07/01 M. Sato
0084 %  alpha is scaled back by bsnorm before saving in new vb_job_vb
0085 %  Then, current is calculated by using leadfield without normalization
0086 %  Leadfield different from that used in VB estimation can be used
0087 % 2008-08-19 Taku Yoshioka
0088 %  Extended dipole was supported.
0089 % 2009-04-02 Taku Yoshioka
0090 %  Parameter name changed within this code for readability
0091 %  (just replacing 'resultfile' to bayesfile)
0092 % 2009-03-01 rhayashi
0093 %  bugfix(ix_area was not given to vbmeg_reconstruct functions)
0094 % 2010-12-03 taku-y
0095 %  [trivial] Comment modified.
0096 %  [trivial] Struct 'curr_parm' available without field 'areafile'.
0097 % 2010-12-06 taku-y
0098 %  [trivial] Comment modified.
0099 % 2011-05-11 taku-y
0100 %  [minor] 'vbmeg_current_reconstruct_z(_tr)' was replaced by
0101 %  'vb_current_reconstruct_z(_tr)', which is the same excepting
0102 %  Jinfo.Tmsec corresponds to overlaped time windows.
0103 %
0104 % Copyright (C) 2011, ATR All Rights Reserved.
0105 % License : New BSD License(see VBMEG_LICENSE.txt)
0106 
0107 %
0108 % check input arguments
0109 %
0110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0111 if length(varargin) == 1
0112   proj_root = [];
0113   curr_parm = varargin{1};
0114 elseif length(varargin) == 2
0115   proj_root = varargin{1};
0116   curr_parm = varargin{2};
0117 else
0118   error('Error: invalid usage of job_current.');
0119 end
0120 
0121 proj_root = vb_rm_trailing_slash(proj_root);
0122 
0123 if ~isfield(curr_parm,'trial_average'), 
0124   curr_parm.trial_average = true; 
0125 end
0126 
0127 if ~isfield(curr_parm,'areafile'), 
0128   curr_parm.areafile = [];
0129 end
0130 
0131 %
0132 % set absolute path
0133 %
0134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0135 if ~isempty(proj_root)
0136   bayesfile = [proj_root filesep curr_parm.bayesfile]; % bayes file
0137   currfile  = [proj_root filesep curr_parm.currfile];  % current file
0138   if isfield(curr_parm, 'areafile')
0139     areafile   = [proj_root filesep curr_parm.areafile];   % vb_get_area
0140   end
0141 else
0142   bayesfile = curr_parm.bayesfile;
0143   currfile  = curr_parm.currfile;
0144   if isfield(curr_parm, 'areafile')
0145     areafile   = curr_parm.areafile;
0146   end
0147 end
0148 
0149 %
0150 % Current estimation
0151 %
0152 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0153 vb_disp('Start current estimation')
0154 
0155 if ~isempty(areafile) ...
0156   & isfield(curr_parm, 'area_key') & ~isempty(curr_parm.area_key),
0157     Area = vb_get_area(areafile, curr_parm.area_key);
0158     ix_area = Area.Iextract;
0159 else
0160     ix_area = [];
0161 end
0162 
0163 parm = curr_parm;
0164 parm.ix_area = ix_area;
0165 if curr_parm.trial_average == false ...
0166       && isfield(curr_parm,'jactdir') && ~isempty(curr_parm.jactdir)
0167   [Zact, Jinfo, bayes_parm, vb_parm, MEGinfo, Jext, Pointlist] ...
0168       = vb_current_reconstruct_z_tr(proj_root, parm);
0169 else
0170   [Zact, Jinfo, bayes_parm, vb_parm, MEGinfo, Jext, Pointlist] ...
0171       = vb_current_reconstruct_z(proj_root, parm);
0172 end;
0173 
0174 % load brain vertex number
0175 brain_file = fullfile(proj_root, bayes_parm.brainfile);
0176 Nvertex = vb_load_cortex_info(brain_file);
0177 
0178 
0179 %
0180 % Save result
0181 %
0182 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0183 vb_disp(sprintf('--- Save estimated current: %s\n',currfile));
0184 vb_fsave(currfile,'Zact','Jinfo','MEGinfo','bayes_parm','vb_parm',...
0185          'Jext','Pointlist', 'curr_parm', 'Nvertex');
0186 
0187 %
0188 % project_file save
0189 %
0190 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0191 proj_file = get_project_filename;
0192 if isempty(proj_file)
0193   return;
0194 end
0195 
0196 project_file_mgr('load', proj_file);
0197 project_file_mgr('add', 'current_parm', curr_parm);
0198 
0199 return;

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