0001 function J = job_plot_cmap_get_spatialpattern(inst_id)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 global vbmeg_inst;
0024 const = vb_define_verbose;
0025 VERBOSE_LEVEL_DEBUG = const.VERBOSE_LEVEL_DEBUG;
0026
0027
0028 Jinfo = vbmeg_inst.plotcmap{inst_id}.Jinfo;
0029 TFinfo = vbmeg_inst.plotcmap{inst_id}.TFinfo;
0030 toi = vbmeg_inst.plotcmap{inst_id}.toi;
0031 foi = vbmeg_inst.plotcmap{inst_id}.foi;
0032 cb7 = vbmeg_inst.plotcmap{inst_id}.cb7;
0033 xxP = vbmeg_inst.plotcmap{inst_id}.xxP;
0034
0035
0036
0037
0038 vb_disp('job_plot_cmap_get_spatialpattern','DEBUG');
0039 vb_disp(sprintf('size(toi) = %d, %d',size(toi)),'DEBUG');
0040 vb_disp(sprintf('size(foi) = %d, %d',size(foi)),'DEBUG');
0041
0042
0043 I = size(vbmeg_inst.plotcmap{inst_id}.V,1);
0044 J = zeros(I,1);
0045
0046 if ~isempty(xxP) && get(cb7,'Value'),
0047 J = xxP;
0048 elseif ~isempty(Jinfo),
0049 if vb_version_cmp(Jinfo.version,'>=','0.9-0.a.0'),
0050 [tmp,ix(1)] = min(abs(Jinfo.Tmsec-toi(1)));
0051 [tmp,ix(2)] = min(abs(Jinfo.Tmsec-toi(2)));
0052 if ix(1)>ix(2),
0053 tt = ix(2):ix(1);
0054 else
0055 tt = ix(1):ix(2);
0056 end
0057 else
0058 Tstart = vbmeg_inst.plotcmap{inst_id}.Tstart;
0059 tt = ceil((toi(1):toi(2))*Jinfo.SampleFreq/1000-Tstart ...
0060 +Jinfo.Pretrigger)+1;
0061 end
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073 ix_trial = vbmeg_inst.plotcmap{inst_id}.ix_trial;
0074 if size(vbmeg_inst.plotcmap{inst_id}.Jact,3) > 1
0075 J(Jinfo.ix_act_ex,:) ...
0076 = mean(vbmeg_inst.plotcmap{inst_id}.Jact(:,tt,ix_trial),2);
0077 else
0078 J(Jinfo.ix_act_ex,:) ...
0079 = mean(vbmeg_inst.plotcmap{inst_id}.Jact(:,tt),2);
0080 end
0081 elseif ~isempty(TFinfo),
0082 [tmp,ix(1)] = min(abs(TFinfo.Tmsec-toi(1)));
0083 [tmp,ix(2)] = min(abs(TFinfo.Tmsec-toi(2)));
0084 if ix(1)>ix(2),
0085 tt = ix(2):ix(1);
0086 else
0087 tt = ix(1):ix(2);
0088 end
0089
0090
0091 [tmp,ix(1)] = min(abs(TFinfo.freq-foi(1)));
0092 [tmp,ix(2)] = min(abs(TFinfo.freq-foi(2)));
0093 if ix(1)>ix(2),
0094 ff = ix(2):ix(1);
0095 else
0096 ff = ix(1):ix(2);
0097 end
0098
0099
0100 vb_disp(sprintf('min and max of tt = %d, %d\n',min(tt),max(tt)), 'DEBUG');
0101 vb_disp(sprintf('min and max of ff = %d, %d\n',min(ff),max(ff)), 'DEBUG');
0102
0103
0104 tmp = sum(sum(vbmeg_inst.plotcmap{inst_id}.data(ff,tt,:),1),2);
0105 tmp = reshape(tmp,[length(tmp) 1])./(length(ff)*length(tt));
0106 J(TFinfo.ix_act_ex) = TFinfo.Wact*tmp;
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 else
0120 J = [];
0121 end
0122
0123 return;