Home > marsbar > @mardo > private > pr_ev_diff.m

pr_ev_diff

PURPOSE ^

method to calculate event height for % signal change

SYNOPSIS ^

function d = pr_ev_diff(ev_tc, diff_func, varargin)

DESCRIPTION ^

 method to calculate event height for % signal change
 FORMAT d = pr_ev_diff(ev_tc, diff_func, varargin)
 
 Inputs
 ev_tc     - event time course
 diff_func - difference function; one of
             'max'     - the maximum of the time course
             'max-min' - the max minus the min
             'abs max' - if abs(max) > abs(min) => max otherwise => min
             'abs max-min' -  if abs(max) > abs(min) => (max - min) 
                              otherwise => (min - max) 
  
 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function d = pr_ev_diff(ev_tc, diff_func, varargin)
0002 % method to calculate event height for % signal change
0003 % FORMAT d = pr_ev_diff(ev_tc, diff_func, varargin)
0004 %
0005 % Inputs
0006 % ev_tc     - event time course
0007 % diff_func - difference function; one of
0008 %             'max'     - the maximum of the time course
0009 %             'max-min' - the max minus the min
0010 %             'abs max' - if abs(max) > abs(min) => max otherwise => min
0011 %             'abs max-min' -  if abs(max) > abs(min) => (max - min)
0012 %                              otherwise => (min - max)
0013 %
0014 % $Id$
0015 
0016 if nargin < 2
0017   diff_func = '';
0018 end
0019 if isempty(diff_func)
0020   diff_func = 'max';
0021 end
0022 
0023 [m n] = size(ev_tc);
0024 d = zeros(1, n);
0025 switch lower(diff_func)
0026  case 'max'
0027   d = max(ev_tc, [], 1);
0028  case 'max-min'
0029   d = max(ev_tc, [], 1) - min(ev_tc, [], 1);
0030  case 'abs max'
0031   [d i] = max(abs(ev_tc), [], 1);
0032   for s = 1:n, d(s) = ev_tc(i(s), s); end
0033  case 'abs max-min'
0034   mx = max(ev_tc, [], 1);
0035   mn = min(ev_tc, [], 1);
0036   i  = abs(mx) > abs(mn);
0037   d(i)  = mx(i)-mn(i);
0038   d(~i) = mn(~i)-mx(~i);
0039  case 'window'
0040   if nargin < 4, error('Need window and dt'); end
0041   w = round(varargin{1} / varargin{2}) + 1;
0042   d = mean(ev_tc(w(1):w(2), :), 1);
0043  otherwise
0044   error(sprintf('What is this difference function: %s?', diff_func));
0045 end

Generated on Wed 11-May-2022 16:26:09 by m2html © 2003-2019