Home > eeg > egis > data_utils > average_reference.m

average_reference

PURPOSE ^

avref_trialdata= average_reference(trialdata,mask)

SYNOPSIS ^

function avref_trialdata= average_reference(trialdata,mask)

DESCRIPTION ^

avref_trialdata= average_reference(trialdata,mask)

average references trial

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function avref_trialdata= average_reference(trialdata,mask)
0002 %avref_trialdata= average_reference(trialdata,mask)
0003 %
0004 %average references trial
0005 %
0006 
0007 %Modification history
0008 %
0009 % written 7/17/95 by RS
0010 %
0011 % cleaned out a couple of loops and messed with it in the process -- PJ 7/18/99
0012 % resized to accommodate new input size of mask - RS
0013 %
0014 % 7/15/01 PJ Cleaned up
0015 [npoints NChan] = size(trialdata);
0016 
0017 trialdata(:,NChan+1) = zeros(npoints,1);
0018 
0019 temptrialdata = zeros(npoints,NChan+1);
0020 temptrialdata =trialdata.* repmat(mask,npoints,1);
0021 divisor=sum(mask);
0022 average=sum(temptrialdata')/divisor;
0023 channel=-average';
0024 
0025 avref_trialdata = temptrialdata + repmat(channel,1,NChan+1); 
0026 avref_trialdata=avref_trialdata .* repmat(mask,npoints,1);
0027 
0028

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003