0001 function job_plot_cmap_spatial_peak(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
0025
0026 toi = vbmeg_inst.plotcmap{inst_id}.toi;
0027 foi = vbmeg_inst.plotcmap{inst_id}.foi;
0028 Jinfo = vbmeg_inst.plotcmap{inst_id}.Jinfo;
0029 TFinfo = vbmeg_inst.plotcmap{inst_id}.TFinfo;
0030 ix_trial = vbmeg_inst.plotcmap{inst_id}.ix_trial;
0031 h_fig = vbmeg_inst.plotcmap{inst_id}.h_fig;
0032 ix_peak = vbmeg_inst.plotcmap{inst_id}.ix_peak;
0033 nextDD = vbmeg_inst.plotcmap{inst_id}.nextDD;
0034 nextIX = vbmeg_inst.plotcmap{inst_id}.nextIX;
0035 ed5 = vbmeg_inst.plotcmap{inst_id}.ed5;
0036 area_file = vbmeg_inst.plotcmap{inst_id}.area_file;
0037 lb3 = vbmeg_inst.plotcmap{inst_id}.lb3;
0038
0039 set(h_fig,'Pointer','watch');
0040 drawnow;
0041
0042 if isempty(nextDD),
0043 vb_disp('No cortical surface model is loaded.');
0044 return;
0045 else
0046 I = length(nextDD);
0047 end
0048
0049
0050 R = str2num(get(ed5,'String'))*1e-3;
0051 if R<0, R=0.1; set(ed5,'String','100'); end
0052 ixx = find(nextDD{ix_peak}<=R);
0053 ixx = nextIX{ix_peak}(ixx);
0054
0055
0056 if isempty(TFinfo),
0057 if isempty(Jinfo),
0058 return;
0059 else
0060 J0 = job_plot_cmap_get_spatialpattern(inst_id);
0061 J0 = abs(J0(ixx));
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077 end
0078 else
0079
0080 tt(1) = ceil(toi(1)*TFinfo.SampleFreq/1000+TFinfo.Pretrigger);
0081 tt(2) = ceil(toi(2)*TFinfo.SampleFreq/1000+TFinfo.Pretrigger);
0082 tt = tt(1):tt(2);
0083
0084
0085 [tmp,ix(1)] = min(abs(TFinfo.freq-foi(1)));
0086 [tmp,ix(2)] = min(abs(TFinfo.freq-foi(2)));
0087 if ix(1)>ix(2),
0088 ff = ix(2):ix(1);
0089 else
0090 ff = ix(1):ix(2);
0091 end
0092
0093
0094 [ixx,ixxx] = intersect(TFinfo.ix_act,ixx);
0095 if isempty(ixx),
0096 vb_disp(['No vertex have time-frequency data within the search ' ...
0097 'range. You should set larger search radius.']);
0098 return;
0099 end
0100
0101
0102 tmp = sum(sum(abs(vbmeg_inst.plotcmap{inst_id}.data(tt,ff,ixxx)),1),2);
0103 J0 = zeros(I,1);
0104 J0(ixx) = tmp;
0105 end
0106
0107 [tmp,ixp] = max(J0);
0108 vbmeg_inst.plotcmap{inst_id}.ix_peak = ixx(ixp);
0109
0110
0111
0112
0113
0114 ixp = ixx(ixp);
0115
0116 if ~isempty(area_file),
0117 area_key = vb_get_keyset_area(area_file);
0118 area_key_list = [];
0119 n = 1;
0120
0121 for i=1:length(area_key)
0122 tmp = vb_get_area(area_file,area_key{i});
0123 if ~isempty(find(tmp.Iextract==ixp)),
0124 area_key_list{n} = tmp.key;
0125 n = n+1;
0126 end
0127
0128 set(lb3,'String',area_key_list);
0129 end
0130 end
0131
0132
0133
0134
0135
0136 job_plot_cmap_update_timecourse(inst_id);
0137 job_plot_cmap_update_spatialpattern(inst_id);
0138
0139 set(h_fig,'Pointer','arrow');
0140
0141 return;