Home > vbmeg > 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.
 2012-10-15 taku-y
  [trivial] Modified debug messages.

 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 % 2012-10-15 taku-y
0018 %  [trivial] Modified debug messages.
0019 %
0020 % Copyright (C) 2011, ATR All Rights Reserved.
0021 % License : New BSD License(see VBMEG_LICENSE.txt)
0022 
0023 global vbmeg_inst; 
0024 const = vb_define_verbose;
0025 VERBOSE_LEVEL_DEBUG = const.VERBOSE_LEVEL_DEBUG;
0026 
0027 % --- Global variables
0028 Jinfo    = vbmeg_inst.plotcmap{inst_id}.Jinfo;
0029 TFinfo   = vbmeg_inst.plotcmap{inst_id}.TFinfo;
0030 toi      = vbmeg_inst.plotcmap{inst_id}.toi;
0031 foi      = vbmeg_inst.plotcmap{inst_id}.foi;
0032 cb7      = vbmeg_inst.plotcmap{inst_id}.cb7;
0033 xxP      = vbmeg_inst.plotcmap{inst_id}.xxP;
0034 %lb1      = vbmeg_inst.plotcmap{inst_id}.lb1;
0035 %act_file = vbmeg_inst.plotcmap{inst_id}.act_file;
0036 
0037 % debug messages
0038 vb_disp('job_plot_cmap_get_spatialpattern','DEBUG');
0039 vb_disp(sprintf('size(toi) = %d, %d',size(toi)),'DEBUG');
0040 vb_disp(sprintf('size(foi) = %d, %d',size(foi)),'DEBUG');
0041 
0042 % --- Calculate spatial pattern
0043 I = size(vbmeg_inst.plotcmap{inst_id}.V,1);
0044 J = zeros(I,1);
0045 
0046 if ~isempty(xxP) && get(cb7,'Value'),
0047   J = xxP;
0048 elseif ~isempty(Jinfo), 
0049   if vb_version_cmp(Jinfo.version,'>=','0.9-0.a.0'), 
0050     [tmp,ix(1)] = min(abs(Jinfo.Tmsec-toi(1)));
0051     [tmp,ix(2)] = min(abs(Jinfo.Tmsec-toi(2)));
0052     if ix(1)>ix(2),
0053       tt = ix(2):ix(1);
0054     else
0055       tt = ix(1):ix(2);
0056     end
0057   else
0058     Tstart = vbmeg_inst.plotcmap{inst_id}.Tstart;
0059     tt = ceil((toi(1):toi(2))*Jinfo.SampleFreq/1000-Tstart ...
0060               +Jinfo.Pretrigger)+1;
0061   end
0062   
0063   % Debug code
0064   %if vb_get_verbose==VERBOSE_LEVEL_DEBUG,
0065   %  size(J)
0066   %  size(Jinfo.ix_act)
0067   %  max(Jinfo.ix_act)
0068   %  disp('pause');
0069   %  pause;
0070   %end
0071 
0072   % Mean of current over time window
0073   ix_trial = vbmeg_inst.plotcmap{inst_id}.ix_trial;
0074   if size(vbmeg_inst.plotcmap{inst_id}.Jact,3) > 1
0075     J(Jinfo.ix_act_ex,:) ...
0076         = mean(vbmeg_inst.plotcmap{inst_id}.Jact(:,tt,ix_trial),2);
0077   else
0078     J(Jinfo.ix_act_ex,:) ...
0079         = mean(vbmeg_inst.plotcmap{inst_id}.Jact(:,tt),2);
0080   end
0081 elseif ~isempty(TFinfo), 
0082   [tmp,ix(1)] = min(abs(TFinfo.Tmsec-toi(1)));
0083   [tmp,ix(2)] = min(abs(TFinfo.Tmsec-toi(2)));
0084   if ix(1)>ix(2),
0085     tt = ix(2):ix(1);
0086   else
0087     tt = ix(1):ix(2);
0088   end
0089   
0090   % Frequency window
0091   [tmp,ix(1)] = min(abs(TFinfo.freq-foi(1)));
0092   [tmp,ix(2)] = min(abs(TFinfo.freq-foi(2)));
0093   if ix(1)>ix(2), 
0094     ff = ix(2):ix(1);
0095   else
0096     ff = ix(1):ix(2);
0097   end
0098   
0099   % debug messages
0100   vb_disp(sprintf('min and max of tt = %d, %d\n',min(tt),max(tt)), 'DEBUG');
0101   vb_disp(sprintf('min and max of ff = %d, %d\n',min(ff),max(ff)), 'DEBUG');
0102   
0103   % Mean of data over time-frequency window
0104   tmp = sum(sum(vbmeg_inst.plotcmap{inst_id}.data(ff,tt,:),1),2);
0105   tmp = reshape(tmp,[length(tmp) 1])./(length(ff)*length(tt));
0106   J(TFinfo.ix_act_ex) = TFinfo.Wact*tmp;
0107   
0108   % Debug code
0109   %if vb_get_verbose==VERBOSE_LEVEL_DEBUG,
0110   %  figure;
0111   %  subplot(2,1,1);
0112   %  plot(sum(TFinfo.Wact,1));
0113   %  subplot(2,1,2);
0114   %  plot(sum(TFinfo.Wact,2));
0115   %  disp('pause');
0116   %  pause;
0117   %  close;
0118   %end
0119 else
0120   J = [];
0121 end
0122 
0123 return;

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