Home > functions > job > job_plot_currentmap_dir > job_plot_cmap_spatial_peak.m

job_plot_cmap_spatial_peak

PURPOSE ^

Update spatial pattern.

SYNOPSIS ^

function job_plot_cmap_spatial_peak(inst_id)

DESCRIPTION ^

 Update spatial pattern.
 
 [history]
 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-09 taku-y
  [major] Time-frequency data supported. 
 2011-02-16 taku-y
  [enhancement] Show area list including selected vertex. 
 2012-01-26 sako
  [minor change] n_trial -> "n_trial" was replaced to "ix_trial"
 2012-03-09 taku-y
  [internal change] Modified to use job_plot_cmap_get_spatialpattern. 

 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_spatial_peak(inst_id)
0002 % Update spatial pattern.
0003 %
0004 % [history]
0005 % 2010-12-01 taku-y
0006 %  [internal change] 'Jinfo' replaces 'MEGinfo'
0007 % 2010-12-06 taku-y
0008 %  [enhancement] Jinfo.version>=0.9 supported.
0009 % 2010-12-08 taku-y
0010 %  [internal change] vb_version_cmp used.
0011 % 2010-12-09 taku-y
0012 %  [major] Time-frequency data supported.
0013 % 2011-02-16 taku-y
0014 %  [enhancement] Show area list including selected vertex.
0015 % 2012-01-26 sako
0016 %  [minor change] n_trial -> "n_trial" was replaced to "ix_trial"
0017 % 2012-03-09 taku-y
0018 %  [internal change] Modified to use job_plot_cmap_get_spatialpattern.
0019 %
0020 % Copyright (C) 2011, ATR All Rights Reserved.
0021 % License : New BSD License(see VBMEG_LICENSE.txt)
0022 
0023 global vbmeg_inst; 
0024 
0025 % Global variables
0026 toi       = vbmeg_inst.plotcmap{inst_id}.toi;
0027 foi       = vbmeg_inst.plotcmap{inst_id}.foi;
0028 Jinfo     = vbmeg_inst.plotcmap{inst_id}.Jinfo;
0029 TFinfo    = vbmeg_inst.plotcmap{inst_id}.TFinfo;
0030 ix_trial  = vbmeg_inst.plotcmap{inst_id}.ix_trial;
0031 h_fig     = vbmeg_inst.plotcmap{inst_id}.h_fig;
0032 ix_peak   = vbmeg_inst.plotcmap{inst_id}.ix_peak;
0033 nextDD    = vbmeg_inst.plotcmap{inst_id}.nextDD;
0034 nextIX    = vbmeg_inst.plotcmap{inst_id}.nextIX;
0035 ed5       = vbmeg_inst.plotcmap{inst_id}.ed5;
0036 area_file = vbmeg_inst.plotcmap{inst_id}.area_file;
0037 lb3       = vbmeg_inst.plotcmap{inst_id}.lb3;
0038 
0039 set(h_fig,'Pointer','watch');
0040 drawnow;
0041 
0042 if isempty(nextDD), 
0043   vb_disp('No cortical surface model is loaded.');
0044   return;
0045 else
0046   I = length(nextDD);
0047 end
0048 
0049 % ROI for search
0050 R = str2num(get(ed5,'String'))*1e-3;
0051 if R<0, R=0.1; set(ed5,'String','100'); end
0052 ixx = find(nextDD{ix_peak}<=R);
0053 ixx = nextIX{ix_peak}(ixx);
0054 
0055 % Get time (and frequency) window
0056 if isempty(TFinfo), 
0057   if isempty(Jinfo), 
0058     return;
0059   else
0060     J0 = job_plot_cmap_get_spatialpattern(inst_id);
0061     J0 = abs(J0(ixx));
0062     % Time window
0063     %if vb_version_cmp(Jinfo.version,'>=','0.9-0.a.0'),
0064     %  tt(1) = ceil(toi(1)*Jinfo.SampleFreq/1000+Jinfo.Pretrigger);
0065     %  tt(2) = ceil(toi(2)*Jinfo.SampleFreq/1000+Jinfo.Pretrigger);
0066     %  tt = tt(1):tt(2);
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     % Temporal sum of absolute value of cortical current
0074     %J0 = job_plot_cmap_get_current(inst_id,ix_trial,tt);
0075     %J0 = abs(mean(J0,2));
0076     %J0 = J0(ixx);
0077   end
0078 else
0079   % Time window
0080   tt(1) = ceil(toi(1)*TFinfo.SampleFreq/1000+TFinfo.Pretrigger);
0081   tt(2) = ceil(toi(2)*TFinfo.SampleFreq/1000+TFinfo.Pretrigger);
0082   tt = tt(1):tt(2);
0083   
0084   % Frequency window
0085   [tmp,ix(1)] = min(abs(TFinfo.freq-foi(1)));
0086   [tmp,ix(2)] = min(abs(TFinfo.freq-foi(2)));
0087   if ix(1)>ix(2), 
0088     ff = ix(2):ix(1); 
0089   else
0090     ff = ix(1):ix(2);
0091   end
0092   
0093   % Vertex indices to be searched
0094   [ixx,ixxx] = intersect(TFinfo.ix_act,ixx);
0095   if isempty(ixx), 
0096     vb_disp(['No vertex have time-frequency data within the search ' ...
0097              'range. You should set larger search radius.']);
0098     return;
0099   end
0100   
0101   % Time-frequency sum of absolute value of data
0102   tmp = sum(sum(abs(vbmeg_inst.plotcmap{inst_id}.data(tt,ff,ixxx)),1),2);
0103   J0 = zeros(I,1);
0104   J0(ixx) = tmp;
0105 end
0106 
0107 [tmp,ixp] = max(J0);
0108 vbmeg_inst.plotcmap{inst_id}.ix_peak = ixx(ixp);
0109 
0110 %
0111 % Update cortical area list
0112 %
0113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0114 ixp = ixx(ixp);
0115 
0116 if ~isempty(area_file),
0117   area_key      = vb_get_keyset_area(area_file);
0118   area_key_list = []; %cell(0,0);
0119   n = 1;
0120   
0121   for i=1:length(area_key)
0122     tmp = vb_get_area(area_file,area_key{i});
0123     if ~isempty(find(tmp.Iextract==ixp)),
0124       area_key_list{n} = tmp.key;
0125       n = n+1;
0126     end
0127     
0128     set(lb3,'String',area_key_list);
0129   end
0130 end
0131 
0132 %
0133 % Update figure
0134 %
0135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0136 job_plot_cmap_update_timecourse(inst_id); 
0137 job_plot_cmap_update_spatialpattern(inst_id);
0138 
0139 set(h_fig,'Pointer','arrow');
0140 
0141 return;

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