Home > polypedal > cartperturb > impulseNormalization.m

impulseNormalization

PURPOSE ^

Collect impulse data in one big array

SYNOPSIS ^

function lp = impulseNormalization(lp,imp)

DESCRIPTION ^

 Collect impulse data in one big array

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function lp = impulseNormalization(lp,imp)
0002 
0003 % Collect impulse data in one big array
0004 [lp.imp,lp.impfr] = oneBigArray(imp);
0005 
0006 % Collect impulse frames for individual trials
0007 lp.impfrs = vertcat(imp.frames);
0008 
0009 % keyboard
0010 
0011 % Before and after impulse frame ranges
0012 bi = [100,15];
0013 ai = [20,200];
0014 
0015 % Normalize impulse data by zeroing on segment before impulse
0016 lp.imp = lp.imp - repmat(nanmean(lp.imp(:,1:lp.impfr-bi(2))')',1,size(lp.imp,2));
0017 
0018 
0019 impmean = nanmean(lp.imp);
0020 befimp = (lp.impfr-bi(1)):lp.impfr-bi(2);
0021 befmean = nanmean(lp.imp(:,befimp));
0022 befres = lp.imp(:,befimp) - repmat(befmean,size(lp.imp,1),1);
0023 befse = nanstd(befres(:))/sqrt(length(befres(:)));
0024 befstd = nanstd(befres(:));
0025 %   befse = nanstd(lp.imp(:,befimp))/sqrt(size(lp.imp,1));
0026 befmean = mean(befmean);
0027 
0028 % Before impulse statistics
0029 lp.bi = befimp;
0030 lp.bim = befmean;
0031 lp.bise = befse;
0032 lp.bistd = befstd;
0033 
0034 
0035 aftimp = (lp.impfr+ai(1)):lp.impfr+ai(2);
0036 aftmean = nanmean(lp.imp(:,aftimp));
0037 %   aftse = nanstd(lp.imp(:,aftimp))/sqrt(size(lp.imp,1));
0038 aftres = lp.imp(:,aftimp) - repmat(aftmean,size(lp.imp,1),1);
0039 aftse = nanstd(aftres(:))/sqrt(length(aftres(:)));
0040 aftstd = nanstd(aftres(:));
0041 aftmean = mean(aftmean);
0042 
0043 % After impulse statistics
0044 lp.ai = befimp;
0045 lp.aim = aftmean;
0046 lp.aise = aftse;
0047 lp.aistd = aftstd;
0048 
0049 
0050 % Confidence interval for start and end of impulse
0051 lp.ci = lp.impfr*[1,1];
0052 
0053 for r = 1:size(lp.imp,1)
0054   lp.ci(1) = min([lp.ci(1),max(find(lp.imp(r,:)<=befmean+befstd))]);
0055   lp.ci(2) = max([lp.ci(2),min(find(lp.imp(r,:)>=aftmean-aftstd))]);
0056 end

Generated on Mon 02-Aug-2010 16:44:38 by m2html © 2003