0001 function [ix_peak,J_peak] ...
0002 = vb_extract_peak_timecourse(J,ix,num_iter,t0,t_size,t_range,ix_area)
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
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
0036 Jmask0 = zeros(size(J,1),1);
0037 Jmask0(ixx) = 1;
0038
0039
0040 Jmask1 = zeros(1,size(J,2));
0041 Jmask1(t_range) = 1;
0042
0043
0044 t_max = t0;
0045 for i=1:num_iter
0046 fprintf('Iteration %d\n',i);
0047
0048
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
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
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