Home > functions > job > vb_job_current_z.m

vb_job_current_z

PURPOSE ^

This script calculates estimated current time courses in a

SYNOPSIS ^

function [Zact,ix_act,Zbck,ix_bck,Varact] = vb_job_current_z(varargin)

DESCRIPTION ^

 This script calculates estimated current time courses in a
 specified area.

 ---
 USAGE:
  function vb_job_current(proj_root,parm)
 or
  function vb_job_current(parm)

 --- Input parameters
 - parm.currfile
   .curr.mat file into which estimated current time courses are
   saved.
 - parm.bayesfile
   .bayes.mat file.

 ---- Optional  (default)
 - parm.areafile ([])  --> focal window
   .area.mat file.
 - parm.area_key ([])
   ID of interested area.
 - parm.trial_average    (ON)
 ON: Average current over all sessions.
 OFF: Current for each session. This option is needed for time
       frequency analysis.
 - parm.tsubsmpl ([]) --> whole time points
   Time points where currents are calculated. For example,
   if tsubsmpl = [1:5:100], currents are calculated at only every 5 sample
   point.
 - parm.overlap_mode 
   = 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

 * Parameters saved in output file (.curr.mat)

 - Zact
 - Zbck
 - ix_act
 - ix_bck
 - Lact
 - Lbck
 - Varact
 - bayes_parm
 - vb_parm
 - Jinfo
 * 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
 2009-04-02 Taku Yoshioka
  Parameter name changed within this code for readability
  (just replacing 'resultfile' to bayesfile)

 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,ix_act,Zbck,ix_bck,Varact] = vb_job_current_z(varargin)
0002 % This script calculates estimated current time courses in a
0003 % specified area.
0004 %
0005 % ---
0006 % USAGE:
0007 %  function vb_job_current(proj_root,parm)
0008 % or
0009 %  function vb_job_current(parm)
0010 %
0011 % --- Input parameters
0012 % - parm.currfile
0013 %   .curr.mat file into which estimated current time courses are
0014 %   saved.
0015 % - parm.bayesfile
0016 %   .bayes.mat file.
0017 %
0018 % ---- Optional  (default)
0019 % - parm.areafile ([])  --> focal window
0020 %   .area.mat file.
0021 % - parm.area_key ([])
0022 %   ID of interested area.
0023 % - parm.trial_average    (ON)
0024 % ON: Average current over all sessions.
0025 % OFF: Current for each session. This option is needed for time
0026 %       frequency analysis.
0027 % - parm.tsubsmpl ([]) --> whole time points
0028 %   Time points where currents are calculated. For example,
0029 %   if tsubsmpl = [1:5:100], currents are calculated at only every 5 sample
0030 %   point.
0031 % - parm.overlap_mode
0032 %   = 0 : current is averaged over overlapped time window
0033 %   = 1 : current is not averaged for overlapped window
0034 %         current time series of each time windows
0035 %         are concatenated sequentially for spectral analysis
0036 %
0037 % * Parameters saved in output file (.curr.mat)
0038 %
0039 % - Zact
0040 % - Zbck
0041 % - ix_act
0042 % - ix_bck
0043 % - Lact
0044 % - Lbck
0045 % - Varact
0046 % - bayes_parm
0047 % - vb_parm
0048 % - Jinfo
0049 % * Example
0050 %
0051 % >> parm.areafile = './NG/data/100009d.area.mat';
0052 % >> parm.bayesfile = './NG/result/result3_col.bayes.mat';
0053 % >> parm.trial_average = OFF;
0054 % >> parm.area_key = 'fMTl';
0055 % >> parm.currfile = './result/result3_col_fMTl_1.curr.mat';
0056 % >> vb_job_current(parm);
0057 %
0058 % 2005-03-31 Taku Yoshioka
0059 % 2005/08/22 O. Yamashita ver.30b
0060 % 2005/08/24 O. Yamashita Modified
0061 % 2006/03/24 M. Sato Modified
0062 %   Eliminate zero variance point in current reconstruction
0063 % 2006/04/06 D. Kawawaki modified
0064 %   'project root' problem was solved.
0065 % 2006/07/19 O. Yamashita Modified
0066 % 2006/09/01 M. Sato
0067 % 2009-04-02 Taku Yoshioka
0068 %  Parameter name changed within this code for readability
0069 %  (just replacing 'resultfile' to bayesfile)
0070 %
0071 % Copyright (C) 2011, ATR All Rights Reserved.
0072 % License : New BSD License(see VBMEG_LICENSE.txt)
0073 
0074 %check input arguments
0075 if length(varargin) == 1
0076   proj_root = [];
0077   parm = varargin{1};
0078 elseif length(varargin) == 2
0079   proj_root = varargin{1};
0080   parm = varargin{2};
0081 else
0082   error('Error: invalid usage of job_current.');
0083 end
0084 
0085 proj_root = vb_rm_trailing_slash(proj_root);
0086 
0087 %set absolute path
0088 if ~isempty(proj_root)
0089   bayesfile = [proj_root filesep parm.bayesfile]; % curr. var. file
0090   currfile  = [proj_root filesep parm.currfile];   % current file
0091   if isfield(parm, 'areafile')
0092       areafile   = [proj_root filesep parm.areafile];   % vb_get_area
0093   end
0094 else
0095   bayesfile = parm.bayesfile;
0096   currfile  = parm.currfile;
0097   if isfield(parm, 'areafile')
0098       areafile   = parm.areafile;
0099   end
0100 end
0101 
0102 % set paramater
0103 if ~isempty(parm.areafile) ...
0104   & isfield(parm, 'area_key') & ~isempty(parm.area_key),
0105     Area = vb_get_area(areafile,parm.area_key);
0106     ix_area = Area.Iextract;
0107 else
0108     ix_area = [];
0109 end
0110 
0111 if isfield(parm,'trial_average')
0112     trial_average = parm.trial_average;
0113 else
0114     trial_average = ON;
0115 end
0116 if isfield(parm,'tsubsmpl')
0117     tsubsmpl = parm.tsubsmpl;
0118 else
0119     tsubsmpl = [];
0120 end
0121 if isfield(parm,'overlap_mode')
0122     overlap_mode = parm.overlap_mode;
0123 else
0124     overlap_mode = 0;
0125 end
0126 if ~isfield(parm,'flag')
0127     parm.flag = 0;
0128 end
0129 
0130 fprintf('Start current estimation\n')
0131 
0132 % Current estimation
0133 %[Jact, ix_act, Jbck, ix_bck, Varact] ...
0134 
0135 [Zact ,ix_act, Zbck, ix_bck, Varact, Jinfo] ...
0136    = vbmeg_current_reconstruct_z(proj_root, parm.bayesfile,...
0137               ix_area, trial_average, tsubsmpl, overlap_mode);
0138 
0139 %%%%%% load result file
0140 load(bayesfile, 'bayes_parm','vb_parm');
0141 
0142 if ~isempty(proj_root)
0143     megfile   = [proj_root filesep bayes_parm.megfile{1}];
0144 else
0145     megfile   = bayes_parm.megfile{1};
0146 end
0147 
0148 % Time window
0149 if isempty(tsubsmpl)
0150     Jinfo.Tstart  = bayes_parm.twin_meg(1);
0151     Jinfo.Tend    = bayes_parm.twin_meg(2);
0152     Jinfo.Tsample = Jinfo.Tstart:Jinfo.Tend;
0153 else
0154     Jinfo.Tstart  = tsubsmpl(1) + bayes_parm.twin_meg(1) - 1;
0155     Jinfo.Tend    = tsubsmpl(end) + bayes_parm.twin_meg(1) - 1;
0156     Jinfo.Tsample = tsubsmpl + bayes_parm.twin_meg(1) - 1;
0157 end
0158 
0159 % MEG information
0160 MEGinfo = vb_load_meg_info(megfile);
0161 
0162 % Save result
0163 fprintf(' --- Save estimated current: %s\n',currfile)
0164 vb_fsave(currfile,'Zact','Zbck','Jinfo','Varact', ...
0165                 'MEGinfo','bayes_parm','vb_parm');
0166 
0167 %vb_fsave(currfile,'Jact','Jbck','ix_act','ix_bck','Varact','MEGinfo', ...
0168 %    'Tsample','Tstart','Tend','Lact','Lbck','bayes_parm','vb_parm');
0169 
0170 % project_file save
0171 proj_file = get_project_filename;
0172 if isempty(proj_file)
0173     return;
0174 end
0175 
0176 project_file_mgr('load', proj_file);
0177 project_file_mgr('add', 'current_parm', parm);
0178

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005