0001 function job_plot_cmap_update_timecourse(inst_id)
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 global vbmeg_inst;
0029 if isempty(vbmeg_inst.plotcmap{inst_id}.V), return; end
0030 const = vb_define_verbose;
0031 VERBOSE_LEVEL_DEBUG = const.VERBOSE_LEVEL_DEBUG;
0032
0033
0034
0035
0036
0037 h_fig = vbmeg_inst.plotcmap{inst_id}.h_fig;
0038 h_time = vbmeg_inst.plotcmap{inst_id}.h_time;
0039 h_cbar_tf = vbmeg_inst.plotcmap{inst_id}.h_cbar_tf;
0040 ix_trial = vbmeg_inst.plotcmap{inst_id}.ix_trial;
0041 Jinfo = vbmeg_inst.plotcmap{inst_id}.Jinfo;
0042 TFinfo = vbmeg_inst.plotcmap{inst_id}.TFinfo;
0043 TFmax = vbmeg_inst.plotcmap{inst_id}.TFmax;
0044 TFmin = vbmeg_inst.plotcmap{inst_id}.TFmin;
0045 toi = vbmeg_inst.plotcmap{inst_id}.toi;
0046 foi = vbmeg_inst.plotcmap{inst_id}.foi;
0047 ix_peak = vbmeg_inst.plotcmap{inst_id}.ix_peak;
0048 J_hold = vbmeg_inst.plotcmap{inst_id}.J_hold;
0049 cb4 = vbmeg_inst.plotcmap{inst_id}.cb4;
0050 ed10 = vbmeg_inst.plotcmap{inst_id}.ed10;
0051
0052
0053 set(h_fig,'Pointer','watch');
0054 drawnow;
0055
0056 if ~isempty(Jinfo),
0057 Tmsec = Jinfo.Tmsec;
0058 elseif ~isempty(TFinfo),
0059 Tmsec = TFinfo.Tmsec;
0060 else
0061 return;
0062 end
0063
0064
0065 I = size(vbmeg_inst.plotcmap{inst_id}.V,1);
0066 ix_peak = ceil(ix_peak);
0067 if ix_peak<1, ix_peak = 1; end
0068 if ix_peak>I, ix_peak = I; end
0069 vbmeg_inst.plotcmap{inst_id}.ix_peak = ix_peak;
0070
0071
0072 if toi(1)<min(Tmsec), toi(1)=min(Tmsec); end
0073 if toi(1)>max(Tmsec), toi(1)=max(Tmsec); end
0074 if toi(2)<min(Tmsec), toi(2)=min(Tmsec); end
0075 if toi(2)>max(Tmsec), toi(2)=max(Tmsec); end
0076 if toi(1)>toi(2), toi=toi(2:-1:1); end
0077 vbmeg_inst.plotcmap{inst_id}.toi = toi;
0078
0079
0080 if ~isempty(TFinfo),
0081 if foi(1)<min(TFinfo.freq), foi(1)=min(TFinfo.freq); end
0082 if foi(1)>max(TFinfo.freq), foi(1)=max(TFinfo.freq); end
0083 if foi(2)<min(TFinfo.freq), foi(2)=min(TFinfo.freq); end
0084 if foi(2)>max(TFinfo.freq), foi(2)=max(TFinfo.freq); end
0085 if foi(1)>foi(2), foi=foi(2:-1:1); end
0086 vbmeg_inst.plotcmap{inst_id}.foi = foi;
0087 end
0088
0089 ixx = ix_peak;
0090 W = vbmeg_inst.plotcmap{inst_id}.W(ixx,:);
0091
0092
0093 if ~isempty(Jinfo),
0094 if ixx==0,
0095 J = zeros(length(Tmsec),1);
0096 else
0097 ixx2 = find(sum(abs(W),1)>0);
0098 W = W(:,ixx2);
0099 Jtmp = zeros(I,length(Jinfo.Tmsec));
0100
0101 if size(vbmeg_inst.plotcmap{inst_id}.Jact, 3) > 1
0102 ix_trial = vbmeg_inst.plotcmap{inst_id}.ix_trial;
0103 Jtmp(Jinfo.ix_act_ex,:) ...
0104 = vbmeg_inst.plotcmap{inst_id}.Jact(:,:,ix_trial);
0105 else
0106 Jtmp(Jinfo.ix_act_ex,:) ...
0107 = vbmeg_inst.plotcmap{inst_id}.Jact(:,:);
0108 end
0109
0110 if length(W(:))>0,
0111 J = W*Jtmp(ixx2,:)/sum(W(:));
0112 end
0113
0114
0115 if get(cb4,'Value')==get(cb4,'Max'),
0116 J_hold = [J_hold; J];
0117 else
0118 J_hold = J;
0119 end
0120 vbmeg_inst.plotcmap{inst_id}.J_hold = J_hold;
0121 end
0122
0123
0124 if Jinfo.patch_norm==ON,
0125 ylabel_str = 'Dipole moment density [pAm/mm^2]';
0126 else
0127 ylabel_str = 'Dipole moment [nA\cdot m]';
0128 end
0129 elseif ~isempty(TFinfo),
0130 if ixx==0,
0131 data = zeros(length(TFinfo.freq),length(Tmsec));
0132 else
0133 W = sparse(W*TFinfo.Wact);
0134 ixx = find(W>0);
0135
0136 c = 0.0;
0137 data = zeros(length(TFinfo.freq),length(TFinfo.Tmsec));
0138 for i=1:length(ixx)
0139 data ...
0140 = data+W(ixx(i))*vbmeg_inst.plotcmap{inst_id}.data(:,:,ixx(i));
0141 c = c+W(ixx(i));
0142 end
0143 data = data./c;
0144
0145
0146 ylabel_str = 'Frequency [Hz]';
0147 end
0148 else
0149 return;
0150 end
0151
0152
0153
0154
0155
0156 set(0,'CurrentFigure',h_fig);
0157 set(h_fig,'CurrentAxes',h_time);
0158 if ~isempty(Jinfo),
0159 plot(repmat(Tmsec,[size(J_hold,1) 1])',J_hold');
0160 xlim([min(Tmsec) max(Tmsec)]);
0161 set(h_time,'YDir','normal');
0162
0163
0164 plotcmap_str = ['vbmeg_inst.plotcmap{' num2str(inst_id) '}'];
0165 command = ['global vbmeg_inst; ' ...
0166 plotcmap_str '.toi = xrange;' ...
0167 'inst_id = job_plot_cmap_get_inst_id(gcf);' ...
0168 'job_plot_cmap_update_timecourse(inst_id);' ...
0169 'job_plot_cmap_update_spatialpattern(inst_id);'];
0170 select_xrange('init',gca,'ButtonUpFcn',command,...
0171 'InitialRange',toi);
0172 else
0173 if strcmp(TFinfo.freq_scale,'log'),
0174 h_img = imagesc(TFinfo.Tmsec,log2(TFinfo.freq),data);
0175 ylim(log2([min(TFinfo.freq) max(TFinfo.freq)]));
0176 yy = [2 5 10 20 50 100 200 500 1000 2000 5000 10000];
0177 [tmp,ix_yy1] = find(yy<=max(TFinfo.freq));
0178 [tmp,ix_yy2] = find(yy>=min(TFinfo.freq));
0179 yy = sort(yy(intersect(ix_yy1,ix_yy2)));
0180 set(h_time,'YDir','normal','YTick',log2(yy),'YTickLabel',yy);
0181 else
0182 h_img = imagesc(TFinfo.Tmsec,TFinfo.freq,data);
0183 ylim([min(TFinfo.freq) max(TFinfo.freq)]);
0184 set(h_time,'YDir','normal');
0185
0186
0187
0188
0189
0190 end
0191
0192
0193 if vb_get_verbose==VERBOSE_LEVEL_DEBUG,
0194 fprintf('job_plot_cmap_update_timecourse\n');
0195 fprintf('max(max(data))=%e\n',max(max(data)));
0196 fprintf('TFmax=%e\n',TFmax);
0197 end
0198
0199
0200 tfmax = str2num(get(ed10,'String'));
0201
0202
0203
0204
0205
0206
0207
0208 reset(h_cbar_tf);
0209 if TFmin<0,
0210 caxis(h_time,[-1*tfmax tfmax]);
0211
0212 if datenum(version('-date'))<=733071,
0213 reset(vbmeg_inst.plotcmap{inst_id}.h_cbar_tf);
0214 colorbar(vbmeg_inst.plotcmap{inst_id}.h_cbar_tf);
0215 else
0216 pos = get(vbmeg_inst.plotcmap{inst_id}.h_cbar_tf,'Position');
0217 delete(vbmeg_inst.plotcmap{inst_id}.h_cbar_tf);
0218 h_cbar_tf = colorbar('Position',pos);
0219 vbmeg_inst.plotcmap{inst_id}.h_cbar_tf = h_cbar_tf;
0220 end
0221
0222 set(h_cbar_tf,'Ylim',[-1*tfmax tfmax],'XTick',[]);
0223 else
0224 caxis(h_time,[0 tfmax]);
0225
0226 if datenum(version('-date'))<=733071,
0227 reset(vbmeg_inst.plotcmap{inst_id}.h_cbar_tf);
0228 colorbar(vbmeg_inst.plotcmap{inst_id}.h_cbar_tf);
0229 else
0230 pos = get(vbmeg_inst.plotcmap{inst_id}.h_cbar_tf,'Position');
0231 delete(vbmeg_inst.plotcmap{inst_id}.h_cbar_tf);
0232 h_cbar_tf = colorbar('Position',pos);
0233 vbmeg_inst.plotcmap{inst_id}.h_cbar_tf = h_cbar_tf;
0234 end
0235
0236 set(h_cbar_tf,'Ylim',[0 tfmax],'XTick',[]);
0237 end
0238
0239
0240 plotcmap_str = ['vbmeg_inst.plotcmap{' num2str(inst_id) '}'];
0241 if strcmp(TFinfo.freq_scale,'log'),
0242 command = ['global vbmeg_inst; ' ...
0243 plotcmap_str '.toi = [xyrange(1) xyrange(3)];' ...
0244 plotcmap_str '.foi = [2.^xyrange(2) 2.^xyrange(4)];' ...
0245 'inst_id = job_plot_cmap_get_inst_id(gcf);' ...
0246 'job_plot_cmap_update_timecourse(inst_id);' ...
0247 'job_plot_cmap_update_spatialpattern(inst_id);'];
0248 vb_select_xyrange('init',h_img,'ButtonUpFcn',command,...
0249 'InitialRange',[toi(1) log2(foi(1)) toi(2) ...
0250 log2(foi(2))]);
0251 else
0252 command = ['global vbmeg_inst; ' ...
0253 plotcmap_str '.toi = [xyrange(1) xyrange(3)];' ...
0254 plotcmap_str '.foi = [xyrange(2) xyrange(4)];' ...
0255 'inst_id = job_plot_cmap_get_inst_id(gcf);' ...
0256 'job_plot_cmap_update_timecourse(inst_id);' ...
0257 'job_plot_cmap_update_spatialpattern(inst_id);'];
0258 vb_select_xyrange('init',h_img,'ButtonUpFcn',command,...
0259 'InitialRange',[toi(1) foi(1) toi(2) foi(2)]);
0260 end
0261
0262 end
0263
0264 xlabel('Time [ms]');
0265 ylabel(ylabel_str);
0266
0267
0268
0269
0270
0271
0272
0273 set(vbmeg_inst.plotcmap{inst_id}.ed2,'String',num2str(toi(1)));
0274 set(vbmeg_inst.plotcmap{inst_id}.ed3,'String',num2str(toi(2)));
0275 if ~isempty(TFinfo),
0276 set(vbmeg_inst.plotcmap{inst_id}.ed8,'String',num2str(foi(1)));
0277 set(vbmeg_inst.plotcmap{inst_id}.ed9,'String',num2str(foi(2)));
0278 else
0279 set(vbmeg_inst.plotcmap{inst_id}.ed8,'String','');
0280 set(vbmeg_inst.plotcmap{inst_id}.ed9,'String','');
0281 end
0282
0283 set(h_fig,'Pointer','arrow');
0284
0285 return;