Home > vbmeg > functions > common > loadfunc > subdirectory > vb_load_current_info.m

vb_load_current_info

PURPOSE ^

Load information of cortical current file.

SYNOPSIS ^

function [Jinfo] = vb_load_current_info(curr_file)

DESCRIPTION ^

 Load information of cortical current file. 

 [syntax]
 Jinfo = vb_load_current_z(curr_file)

 [input]
 curr_file: <<string>> Cortical current file (.curr.mat). 

 [output]
 Jinfo: <<struct>> Information of cortical current.
 --- 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). 
 ---

 [history]
 2010-12-06 taku-y
  [enhancement] Cortical current file version 0.9 or later supported. 
 2011-01-27 taku-y
  [debug] Jinfo.patch_norm set. 
 2011-08-23 taku-y
  [debug] If Jinfo.patch_norm does not exist, bayes_parm.patch_norm is
  used. 
 2012-02-03 taku-y
  [minor] Jinfo.Tix was added.

 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 [Jinfo] = vb_load_current_info(curr_file)
0002 % Load information of cortical current file.
0003 %
0004 % [syntax]
0005 % Jinfo = vb_load_current_z(curr_file)
0006 %
0007 % [input]
0008 % curr_file: <<string>> Cortical current file (.curr.mat).
0009 %
0010 % [output]
0011 % Jinfo: <<struct>> Information of cortical current.
0012 % --- fields of Jinfo
0013 %  version   : <<string>> Version of cortical current file.
0014 %  curr_type : <<string>> 'Z-current'. It can be 'J-current' for VBMEG
0015 %              version 0.8 or older.
0016 %  Wact      : <<float matrix>> Smoothing Gaussian filter, mapping from
0017 %              Z-current to J-current.
0018 %  ix_act    : <<int vector>>: Vertex indices of Z-current.
0019 %  ix_act_ex : <<int vector>>: Vertex indices of J-current.
0020 %  Lact      : <<int>> Number of current direction at one vertex.
0021 %  Tsample   : <<int vector>> Time sample indices of the original MEG
0022 %              data. length(Tsample) == size(Zact,2) == size(Jact,2).
0023 %  Tmsec     : <<float vector>> Time in msec.
0024 %  SampleFreq: <<float>> Sample frequency of cortical current, not
0025 %              original M/EEG signal [Hz].
0026 %  Pretrigger: <<int>> Time points of the length of the pretrigger
0027 %              period of cortical current data. It is neither actual time
0028 %              nor time points of the original M/EEG signal.
0029 %  Ntrial    : <<int>> Number of trials of estimated current.
0030 %  patch_norm: <<bool>> Cortical current is patch size normalized
0031 %              (Am/m^2) or not (Am).
0032 % ---
0033 %
0034 % [history]
0035 % 2010-12-06 taku-y
0036 %  [enhancement] Cortical current file version 0.9 or later supported.
0037 % 2011-01-27 taku-y
0038 %  [debug] Jinfo.patch_norm set.
0039 % 2011-08-23 taku-y
0040 %  [debug] If Jinfo.patch_norm does not exist, bayes_parm.patch_norm is
0041 %  used.
0042 % 2012-02-03 taku-y
0043 %  [minor] Jinfo.Tix was added.
0044 %
0045 % Copyright (C) 2011, ATR All Rights Reserved.
0046 % License : New BSD License(see VBMEG_LICENSE.txt)
0047 
0048 load(curr_file);
0049 
0050 if isfield(Jinfo,'version'), 
0051   v = Jinfo.version;
0052 else
0053   v = '0.7';
0054 end
0055 
0056 if vb_version_cmp(v,'>','1.0-0.a.0'), 
0057   vb_struct2vars(Jinfo,{'version','curr_type','ix_act','ix_act_ex', ...
0058                       'Wact','Lact','Tsample','Tmsec','SampleFreq', ...
0059                       'Pretrigger','Ntrial','patch_norm','Tix'});
0060   clear Jinfo;
0061   Jinfo.version    = v;
0062   Jinfo.curr_type  = curr_type;
0063   Jinfo.ix_act     = ix_act;
0064   Jinfo.ix_act_ex  = ix_act_ex;
0065   Jinfo.Wact       = Wact;
0066   Jinfo.Lact       = Lact;
0067   Jinfo.Tsample    = Tsample;
0068   Jinfo.Tmsec      = Tmsec;
0069   Jinfo.SampleFreq = SampleFreq;
0070   Jinfo.Pretrigger = Pretrigger;
0071   Jinfo.Ntrial     = Ntrial;
0072   Jinfo.patch_norm = patch_norm;
0073   Jinfo.Tix        = Tix;
0074   
0075   if isempty(patch_norm) & isfield(bayes_parm,'patch_norm'), 
0076     Jinfo.patch_norm = bayes_parm.patch_norm;
0077   end
0078 elseif vb_version_cmp(v,'>=','0.9-0.a.0'), 
0079   vb_struct2vars(Jinfo,{'version','curr_type','ix_act','ix_act_ex', ...
0080                       'Wact','Lact','Tsample','Tmsec','SampleFreq', ...
0081                       'Pretrigger','Ntrial','patch_norm'});
0082   clear Jinfo;
0083   Jinfo.version    = v;
0084   Jinfo.curr_type  = curr_type;
0085   Jinfo.ix_act     = ix_act;
0086   Jinfo.ix_act_ex  = ix_act_ex;
0087   Jinfo.Wact       = Wact;
0088   Jinfo.Lact       = Lact;
0089   Jinfo.Tsample    = Tsample;
0090   Jinfo.Tmsec      = Tmsec;
0091   Jinfo.SampleFreq = SampleFreq;
0092   Jinfo.Pretrigger = Pretrigger;
0093   Jinfo.Ntrial     = Ntrial;
0094   Jinfo.patch_norm = patch_norm;
0095   
0096   if isempty(patch_norm) & isfield(bayes_parm,'patch_norm'), 
0097     Jinfo.patch_norm = bayes_parm.patch_norm;
0098   end
0099 else % otherwise
0100   if ~exist('bayes_parm','var'),
0101     bayes_parm = [];
0102   end;
0103 
0104   if ~exist('Jinfo','var')
0105     if exist('ix_act','var') 
0106       Jinfo.ix_act = ix_act;
0107     elseif exist('ix0','var') 
0108       Jinfo.ix_act = ix0;
0109     else
0110       Jinfo.ix_act = [];
0111     end;
0112     
0113     if exist('Lact','var')
0114       Jinfo.Lact = Lact;
0115     elseif exist('vb_parm','var')
0116       Jinfo.Lact = vb_parm.Norient;
0117     else
0118       Jinfo.Lact = 1;
0119     end;
0120     
0121     if exist('Tsample','var')
0122       Jinfo.Tsample = Tsample;
0123     else
0124       if ~isempty(Jact)
0125         T = size(Jact,2);
0126       elseif ~isempty(Jbck)
0127         T = size(Jbck,2);
0128       else
0129         error(['There is no Jact in ' curr_file])
0130       end;
0131       
0132       if ~exist('Tstart','var') & exist('bayes_parm','var')
0133         Tstart  = bayes_parm.twin_meg(1);
0134       else
0135         Tstart = 1; 
0136       end
0137       if ~exist('Tend','var') & exist('bayes_parm','var')
0138         Tend = bayes_parm.twin_meg(2);
0139       else
0140         Tend = Tstart + T - 1; 
0141       end;
0142       
0143       step = (Tend - Tstart + 1)/T;
0144       Jinfo.Tsample = Tstart:step:Tend;
0145     end;
0146   end;
0147 
0148   if exist('JactInfo','var')
0149     Jinfo.jactdir  = JactInfo.jactdir;
0150     Jinfo.Ntrial   = JactInfo.Ntrial  ;
0151     Jinfo.Nsession = JactInfo.Nsession;
0152   end;
0153 
0154   if ~isfield(Jinfo,'SampleFreq')
0155     if exist('MEGinfo','var')
0156       Jinfo.SampleFreq = MEGinfo.SampleFreq;
0157     else
0158       MEGinfo = [];
0159       Jinfo.SampleFreq = [];
0160     end;
0161   end;
0162   
0163   if ~isfield(Jinfo,'Pretrigger')
0164     if exist('MEGinfo','var')
0165       Jinfo.Pretrigger = vb_meginfo_get_pre_trigger(MEGinfo);
0166     else
0167       MEGinfo = [];
0168       Jinfo.Pretrigger  = [];
0169     end;
0170   end;
0171   
0172   Jinfo.Tmsec = time_msec( Jinfo.Tsample, Jinfo);
0173 
0174   if exist('Zact','var') 
0175     Jinfo.curr_type = 'Z-current';
0176   elseif exist('Jact','var') 
0177     Jinfo.curr_type = 'J-current';
0178   elseif exist('J','var')
0179     Jinfo.curr_type = 'J-current';
0180   else
0181     Jinfo.curr_type = '';
0182   end;
0183 end;
0184 
0185 return;
0186 
0187 %
0188 % --- Inner function
0189 %
0190 function    Tms = time_msec( t, para )
0191 %   Time (ms)  : Tms  = (t - Pretrigger)*(1000/SampleFreq)
0192 
0193 if isempty(para.Pretrigger), para.Pretrigger = 0; end;
0194 if isempty(para.SampleFreq), para.SampleFreq = 1000; end;
0195 
0196 Tms = (t - para.Pretrigger)*(1000/para.SampleFreq);

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