0001 function job_plot_cmap_update_spatialpattern(inst_id, initial_load)
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 global vbmeg_inst;
0036 if isempty(vbmeg_inst.plotcmap{inst_id}.V), return; end
0037
0038
0039
0040
0041
0042 h_fig = vbmeg_inst.plotcmap{inst_id}.h_fig;
0043 h_space = vbmeg_inst.plotcmap{inst_id}.h_space;
0044 F = vbmeg_inst.plotcmap{inst_id}.F;
0045 plot_parm = vbmeg_inst.plotcmap{inst_id}.plot_parm;
0046 Jinfo = vbmeg_inst.plotcmap{inst_id}.Jinfo;
0047 Jmin = vbmeg_inst.plotcmap{inst_id}.Jmin;
0048 Jmax_plot = vbmeg_inst.plotcmap{inst_id}.Jmax_plot;
0049 Jmin_plot = vbmeg_inst.plotcmap{inst_id}.Jmin_plot;
0050 TFinfo = vbmeg_inst.plotcmap{inst_id}.TFinfo;
0051 TFmin = vbmeg_inst.plotcmap{inst_id}.TFmin;
0052 TFmax_plot = vbmeg_inst.plotcmap{inst_id}.TFmax_plot;
0053 TFmin_plot = vbmeg_inst.plotcmap{inst_id}.TFmin_plot;
0054 ix_peak = vbmeg_inst.plotcmap{inst_id}.ix_peak;
0055 cb2 = vbmeg_inst.plotcmap{inst_id}.cb2;
0056 cb3 = vbmeg_inst.plotcmap{inst_id}.cb3;
0057 cb7 = vbmeg_inst.plotcmap{inst_id}.cb7;
0058 cb8 = vbmeg_inst.plotcmap{inst_id}.cb8;
0059 cb5 = vbmeg_inst.plotcmap{inst_id}.cb5;
0060 ed5 = vbmeg_inst.plotcmap{inst_id}.ed5;
0061 lb1 = vbmeg_inst.plotcmap{inst_id}.lb1;
0062 lb3 = vbmeg_inst.plotcmap{inst_id}.lb3;
0063 act_file = vbmeg_inst.plotcmap{inst_id}.act_file;
0064 model_type_original_rb = ...
0065 vbmeg_inst.plotcmap{inst_id}.model_type_original_rb;
0066 Vtal = vbmeg_inst.plotcmap{inst_id}.Vtal;
0067 nextDD = vbmeg_inst.plotcmap{inst_id}.nextDD;
0068 nextIX = vbmeg_inst.plotcmap{inst_id}.nextIX;
0069 Jmax_plot_edit = vbmeg_inst.plotcmap{inst_id}.Jmax_plot_edit;
0070 Jmin_plot_edit = vbmeg_inst.plotcmap{inst_id}.Jmin_plot_edit;
0071 area_file = vbmeg_inst.plotcmap{inst_id}.area_file;
0072 area_key = vbmeg_inst.plotcmap{inst_id}.area_key;
0073
0074
0075
0076
0077
0078 set(h_fig,'Pointer','arrow');
0079 drawnow;
0080
0081
0082 if get(model_type_original_rb,'Value')==1,
0083 V = vbmeg_inst.plotcmap{inst_id}.V;
0084 inf_C = [];
0085 else
0086 V = vbmeg_inst.plotcmap{inst_id}.Vinf;
0087 inf_C = vbmeg_inst.plotcmap{inst_id}.inf_C;
0088 end
0089
0090
0091 LRflag = [];
0092 if get(cb2,'Value')==get(cb2,'Max'), LRflag = 'L'; end
0093 if get(cb3,'Value')==get(cb3,'Max'), LRflag = [LRflag 'R']; end;
0094 if isempty(LRflag),
0095 set(cb2,'Value',get(cb2,'Max'));
0096 LRflag = 'L';
0097 end
0098 plot_parm.LRflag = LRflag;
0099
0100
0101 if get(cb5,'Value')==get(cb5,'Max'),
0102 R = str2num(get(ed5,'String'))*1e-3;
0103 ix_area = find(nextDD{ix_peak}<=R);
0104 ix_area = nextIX{ix_peak}(ix_area);
0105 else
0106 ix_area = [];
0107 end
0108
0109
0110
0111
0112
0113 J0 = job_plot_cmap_get_spatialpattern(inst_id);
0114
0115 if isempty(J0),
0116 isact = 0;
0117 else
0118 isact=1;
0119 end
0120 plot_parm.isact = isact;
0121
0122
0123 Jmax_plot = str2num(get(Jmax_plot_edit,'String'));
0124 Jmin_plot = str2num(get(Jmin_plot_edit,'String'));
0125
0126 if isempty(Jmax_plot),
0127 Jmax_plot = max(J0(:));
0128 set(Jmax_plot_edit,'String',num2str(Jmax_plot));
0129 end
0130
0131 if isempty(Jmin_plot),
0132 Jmin_plot = Jmax_plot*0.1;
0133 set(Jmin_plot_edit,'String',num2str(Jmin_plot));
0134 end
0135
0136
0137
0138
0139
0140 if ~isempty(Jinfo),
0141 if Jmin<0,
0142 plot_parm.wmode = 0;
0143 else
0144 plot_parm.wmode = 1;
0145 end
0146 elseif ~isempty(TFinfo),
0147 if TFmin<0,
0148 plot_parm.wmode = 0;
0149 else
0150 plot_parm.wmode = 1;
0151 end
0152 end
0153
0154
0155 if ~isempty(area_key) && get(cb8,'Value'),
0156 area_colors = [ 1 0 0; 0 1 0; 0 0 1; 1 1 0; 1 0 1; 0 1 1;
0157 1 1 0.5; 0.5 0 0; 0 0.5 1; 0.5 1 0; 1 0.5 1; 0 0 0.5;
0158 1 0.5 0; 0 1 0.5; 0.5 0 1; 0 0.5 0; 0.5 1 1; 1 0 0.5;
0159 1 0.5 0.5; 0 0.5 0.5; 0.5 1 0.5;
0160 0.5 0 0.5; 0.5 0.5 1; 0.5 0.5 0 ];
0161
0162 if ~iscell(area_key), area_key = {area_key}; end
0163 plot_parm.area.area_file = area_file;
0164 plot_parm.area.key = area_key;
0165 plot_parm.area.transparent = false;
0166
0167 for i=1:length(area_key)
0168 tmp_area = vb_get_area(area_file, area_key{i});
0169 if isfield(tmp_area, 'clr')
0170 plot_parm.area.clr{i} = tmp_area.clr;
0171 else
0172 plot_parm.area.clr{i} ...
0173 = area_colors(1+mod(i-1,length(area_colors)),:);
0174 end
0175 end
0176 end
0177 set(0, 'CurrentFigure', h_fig);
0178 set(h_fig,'CurrentAxes',h_space);
0179 cla;
0180 h = vb_plot_cortex(plot_parm,V,F,inf_C,J0,Jmin_plot,Jmax_plot,ix_area);
0181 if exist('initial_load', 'var') && initial_load
0182 axis off;
0183 axis tight;
0184 axis equal;
0185 a = xlim;
0186 xlim(a*1.01);
0187 set(h_space, 'XLimMode', 'manual');
0188 end
0189 colormap(jet);
0190 try
0191 if datenum(version('-date'))<=733071,
0192 reset(vbmeg_inst.plotcmap{inst_id}.h_cbar);
0193 colorbar(vbmeg_inst.plotcmap{inst_id}.h_cbar);
0194 else
0195 pos = get(vbmeg_inst.plotcmap{inst_id}.h_cbar,'Position');
0196 delete(vbmeg_inst.plotcmap{inst_id}.h_cbar);
0197 vbmeg_inst.plotcmap{inst_id}.h_cbar = colorbar('Position',pos);
0198 end
0199 catch
0200 end
0201
0202
0203
0204
0205 plot3(V(ix_peak,1),V(ix_peak,2),V(ix_peak,3),'gx',...
0206 'MarkerSize',15,'LineWidth',3);
0207
0208
0209
0210
0211
0212 job_plot_cmap_update_talcoord(inst_id);
0213 set(h_fig,'Pointer','arrow');
0214
0215
0216 set(h_fig, 'WindowButtonUpFcn', ['job_plot_cmap_post_rotate(' num2str(inst_id) ');']);
0217 vb_dragzoom(h_space, '3D');
0218
0219
0220 patches = get(h_space, 'Children');
0221 set(patches, 'ButtonDownFcn', {@inner_send_select_vertex, inst_id});
0222
0223
0224
0225
0226
0227 ix_peak = vbmeg_inst.plotcmap{inst_id}.ix_peak;
0228 if ~isempty(area_file) && ~isempty(ix_peak);
0229 area_key = vb_get_keyset_area(area_file);
0230 area_key_list = [];
0231 n = 1;
0232
0233 for i=1:length(area_key)
0234 tmp = vb_get_area(area_file,area_key{i});
0235 if ~isempty(find(tmp.Iextract==ix_peak)),
0236 area_key_list{n} = tmp.key;
0237 n = n+1;
0238 end
0239
0240 set(lb3,'String',area_key_list, 'Value', 1);
0241 end
0242 end
0243
0244 return;
0245
0246 function inner_send_select_vertex(src, evt, inst_id)
0247 global vbmeg_inst;
0248 fig = vbmeg_inst.plotcmap{inst_id}.h_fig;
0249
0250 if strcmpi(get(fig, 'SelectionType'), 'open')
0251 job_plot_cmap_selvertex(inst_id);
0252 end
0253
0254
0255 return;
0256
0257
0258