Home > vbmeg > functions > estimation > bayes > vb_extract_peak_timecourse.m

vb_extract_peak_timecourse

PURPOSE ^

------------------------------------------------------------

SYNOPSIS ^

function [ix_peak,J_peak]= vb_extract_peak_timecourse(J,ix,num_iter,t0,t_size,t_range,ix_area)

DESCRIPTION ^

------------------------------------------------------------
 function [ix_peak,J_peak] ...
     = vb_extract_peak_timecourse(J,ix,num_iter,t0,t_size,t_range,ix_area)

 *** Input parameters
 - J       :
 - ix      :
 - num_iter:
 - t0      :
 - t_size  :
 - t_range :
 - ix_area :

 *** Output parameters
 - ix_peak :
 - J_peak  : 

 2005-03-17 Taku Yoshioka
------------------------------------------------------------

 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 [ix_peak,J_peak] ...
0002     = vb_extract_peak_timecourse(J,ix,num_iter,t0,t_size,t_range,ix_area)
0003 %------------------------------------------------------------
0004 % function [ix_peak,J_peak] ...
0005 %     = vb_extract_peak_timecourse(J,ix,num_iter,t0,t_size,t_range,ix_area)
0006 %
0007 % *** Input parameters
0008 % - J       :
0009 % - ix      :
0010 % - num_iter:
0011 % - t0      :
0012 % - t_size  :
0013 % - t_range :
0014 % - ix_area :
0015 %
0016 % *** Output parameters
0017 % - ix_peak :
0018 % - J_peak  :
0019 %
0020 % 2005-03-17 Taku Yoshioka
0021 %------------------------------------------------------------
0022 %
0023 % Copyright (C) 2011, ATR All Rights Reserved.
0024 % License : New BSD License(see VBMEG_LICENSE.txt)
0025 
0026 % Search area
0027 ixx = [];
0028 for i=1:length(ix_area)
0029   ix_tmp = find(ix==ix_area(i)); 
0030   if ~isempty(ix_tmp), ixx = [ixx; ix_tmp]; end; 
0031 end
0032 ix_area_back = zeros(size(J,1),1);
0033 ix_area_back(ix_area) = 1:length(ix_area); 
0034 
0035 % Spatial mask
0036 Jmask0 = zeros(size(J,1),1); 
0037 Jmask0(ixx) = 1; 
0038 
0039 % Temporal mask
0040 Jmask1 = zeros(1,size(J,2)); 
0041 Jmask1(t_range) = 1; 
0042 
0043 % Loop
0044 t_max = t0; 
0045 for i=1:num_iter
0046   fprintf('Iteration %d\n',i);
0047   
0048   % Time window
0049   Twin = max(1,(t_max-t_size)):min(size(J,2),(t_max+t_size));
0050   fprintf('Time window: [%d,%d]\n',min(Twin),max(Twin)); 
0051    
0052   % Find spacial peak
0053   Jspace = sum(abs(J(:,Twin)),2);
0054   Jspace = Jspace.*Jmask0; 
0055   [tmp,ix_max] = max(Jspace);
0056   fprintf('Spacial paek: %d\n',ix_area(ix_area_back(ix_max))); 
0057   
0058   % Find temporal peak
0059   Jtime = abs(J(ix_max,:)).*Jmask1; 
0060   [tmp,t_max] = max(Jtime);
0061   fprintf('Temporal peak: %d\n',t_max);
0062 end
0063 
0064 ix_peak = ix_area(ix_area_back(ix_max)); 
0065 J_peak = J(ix_peak,:); 
0066

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