0001 function [Jinfo] = vb_load_current_info(curr_file)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
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
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
0189
0190 function Tms = time_msec( t, para )
0191
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);