Home > functions > job > vb_job_current_z_tr.m

vb_job_current_z_tr

PURPOSE ^

This script calculates estimated current time courses for each trial

SYNOPSIS ^

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

DESCRIPTION ^

 This script calculates estimated current time courses for each trial

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

 --- Input parameters
 - parm.resultfile : Current variance file (.bayes.mat)
 - parm.currfile   : Average current is saved.
                     Infomation of current file are also saved.
                     current of each trials are saved into 'jactdir' directory
   .curr.mat file 
 - parm.jactdir : output directory of current files for each trial
                  relative path from proj_root
                  do not include '/' or '\' in the end of string
                  If 'jactdir' is not given,  jactdir = 'temp'
 ---- Optional  (default)
 - parm.areafile ([])  --> focal window
   .area.mat file.
 - parm.area_key ([])
   ID of interested area.
 - 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)

 - Jact
 - Jbck
 - ix_act
 - ix_bck
 - Lact
 - Lbck
 - Varact
 - bayes_parm
 - vb_parm

 * Example

 >> proj_root    = '.'
 >> 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';
 >> parm.jactdir  = 'temp';
 >> vb_job_current_tr(proj_root,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_tr(varargin)
0002 % This script calculates estimated current time courses for each trial
0003 %
0004 % ---
0005 % USAGE:
0006 %  function vb_job_current_tr(proj_root,parm)
0007 % or
0008 %  function vb_job_current_tr(parm)
0009 %
0010 % --- Input parameters
0011 % - parm.resultfile : Current variance file (.bayes.mat)
0012 % - parm.currfile   : Average current is saved.
0013 %                     Infomation of current file are also saved.
0014 %                     current of each trials are saved into 'jactdir' directory
0015 %   .curr.mat file
0016 % - parm.jactdir : output directory of current files for each trial
0017 %                  relative path from proj_root
0018 %                  do not include '/' or '\' in the end of string
0019 %                  If 'jactdir' is not given,  jactdir = 'temp'
0020 % ---- Optional  (default)
0021 % - parm.areafile ([])  --> focal window
0022 %   .area.mat file.
0023 % - parm.area_key ([])
0024 %   ID of interested area.
0025 % - parm.tsubsmpl ([]) --> whole time points
0026 %   Time points where currents are calculated. For example,
0027 %   if tsubsmpl = [1:5:100], currents are calculated at only every 5 sample
0028 %   point.
0029 % - parm.overlap_mode
0030 %   = 0 : current is averaged over overlapped time window
0031 %   = 1 : current is not averaged for overlapped window
0032 %         current time series of each time windows
0033 %         are concatenated sequentially for spectral analysis
0034 %
0035 % * Parameters saved in output file (.curr.mat)
0036 %
0037 % - Jact
0038 % - Jbck
0039 % - ix_act
0040 % - ix_bck
0041 % - Lact
0042 % - Lbck
0043 % - Varact
0044 % - bayes_parm
0045 % - vb_parm
0046 %
0047 % * Example
0048 %
0049 % >> proj_root    = '.'
0050 % >> parm.areafile = 'NG/data/100009d.area.mat';
0051 % >> parm.bayesfile = 'NG/result/result3_col.bayes.mat';
0052 % >> parm.trial_average = OFF;
0053 % >> parm.area_key = 'fMTl';
0054 % >> parm.currfile = 'result/result3_col_fMTl_1.curr.mat';
0055 % >> parm.jactdir  = 'temp';
0056 % >> vb_job_current_tr(proj_root,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_tr.');
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 isfield(parm,'trial_average') & parm.trial_average == ON;
0104     error('vb_job_current_tr should be used for trial_average = OFF')
0105 end
0106 if ~isempty(parm.areafile) ...
0107   & isfield(parm, 'area_key') & ~isempty(parm.area_key),
0108     Area = vb_get_area(areafile,parm.area_key);
0109     ix_area = Area.Iextract;
0110 else
0111     ix_area = [];
0112 end
0113 
0114 if isfield(parm,'tsubsmpl')
0115     tsubsmpl = parm.tsubsmpl;
0116 else
0117     tsubsmpl = [];
0118 end
0119 if isfield(parm,'overlap_mode')
0120     overlap_mode = parm.overlap_mode;
0121 else
0122     overlap_mode = 0;
0123 end
0124 if isfield(parm,'jactdir'), 
0125     jactdir = parm.jactdir; 
0126 else
0127     jactdir = 'temp'; 
0128 end;
0129 
0130 % Current estimation
0131 %[Jact ,ix_act, Jbck, ix_bck, Varact, JactInfo] = ...
0132 
0133 [Zact ,ix_act, Zbck, ix_bck, Varact, Jinfo] = ...
0134     vbmeg_current_reconstruct_z_tr(proj_root, parm.bayesfile, ...
0135                   ix_area, tsubsmpl, jactdir, overlap_mode);
0136 
0137 %%%%%% load result file
0138 load(bayesfile, 'bayes_parm','vb_parm');
0139 
0140 if ~isempty(proj_root)
0141     megfile   = [proj_root filesep bayes_parm.megfile{1}];
0142 else
0143     megfile   = bayes_parm.megfile{1};
0144 end
0145 
0146 % Time window
0147 if isempty(tsubsmpl)
0148     Jinfo.Tstart  = bayes_parm.twin_meg(1);
0149     Jinfo.Tend    = bayes_parm.twin_meg(2);
0150     Jinfo.Tsample = Jinfo.Tstart:Jinfo.Tend;
0151 else
0152     Jinfo.Tstart  = tsubsmpl(1) + bayes_parm.twin_meg(1) - 1;
0153     Jinfo.Tend    = tsubsmpl(end) + bayes_parm.twin_meg(1) - 1;
0154     Jinfo.Tsample = tsubsmpl + bayes_parm.twin_meg(1) - 1;
0155 end
0156 
0157 % MEG information
0158 MEGinfo = vb_load_meg_info(megfile);
0159 
0160 % Save result
0161 fprintf(' --- Save estimated current: %s\n',currfile)
0162 vb_fsave(currfile,'Zact','Zbck','Varact','MEGinfo', ...
0163            'bayes_parm','vb_parm','Jinfo');
0164 
0165 % project_file save
0166 proj_file = get_project_filename;
0167 if isempty(proj_file)
0168     return;
0169 end
0170 
0171 project_file_mgr('load', proj_file);
0172 project_file_mgr('add', 'current_parm', parm);

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