Home > functions > job > job_plot_currentmap_dir > job_plot_cmap_get_spatialpattern.m

job_plot_cmap_get_spatialpattern

PURPOSE ^

Get spatial pattern of data using current TOI and FOI.

SYNOPSIS ^

function J = job_plot_cmap_get_spatialpattern(inst_id)

DESCRIPTION ^

 Get spatial pattern of data using current TOI and FOI. 

 When time-frequency data is loaded, it is spatially smoothed by
 gaussian filter, which is saved in time-frequency file.

 [syntax]
 J = job_plot_cmap_get_spatialpattern(inst_id)

 [history]
 2010-12-11 taku-y
  [new] This function is newly created.
 2011-01-28 taku-y
  [enhancement] Activity map plot supported. 
 2011-02-28 taku-y
  [debug] Time point index corrected.

 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 J = job_plot_cmap_get_spatialpattern(inst_id)
0002 % Get spatial pattern of data using current TOI and FOI.
0003 %
0004 % When time-frequency data is loaded, it is spatially smoothed by
0005 % gaussian filter, which is saved in time-frequency file.
0006 %
0007 % [syntax]
0008 % J = job_plot_cmap_get_spatialpattern(inst_id)
0009 %
0010 % [history]
0011 % 2010-12-11 taku-y
0012 %  [new] This function is newly created.
0013 % 2011-01-28 taku-y
0014 %  [enhancement] Activity map plot supported.
0015 % 2011-02-28 taku-y
0016 %  [debug] Time point index corrected.
0017 %
0018 % Copyright (C) 2011, ATR All Rights Reserved.
0019 % License : New BSD License(see VBMEG_LICENSE.txt)
0020 
0021 global vbmeg_inst; 
0022 const = vb_define_verbose;
0023 VERBOSE_LEVEL_DEBUG = const.VERBOSE_LEVEL_DEBUG;
0024 
0025 %
0026 % Global variables
0027 %
0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0029 Jinfo    = vbmeg_inst.plotcmap{inst_id}.Jinfo;
0030 TFinfo   = vbmeg_inst.plotcmap{inst_id}.TFinfo;
0031 toi      = vbmeg_inst.plotcmap{inst_id}.toi;
0032 foi      = vbmeg_inst.plotcmap{inst_id}.foi;
0033 cb7      = vbmeg_inst.plotcmap{inst_id}.cb7;
0034 xxP      = vbmeg_inst.plotcmap{inst_id}.xxP;
0035 %lb1      = vbmeg_inst.plotcmap{inst_id}.lb1;
0036 %act_file = vbmeg_inst.plotcmap{inst_id}.act_file;
0037 
0038 % Debug code
0039 if vb_get_verbose==VERBOSE_LEVEL_DEBUG, 
0040   disp('job_plot_cmap_get_spatialpattern is invoked.');
0041   fprintf('size(toi) = %d, %d\n',size(toi));
0042   fprintf('size(foi) = %d, %d\n',size(foi));
0043   pause;
0044 end
0045 
0046 %
0047 % Calculate spatial pattern
0048 %
0049 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0050 I = size(vbmeg_inst.plotcmap{inst_id}.V,1);
0051 J = zeros(I,1);
0052 
0053 if ~isempty(xxP) && get(cb7,'Value'),
0054   J = xxP;
0055 elseif ~isempty(Jinfo), 
0056   if vb_version_cmp(Jinfo.version,'>=','0.9-0.a.0'), 
0057     %tt(1) = ceil(toi(1)*Jinfo.SampleFreq/1000+Jinfo.Pretrigger);
0058     %tt(2) = ceil(toi(2)*Jinfo.SampleFreq/1000+Jinfo.Pretrigger);
0059     %tt = tt(1):tt(2);
0060     [tmp,ix(1)] = min(abs(Jinfo.Tmsec-toi(1)));
0061     [tmp,ix(2)] = min(abs(Jinfo.Tmsec-toi(2)));
0062     if ix(1)>ix(2),
0063       tt = ix(2):ix(1);
0064     else
0065       tt = ix(1):ix(2);
0066     end
0067   else
0068     Tstart = vbmeg_inst.plotcmap{inst_id}.Tstart;
0069     tt = ceil((toi(1):toi(2))*Jinfo.SampleFreq/1000-Tstart ...
0070               +Jinfo.Pretrigger)+1;
0071   end
0072   
0073   % Debug code
0074   %if vb_get_verbose==VERBOSE_LEVEL_DEBUG,
0075   %  size(J)
0076   %  size(Jinfo.ix_act)
0077   %  max(Jinfo.ix_act)
0078   %  disp('pause');
0079   %  pause;
0080   %end
0081 
0082   % Mean of current over time window
0083   ix_trial = vbmeg_inst.plotcmap{inst_id}.ix_trial;
0084   if size(vbmeg_inst.plotcmap{inst_id}.Jact,3) > 1
0085     J(Jinfo.ix_act_ex,:) ...
0086         = mean(vbmeg_inst.plotcmap{inst_id}.Jact(:,tt,ix_trial),2);
0087   else
0088     J(Jinfo.ix_act_ex,:) ...
0089         = mean(vbmeg_inst.plotcmap{inst_id}.Jact(:,tt),2);
0090   end
0091 elseif ~isempty(TFinfo), 
0092   % Time window
0093   %tt(1) = ceil(toi(1)*TFinfo.SampleFreq/1000+TFinfo.Pretrigger);
0094   %tt(2) = ceil(toi(2)*TFinfo.SampleFreq/1000+TFinfo.Pretrigger);
0095   %tt = tt(1):tt(2);
0096   [tmp,ix(1)] = min(abs(TFinfo.Tmsec-toi(1)));
0097   [tmp,ix(2)] = min(abs(TFinfo.Tmsec-toi(2)));
0098   if ix(1)>ix(2),
0099     tt = ix(2):ix(1);
0100   else
0101     tt = ix(1):ix(2);
0102   end
0103   
0104   % Frequency window
0105   [tmp,ix(1)] = min(abs(TFinfo.freq-foi(1)));
0106   [tmp,ix(2)] = min(abs(TFinfo.freq-foi(2)));
0107   if ix(1)>ix(2), 
0108     ff = ix(2):ix(1);
0109   else
0110     ff = ix(1):ix(2);
0111   end
0112   
0113   % Debug code
0114   if vb_get_verbose==VERBOSE_LEVEL_DEBUG, 
0115     disp('job_plot_cmap_get_spatialpattern is invoked.');
0116     fprintf('min and max of tt = %d, %d\n',min(tt),max(tt));
0117     fprintf('min and max of ff = %d, %d\n',min(ff),max(ff));
0118     fprintf('size(data)\n');
0119     size(vbmeg_inst.plotcmap{inst_id}.data)
0120     pause;
0121   end
0122   
0123   % Mean of data over time-frequency window
0124   tmp = sum(sum(vbmeg_inst.plotcmap{inst_id}.data(ff,tt,:),1),2);
0125   tmp = reshape(tmp,[length(tmp) 1])./(length(ff)*length(tt));
0126   J(TFinfo.ix_act_ex) = TFinfo.Wact*tmp;
0127   
0128   % Debug code
0129   %if vb_get_verbose==VERBOSE_LEVEL_DEBUG,
0130   %  figure;
0131   %  subplot(2,1,1);
0132   %  plot(sum(TFinfo.Wact,1));
0133   %  subplot(2,1,2);
0134   %  plot(sum(TFinfo.Wact,2));
0135   %  disp('pause');
0136   %  pause;
0137   %  close;
0138   %end
0139 else
0140   J = [];
0141 end
0142 
0143 return;

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