Home > vbmeg > functions > job > job_plot_currentmap_dir > job_plot_cmap_update_spatialpattern.m

job_plot_cmap_update_spatialpattern

PURPOSE ^

Update brain activity map.

SYNOPSIS ^

function job_plot_cmap_update_spatialpattern(inst_id, initial_load)

DESCRIPTION ^

 Update brain activity map. 

 [syntax]
 job_plot_cmap_update_spatialpattern(inst_id[,initial_load])

 [history]
 ????-??-?? Taku Yoshioka
 2008-09-04 Taku Yoshioka
 2008-12-16 Taku Yoshioka
 2009-05-01 Taku Yoshioka
  Debug (remove redundant code)
 2010-08-26 Taku Yoshioka
  Replace function (vb_plot_cortex->vb_plot_cortex)
 2010-12-01 taku-y
  [internal change] 'Jinfo' replaces 'MEGinfo'.
 2010-12-06 taku-y
  [enhancement] Jinfo.version>=0.9 supported. 
 2010-12-08 taku-y
  [internal change] vb_version_cmp used.
 2011-01-29 taku-y
  [enhancement] Activity map plot supported. 
 2011-02-16 taku-y
  [enhancement] Cortical area plot supported. 
 2011-03-16 taku-y
  [debug] Colorbar scale check is ignored when 'Fix' is checked on GUI.
 2011-04-01 taku-y
  [minor] Colorbar fnc argument changed depending on MATLAB version.
 2011-04-04 taku-y
  [enhancement] Multiple cortical area plot supported. 

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function job_plot_cmap_update_spatialpattern(inst_id, initial_load)
0002 % Update brain activity map.
0003 %
0004 % [syntax]
0005 % job_plot_cmap_update_spatialpattern(inst_id[,initial_load])
0006 %
0007 % [history]
0008 % ????-??-?? Taku Yoshioka
0009 % 2008-09-04 Taku Yoshioka
0010 % 2008-12-16 Taku Yoshioka
0011 % 2009-05-01 Taku Yoshioka
0012 %  Debug (remove redundant code)
0013 % 2010-08-26 Taku Yoshioka
0014 %  Replace function (vb_plot_cortex->vb_plot_cortex)
0015 % 2010-12-01 taku-y
0016 %  [internal change] 'Jinfo' replaces 'MEGinfo'.
0017 % 2010-12-06 taku-y
0018 %  [enhancement] Jinfo.version>=0.9 supported.
0019 % 2010-12-08 taku-y
0020 %  [internal change] vb_version_cmp used.
0021 % 2011-01-29 taku-y
0022 %  [enhancement] Activity map plot supported.
0023 % 2011-02-16 taku-y
0024 %  [enhancement] Cortical area plot supported.
0025 % 2011-03-16 taku-y
0026 %  [debug] Colorbar scale check is ignored when 'Fix' is checked on GUI.
0027 % 2011-04-01 taku-y
0028 %  [minor] Colorbar fnc argument changed depending on MATLAB version.
0029 % 2011-04-04 taku-y
0030 %  [enhancement] Multiple cortical area plot supported.
0031 %
0032 % Copyright (C) 2011, ATR All Rights Reserved.
0033 % License : New BSD License(see VBMEG_LICENSE.txt)
0034 
0035 global vbmeg_inst; 
0036 if isempty(vbmeg_inst.plotcmap{inst_id}.V), return; end
0037 
0038 %
0039 % Global variables
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 % Preparation for cortical surface plot
0076 %
0077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0078 set(h_fig,'Pointer','arrow');
0079 drawnow;
0080 
0081 % Original/Inflated model
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 % Get display parameters
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 % Get ROI vertices
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 % Get spatial pattern of data using current TOI (and FOI)
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 % Color scale
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 % Plot brain activities superimposed on the cortical surface model
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 % Set cortical area
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, % January 29, 2007 or older
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 % Plot indicator for selected Vertex
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 % Update standard brain coordinate
0210 %
0211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0212 job_plot_cmap_update_talcoord(inst_id);
0213 set(h_fig,'Pointer','arrow');
0214 
0215 % Attach drag/zoom tool to axes
0216 set(h_fig, 'WindowButtonUpFcn', ['job_plot_cmap_post_rotate(' num2str(inst_id) ');']);
0217 vb_dragzoom(h_space, '3D');
0218 
0219 % Set callback for vertex selection
0220 patches = get(h_space, 'Children');
0221 set(patches, 'ButtonDownFcn', {@inner_send_select_vertex, inst_id});
0222 
0223 %
0224 % Update cortical area list
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 = []; %cell(0,0);
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 % double click
0250 if strcmpi(get(fig, 'SelectionType'), 'open')
0251     job_plot_cmap_selvertex(inst_id);
0252 end
0253 
0254 
0255 return;
0256 
0257 
0258

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005