0001 function job_plot_cmap_print_temporalpattern(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 global vbmeg_inst;
0027 if isempty(vbmeg_inst.plotcmap{inst_id}.V), return; end
0028
0029
0030
0031
0032
0033 ix_trial = vbmeg_inst.plotcmap{inst_id}.ix_trial;
0034 Jinfo = vbmeg_inst.plotcmap{inst_id}.Jinfo;
0035 TFinfo = vbmeg_inst.plotcmap{inst_id}.TFinfo;
0036 TFmax = vbmeg_inst.plotcmap{inst_id}.TFmax;
0037 TFmin = vbmeg_inst.plotcmap{inst_id}.TFmin;
0038 toi = vbmeg_inst.plotcmap{inst_id}.toi;
0039 foi = vbmeg_inst.plotcmap{inst_id}.foi;
0040 ix_peak = vbmeg_inst.plotcmap{inst_id}.ix_peak;
0041 J_hold = vbmeg_inst.plotcmap{inst_id}.J_hold;
0042 cb4 = vbmeg_inst.plotcmap{inst_id}.cb4;
0043
0044 if ~isempty(Jinfo),
0045 Tmsec = Jinfo.Tmsec;
0046 elseif ~isempty(TFinfo),
0047 Tmsec = TFinfo.Tmsec;
0048 else
0049 return;
0050 end
0051
0052
0053 I = size(vbmeg_inst.plotcmap{inst_id}.V,1);
0054 ix_peak = ceil(ix_peak);
0055 if ix_peak<1, ix_peak = 1; end;
0056 if ix_peak>I, ix_peak = I; end;
0057 vbmeg_inst.plotcmap{inst_id}.ix_peak = ix_peak;
0058
0059
0060 if toi(1)<min(Tmsec), toi(1)=min(Tmsec); end
0061 if toi(1)>max(Tmsec), toi(1)=max(Tmsec); end
0062 if toi(2)<min(Tmsec), toi(2)=min(Tmsec); end
0063 if toi(2)>max(Tmsec), toi(2)=max(Tmsec); end
0064 if toi(1)>toi(2), toi=toi(2:-1:1); end
0065 vbmeg_inst.plotcmap{inst_id}.toi = toi;
0066
0067
0068 if ~isempty(TFinfo),
0069 if foi(1)<min(TFinfo.freq), foi(1)=min(TFinfo.freq); end
0070 if foi(1)>max(TFinfo.freq), foi(1)=max(TFinfo.freq); end
0071 if foi(2)<min(TFinfo.freq), foi(2)=min(TFinfo.freq); end
0072 if foi(2)>max(TFinfo.freq), foi(2)=max(TFinfo.freq); end
0073 if foi(1)>foi(2), foi=foi(2:-1:1); end
0074 vbmeg_inst.plotcmap{inst_id}.foi = foi;
0075 end
0076
0077 ixx = ix_peak;
0078 W = vbmeg_inst.plotcmap{inst_id}.W(ixx,:);
0079
0080
0081 if ~isempty(Jinfo),
0082 if ixx==0,
0083 J = zeros(length(Tmsec),1);
0084 elseif isempty(J_hold),
0085 ixx2 = find(sum(abs(W),1)>0);
0086 W = W(:,ixx2);
0087 if length(W(:))>0,
0088 if size(vbmeg_inst.plotcmap{inst_id}.Jact,3) > 1
0089 J = W*vbmeg_inst.plotcmap{inst_id}.Jact(ixx2,:,ix_trial)/sum(W(:));
0090 else
0091 J = W*vbmeg_inst.plotcmap{inst_id}.Jact(ixx2,:)/sum(W(:));
0092 end
0093 end
0094
0095 J_hold = J;
0096 end
0097
0098
0099 if Jinfo.patch_norm==ON,
0100 ylabel_str = 'Dipole moment density [pAm/mm^2]';
0101 else
0102 ylabel_str = 'Dipole moment [nA\cdot m]';
0103 end
0104 elseif ~isempty(TFinfo),
0105 if ixx==0,
0106 data = zeros(length(TFinfo.freq),length(Tmsec));
0107 else
0108 W = sparse(W*TFinfo.Wact);
0109 ixx = find(W>0);
0110
0111 c = 0.0;
0112 data = zeros(length(TFinfo.freq),length(TFinfo.Tmsec));
0113 for i=1:length(ixx)
0114 data ...
0115 = data+W(ixx(i))*vbmeg_inst.plotcmap{inst_id}.data(:,:,ixx(i));
0116 c = c+W(ixx(i));
0117 end
0118 data = data./c;
0119
0120
0121 ylabel_str = 'Frequency [Hz]';
0122 end
0123 else
0124 return;
0125 end
0126
0127
0128
0129
0130
0131 h = figure;
0132 if ~isempty(Jinfo),
0133 plot(repmat(Tmsec,[size(J_hold,1) 1])',J_hold');
0134 xlim([min(Tmsec) max(Tmsec)]);
0135 yy = ylim;
0136 set(gca,'YDir','normal');
0137
0138
0139 title_str = ['Vertex ' num2str(ix_peak)];
0140 property_names = {'Title','ylim','Print option'};
0141 default_values = {title_str,num2str(yy),'-depsc'};
0142 description ...
0143 = {'Colorbar is attached (=1) or not (0).', ...
0144 '[min max] of y axis','Print option (such as ''-dpng'')'};
0145 values = vb_property_dlg(property_names,default_values,description);
0146
0147 if isempty(values),
0148 close;
0149 return;
0150 end
0151
0152 title_str = values{1};
0153 yy = str2num(values{2});
0154 opt_print = values{3};
0155
0156 set(gca,'YLim',yy);
0157 else
0158
0159 title_str = ['Vertex ' num2str(ix_peak)];
0160 property_names = {'Title','Colorbar','Time-frequency window','Max'};
0161 default_values = {title_str,'1','1',num2str(TFmax)};
0162 description ...
0163 = {'Colorbar is attached (=1) or not (0).', ...
0164 'Time-frequency window is shown (1) or not (0).' ...
0165 'Maximum value of the absolute value plotted.'};
0166 values = vb_property_dlg(property_names,default_values,description);
0167
0168 if isempty(values),
0169 close;
0170 return;
0171 end
0172
0173 title_str = values{1};
0174 iscbar = str2num(values{2});
0175 istfbox = str2num(values{3});
0176 TFmax = str2num(values{4});
0177
0178 if strcmp(TFinfo.freq_scale,'log'),
0179 h_img = imagesc(TFinfo.Tmsec,log2(TFinfo.freq),data);
0180 ylim(log2([min(TFinfo.freq) max(TFinfo.freq)]));
0181 yy = [2 5 10 20 50 100 200 500 1000 2000 5000 10000];
0182 [tmp,ix_yy1] = find(yy<=max(TFinfo.freq));
0183 [tmp,ix_yy2] = find(yy>=min(TFinfo.freq));
0184 yy = sort(yy(intersect(ix_yy1,ix_yy2)));
0185 set(gca,'YDir','normal','YTick',log2(yy),'YTickLabel',yy);
0186 else
0187 h_img = imagesc(TFinfo.Tmsec,TFinfo.freq,data);
0188 ylim([min(TFinfo.freq) max(TFinfo.freq)]);
0189 set(gca,'YDir','normal');
0190
0191
0192
0193
0194
0195 end
0196
0197
0198 if TFmin<0,
0199 caxis(gca,[-1*TFmax TFmax]);
0200 else
0201 caxis(gca,[0 TFmax]);
0202 end
0203
0204
0205 if istfbox,
0206
0207 xinf = toi(1);
0208 xsup = toi(2);
0209 if strcmp(TFinfo.freq_scale,'log'),
0210 yinf = log2(foi(1));
0211 ysup = log2(foi(2));
0212 else
0213 yinf = foi(1);
0214 ysup = foi(2);
0215 end
0216 patch( [ xinf, xsup, xsup, xinf ],...
0217 [ yinf, yinf, ysup, ysup ], ...
0218 'k','FaceColor','none','LineWidth',2.5);
0219 end
0220
0221
0222 if iscbar,
0223 h_cbar_tf = colorbar;
0224 if TFmin<0,
0225 set(h_cbar_tf,'Ylim',[-1*TFmax TFmax],'XTick',[]);
0226 else
0227 set(h_cbar_tf,'Ylim',[0 TFmax],'XTick',[]);
0228 end
0229 end
0230 end
0231
0232 xlabel('Time [ms]');
0233 ylabel(ylabel_str);
0234
0235 pos = get(gca,'Position');
0236 set(gca,'Position',[pos(1) pos(2)+0.05 pos(3) pos(4)-0.1]);
0237 title(title_str);
0238
0239
0240
0241
0242
0243 vb_epsfig(gcf,0.5,15);
0244
0245 if ~isempty(findstr(opt_print,'-dpng')),
0246 [fig_dir,fig_file] = vb_file_select({'.png'},'Save figure',true);
0247 else
0248 [fig_dir,fig_file] = vb_file_select({'.eps'},'Save figure',true);
0249 end
0250
0251 if ~isempty(fig_file),
0252 figfile = [fig_dir filesep fig_file{1}];
0253 print(h,opt_print,figfile);
0254 end
0255
0256 delete(h);
0257
0258 return;