Home > 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. 

 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 %
0034 % Copyright (C) 2011, ATR All Rights Reserved.
0035 % License : New BSD License(see VBMEG_LICENSE.txt)
0036 
0037 global vbmeg_inst; 
0038 if isempty(vbmeg_inst.plotcmap{inst_id}.V), return; end
0039 
0040 %
0041 % Global variables
0042 %
0043 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0044 h_space    = vbmeg_inst.plotcmap{inst_id}.h_space;
0045 F          = vbmeg_inst.plotcmap{inst_id}.F;
0046 plot_parm  = vbmeg_inst.plotcmap{inst_id}.plot_parm;
0047 Jinfo      = vbmeg_inst.plotcmap{inst_id}.Jinfo;
0048 Jmin       = vbmeg_inst.plotcmap{inst_id}.Jmin;
0049 Jmax_plot  = vbmeg_inst.plotcmap{inst_id}.Jmax_plot;
0050 Jmin_plot  = vbmeg_inst.plotcmap{inst_id}.Jmin_plot;
0051 TFinfo     = vbmeg_inst.plotcmap{inst_id}.TFinfo;
0052 TFmin      = vbmeg_inst.plotcmap{inst_id}.TFmin;
0053 TFmax_plot = vbmeg_inst.plotcmap{inst_id}.TFmax_plot;
0054 TFmin_plot = vbmeg_inst.plotcmap{inst_id}.TFmin_plot;
0055 cb1        = vbmeg_inst.plotcmap{inst_id}.cb1;
0056 cb2        = vbmeg_inst.plotcmap{inst_id}.cb2;
0057 cb3        = vbmeg_inst.plotcmap{inst_id}.cb3;
0058 cb8        = vbmeg_inst.plotcmap{inst_id}.cb8;
0059 model_type_original_rb = ...
0060     vbmeg_inst.plotcmap{inst_id}.model_type_original_rb;
0061 Jmax_plot_edit = vbmeg_inst.plotcmap{inst_id}.Jmax_plot_edit;
0062 Jmin_plot_edit = vbmeg_inst.plotcmap{inst_id}.Jmin_plot_edit;
0063 area_file = vbmeg_inst.plotcmap{inst_id}.area_file;
0064 area_key  = vbmeg_inst.plotcmap{inst_id}.area_key;
0065 
0066 %
0067 % Preparation for cortical surface plot
0068 %
0069 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0070 
0071 % Original/Inflated model
0072 if get(model_type_original_rb,'Value')==1,  
0073   V = vbmeg_inst.plotcmap{inst_id}.V;
0074   inf_C = [];
0075 else
0076   V = vbmeg_inst.plotcmap{inst_id}.Vinf;
0077   inf_C = vbmeg_inst.plotcmap{inst_id}.inf_C;
0078 end
0079 
0080 % Get display parameters
0081 LRflag = [];
0082 if get(cb2,'Value')==get(cb2,'Max'), LRflag = 'L'; end
0083 if get(cb3,'Value')==get(cb3,'Max'), LRflag = [LRflag 'R']; end;
0084 if isempty(LRflag), 
0085   set(cb2,'Value',get(cb2,'Max')); 
0086   LRflag = 'L';
0087 end
0088 plot_parm.LRflag = LRflag; 
0089 
0090 %
0091 % Get spatial pattern of data using current TOI (and FOI)
0092 %
0093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0094 J0 = job_plot_cmap_get_spatialpattern(inst_id);
0095 
0096 if isempty(J0), 
0097   isact = 0; 
0098 else 
0099   isact=1; 
0100 end
0101 plot_parm.isact = isact;
0102 [az,el] = view(h_space); 
0103 
0104 % Color scale
0105 Jmax_plot = str2num(get(Jmax_plot_edit,'String'));
0106 Jmin_plot = str2num(get(Jmin_plot_edit,'String'));
0107 
0108 if isempty(Jmax_plot), 
0109   Jmax_plot = max(J0(:));
0110   set(Jmax_plot_edit,'String',num2str(Jmax_plot));
0111 end
0112 
0113 if isempty(Jmin_plot),
0114   Jmin_plot = Jmax_plot*0.1;
0115   set(Jmin_plot_edit,'String',num2str(Jmin_plot));
0116 end
0117 
0118 % Show dialog to input max and threshold of colormap
0119 property_names = {'Colorbar','Max','Min','Colorbar', ...
0120                   'Light intensity','Print option'};
0121 default_values = {'1',num2str(Jmax_plot),num2str(Jmin_plot),'jet','1.0'};
0122 if isempty(inf_C), % for fold model
0123   default_values{5} = '0.6';
0124 end
0125 default_values{6} = '-depsc';
0126 description    ...
0127     = {'Colorbar is attached (1) or not (0).', ...
0128        'Maximum value of the absolute value plotted.', ...
0129        ['Minimum threshold; vertices with values lower than ' ...
0130         'the threshold are not plotted.'], ...
0131        'Colormap', ...
0132        'Relative intensity from 0 to 1', ...
0133        'Print option (such as ''-dpng'')'};
0134 values = vb_property_dlg(property_names,default_values,description);
0135 
0136 if isempty(values),
0137   return;
0138 end
0139 
0140 iscbar    = str2num(values{1});
0141 Jmax_plot = str2num(values{2});
0142 Jmin_plot = str2num(values{3});
0143 cmap_str  = values{4};
0144 intensity = str2num(values{5});
0145 opt_print = values{6};
0146 
0147 %
0148 % Plot brain activities superimposed on the cortical surface model
0149 %
0150 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0151 if ~isempty(Jinfo),
0152   if Jmin<0, 
0153     plot_parm.wmode = 0;
0154   else
0155     plot_parm.wmode = 1;
0156   end
0157 elseif ~isempty(TFinfo),
0158   if TFmin<0,
0159     plot_parm.wmode = 0;
0160   else
0161     plot_parm.wmode = 1;
0162   end
0163 end
0164 
0165 % Set cortical area
0166 if ~isempty(area_key) && get(cb8,'Value'),
0167   area_colors = [ 1 0 0; 0 1 0; 0 0 1; 1 1 0; 1 0 1; 0 1 1;
0168                   1 1 0.5; 0.5 0 0; 0 0.5 1; 0.5 1 0; 1 0.5 1; 0 0 0.5;
0169                   1 0.5 0; 0 1 0.5; 0.5 0 1; 0 0.5 0; 0.5 1 1; 1 0 0.5;
0170                   1 0.5 0.5; 0 0.5 0.5; 0.5 1 0.5;
0171                   0.5 0 0.5; 0.5 0.5 1; 0.5 0.5 0 ];
0172   
0173   if ~iscell(area_key), area_key = {area_key}; end
0174   plot_parm.area.area_file   = area_file;
0175   plot_parm.area.key         = area_key;
0176   plot_parm.area.transparent = true;
0177   
0178   for i=1:length(area_key)
0179     plot_parm.area.clr{i} ...
0180         = area_colors(1+mod(i-1,length(area_colors)),:);
0181   end
0182 end
0183 
0184 h_fig = figure;
0185 vb_plot_cortex(plot_parm,V,F,inf_C,J0,Jmin_plot,Jmax_plot); 
0186 axis off;
0187 axis equal;
0188 axis tight;
0189 
0190 if strcmp(cmap_str,'hot'),
0191   colormap(hot);
0192 else
0193   colormap(jet);
0194 end
0195 
0196 if iscbar & Jmax_plot>0,
0197   h = colorbar;
0198   if plot_parm.wmode==0,
0199     set(h,'YLim',[-1*Jmax_plot Jmax_plot]);
0200   else
0201     set(h,'YLim',[0 Jmax_plot]);
0202   end
0203 end
0204 
0205 %
0206 % Print figure
0207 %
0208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0209 view([az el]);
0210 if ~isempty(inf_C), 
0211   lh = camlight('headlight'); % add light for printing inflate model
0212 else % update light position
0213   c = get(gca,'Children');
0214   for i=1:length(c)
0215     if strcmp(get(c(i),'Type'),'light'),
0216       lh = c(i);
0217       camlight(lh,'headlight');
0218     end
0219   end
0220 end
0221 
0222 % update light intensity
0223 cl = get(lh,'Color');
0224 set(lh,'Color',intensity*cl);
0225 
0226 vb_epsfig(gcf,0.5,15);
0227 
0228 if ~isempty(findstr(opt_print,'-dpng')), 
0229   [fig_dir,fig_file] = vb_file_select({'.png'},'Save figure',true);
0230 else
0231   [fig_dir,fig_file] = vb_file_select({'.eps'},'Save figure',true);
0232 end
0233 
0234 if ~isempty(fig_file), 
0235   figfile = [fig_dir filesep fig_file{1}];
0236   print(h_fig,opt_print,figfile);
0237 end
0238 
0239 delete(h_fig);
0240 
0241 return;

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005