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

job_plot_cmap_print_spatialpattern

PURPOSE ^

Update spatial pattern of cortical activities (estimated current)

SYNOPSIS ^

function job_plot_cmap_print_spatialpattern(inst_id)

DESCRIPTION ^

 Update spatial pattern of cortical activities (estimated current)
 
 [syntax]
 function job_plot_cmap_print_spatialpattern(inst_id)

 [history]
 ????-??-?? Taku Yoshioka
 2008-09-01 Taku Yoshioka
 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. 
 2010-12-13 taku-y
  [enhancement] Time-frequency data supported.
  [internal change] Implamentation adapted from
  job_plot_cmap_update_spatialpattern. 
 2011-01-11 taku-y
  [minor] inputdlg replaced by vb_property_dlg. 
 2011-04-04 taku-y
  [enhancement] Multiple cortical area plot supported. 
 2011-09-05 taku-y
  [enhancement] Parameter 'Colormap' supported.
 2011-10-29 taku-y
  [debug] [minor] Double lighting for fold model fixed. 
  [enhancement] [minor] Parameter 'Light intensity' supported.
 2012-02-09 taku-y
  [enhancement] Print option support. 
 2012-10-15 taku-y
  [minor] Modified print options.

 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:

SOURCE CODE ^

0001 function job_plot_cmap_print_spatialpattern(inst_id)
0002 % Update spatial pattern of cortical activities (estimated current)
0003 %
0004 % [syntax]
0005 % function job_plot_cmap_print_spatialpattern(inst_id)
0006 %
0007 % [history]
0008 % ????-??-?? Taku Yoshioka
0009 % 2008-09-01 Taku Yoshioka
0010 % 2010-08-26 Taku Yoshioka
0011 %  Replace function (vb_plot_cortex->vb_plot_cortex)
0012 % 2010-12-01 taku-y
0013 %  [internal change] 'Jinfo' replaces 'MEGinfo'.
0014 % 2010-12-06 taku-y
0015 %  [enhancement] Jinfo.version>=0.9 supported.
0016 % 2010-12-08 taku-y
0017 %  [internal change] vb_version_cmp used.
0018 % 2010-12-13 taku-y
0019 %  [enhancement] Time-frequency data supported.
0020 %  [internal change] Implamentation adapted from
0021 %  job_plot_cmap_update_spatialpattern.
0022 % 2011-01-11 taku-y
0023 %  [minor] inputdlg replaced by vb_property_dlg.
0024 % 2011-04-04 taku-y
0025 %  [enhancement] Multiple cortical area plot supported.
0026 % 2011-09-05 taku-y
0027 %  [enhancement] Parameter 'Colormap' supported.
0028 % 2011-10-29 taku-y
0029 %  [debug] [minor] Double lighting for fold model fixed.
0030 %  [enhancement] [minor] Parameter 'Light intensity' supported.
0031 % 2012-02-09 taku-y
0032 %  [enhancement] Print option support.
0033 % 2012-10-15 taku-y
0034 %  [minor] Modified print options.
0035 %
0036 % Copyright (C) 2011, ATR All Rights Reserved.
0037 % License : New BSD License(see VBMEG_LICENSE.txt)
0038 
0039 global vbmeg_inst; 
0040 if isempty(vbmeg_inst.plotcmap{inst_id}.V), return; end
0041 
0042 % --- Global variables
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 cb1        = vbmeg_inst.plotcmap{inst_id}.cb1;
0055 cb2        = vbmeg_inst.plotcmap{inst_id}.cb2;
0056 cb3        = vbmeg_inst.plotcmap{inst_id}.cb3;
0057 cb8        = vbmeg_inst.plotcmap{inst_id}.cb8;
0058 model_type_original_rb = ...
0059     vbmeg_inst.plotcmap{inst_id}.model_type_original_rb;
0060 Jmax_plot_edit = vbmeg_inst.plotcmap{inst_id}.Jmax_plot_edit;
0061 Jmin_plot_edit = vbmeg_inst.plotcmap{inst_id}.Jmin_plot_edit;
0062 area_file = vbmeg_inst.plotcmap{inst_id}.area_file;
0063 area_key  = vbmeg_inst.plotcmap{inst_id}.area_key;
0064 
0065 % --- Preparation for cortical surface plot
0066 
0067 % Original/Inflated model
0068 if get(model_type_original_rb,'Value')==1,  
0069   V = vbmeg_inst.plotcmap{inst_id}.V;
0070   inf_C = [];
0071 else
0072   V = vbmeg_inst.plotcmap{inst_id}.Vinf;
0073   inf_C = vbmeg_inst.plotcmap{inst_id}.inf_C;
0074 end
0075 
0076 % Get display parameters
0077 LRflag = [];
0078 if get(cb2,'Value')==get(cb2,'Max'), LRflag = 'L'; end
0079 if get(cb3,'Value')==get(cb3,'Max'), LRflag = [LRflag 'R']; end;
0080 if isempty(LRflag), 
0081   set(cb2,'Value',get(cb2,'Max')); 
0082   LRflag = 'L';
0083 end
0084 plot_parm.LRflag = LRflag; 
0085 
0086 % --- Get spatial pattern of data using current TOI (and FOI)
0087 J0 = job_plot_cmap_get_spatialpattern(inst_id);
0088 
0089 if isempty(J0), 
0090   isact = 0; 
0091 else 
0092   isact=1; 
0093 end
0094 plot_parm.isact = isact;
0095 [az,el] = view(h_space); 
0096 
0097 % Color scale
0098 Jmax_plot = str2num(get(Jmax_plot_edit,'String'));
0099 Jmin_plot = str2num(get(Jmin_plot_edit,'String'));
0100 
0101 if isempty(Jmax_plot), 
0102   Jmax_plot = max(J0(:));
0103   set(Jmax_plot_edit,'String',num2str(Jmax_plot));
0104 end
0105 
0106 if isempty(Jmin_plot),
0107   Jmin_plot = Jmax_plot*0.1;
0108   set(Jmin_plot_edit,'String',num2str(Jmin_plot));
0109 end
0110 
0111 % Show dialog to input max and threshold of colormap
0112 property_names = {'Colorbar','Max','Min','Colorbar', ...
0113                   'Light intensity','Print option'};
0114 default_values{1} = num2str(plot_parm.flag_colorbar);
0115 default_values{2} = num2str(Jmax_plot);
0116 default_values{3} = num2str(Jmin_plot);
0117 if plot_parm.cmap==1, 
0118   default_values{4} = 'hot';
0119 else
0120   default_values{4} = 'jet';
0121 end
0122 if isempty(inf_C), % for fold model
0123   default_values{5} = '0.6';
0124 else
0125   default_values{5} = '1.0';
0126 end
0127 default_values{6} = plot_parm.str_print_format;
0128 
0129 % debug code
0130 vb_disp(['job_plot_cmap_print_spatialpattern'],'DEBUG');
0131 for i=1:6
0132   tmp_str = sprintf('default_values{%d}=%s',i,default_values{i});
0133   vb_disp(tmp_str,'DEBUG');
0134 end
0135 
0136 % open dialog
0137 description    ...
0138     = {'Colorbar is attached (1) or not (0).', ...
0139        'Maximum value of the absolute value plotted.', ...
0140        ['Minimum threshold; vertices with values lower than ' ...
0141         'the threshold are not plotted.'], ...
0142        'Colormap', ...
0143        'Relative intensity from 0 to 1', ...
0144        'Print option (such as ''-dpng'')'};
0145 values = vb_property_dlg(property_names,default_values,description);
0146 
0147 if isempty(values),
0148   return;
0149 end
0150 
0151 iscbar    = str2num(values{1});
0152 Jmax_plot = str2num(values{2});
0153 Jmin_plot = str2num(values{3});
0154 cmap_str  = values{4};
0155 intensity = str2num(values{5});
0156 opt_print = values{6};
0157 
0158 % --- Plot brain activities superimposed on the cortical surface model
0159 if ~isempty(Jinfo),
0160   if Jmin<0, 
0161     plot_parm.wmode = 0;
0162   else
0163     plot_parm.wmode = 1;
0164   end
0165 elseif ~isempty(TFinfo),
0166   if TFmin<0,
0167     plot_parm.wmode = 0;
0168   else
0169     plot_parm.wmode = 1;
0170   end
0171 end
0172 
0173 % Set cortical area
0174 if ~isempty(area_key) && get(cb8,'Value'),
0175   area_colors = [ 1 0 0; 0 1 0; 0 0 1; 1 1 0; 1 0 1; 0 1 1;
0176                   1 1 0.5; 0.5 0 0; 0 0.5 1; 0.5 1 0; 1 0.5 1; 0 0 0.5;
0177                   1 0.5 0; 0 1 0.5; 0.5 0 1; 0 0.5 0; 0.5 1 1; 1 0 0.5;
0178                   1 0.5 0.5; 0 0.5 0.5; 0.5 1 0.5;
0179                   0.5 0 0.5; 0.5 0.5 1; 0.5 0.5 0 ];
0180   
0181   if ~iscell(area_key), area_key = {area_key}; end
0182   plot_parm.area.area_file   = area_file;
0183   plot_parm.area.key         = area_key;
0184   plot_parm.area.transparent = true;
0185   
0186   for i=1:length(area_key)
0187     plot_parm.area.clr{i} ...
0188         = area_colors(1+mod(i-1,length(area_colors)),:);
0189   end
0190 end
0191 
0192 h_fig = figure;
0193 vb_plot_cortex(plot_parm,V,F,inf_C,J0,Jmin_plot,Jmax_plot); 
0194 axis off;
0195 axis equal;
0196 axis tight;
0197 
0198 if strcmp(cmap_str,'hot'),
0199   colormap(hot);
0200 else
0201   colormap(jet);
0202 end
0203 
0204 if iscbar & Jmax_plot>0,
0205   h = colorbar;
0206   if plot_parm.wmode==0,
0207     set(h,'YLim',[-1*Jmax_plot Jmax_plot]);
0208   else
0209     set(h,'YLim',[0 Jmax_plot]);
0210   end
0211 end
0212 
0213 % --- Print figure
0214 view([az el]);
0215 if ~isempty(inf_C), 
0216   lh = camlight('headlight'); % add light for printing inflate model
0217 else % update light position
0218   c = get(gca,'Children');
0219   for i=1:length(c)
0220     if strcmp(get(c(i),'Type'),'light'),
0221       lh = c(i);
0222       camlight(lh,'headlight');
0223     end
0224   end
0225 end
0226 
0227 % update light intensity
0228 cl = get(lh,'Color');
0229 set(lh,'Color',intensity*cl);
0230 
0231 vb_epsfig(gcf,0.5,15);
0232 
0233 if ~isempty(findstr(opt_print,'-dpng')), 
0234   [fig_dir,fig_file] = vb_file_select({'.png'},'Save figure',true);
0235 else
0236   [fig_dir,fig_file] = vb_file_select({'.eps'},'Save figure',true);
0237 end
0238 
0239 if ~isempty(fig_file), 
0240   figfile = [fig_dir filesep fig_file{1}];
0241   print(h_fig,opt_print,figfile);
0242 end
0243 
0244 if ishandle(h_fig)
0245     delete(h_fig);
0246 end
0247 
0248 return;

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