Home > bioelectromagnetism > eeg_baseline.m

eeg_baseline

PURPOSE ^

eeg_baseline - remove mean of baseline period from all EEG epochs

SYNOPSIS ^

function [ EEGbase ] = eeg_baseline(EEGdata,baseline_samples)

DESCRIPTION ^

 eeg_baseline - remove mean of baseline period from all EEG epochs

 [ EEGbase ] = eeg_baseline(EEGdata,baseline_samples)

 It is assumed that EEGdata is an MxNxP matrix, with M data samples (ie,
 time), N channels and P epochs (if P=1, EEGdata is MxN).

 baseline_samples is an array of data sample indices (of M) that define
 the baseline period.  If baseline_samples is a scalar, the function
 assumes the baseline index array is 1:baseline_samples.
 
 The function calculates the baseline mean for each epoch as follows:

 baseline_mean = mean(EEGdata(baseline_samples,:,epoch));

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ EEGbase ] = eeg_baseline(EEGdata,baseline_samples)
0002 
0003 % eeg_baseline - remove mean of baseline period from all EEG epochs
0004 %
0005 % [ EEGbase ] = eeg_baseline(EEGdata,baseline_samples)
0006 %
0007 % It is assumed that EEGdata is an MxNxP matrix, with M data samples (ie,
0008 % time), N channels and P epochs (if P=1, EEGdata is MxN).
0009 %
0010 % baseline_samples is an array of data sample indices (of M) that define
0011 % the baseline period.  If baseline_samples is a scalar, the function
0012 % assumes the baseline index array is 1:baseline_samples.
0013 %
0014 % The function calculates the baseline mean for each epoch as follows:
0015 %
0016 % baseline_mean = mean(EEGdata(baseline_samples,:,epoch));
0017 %
0018 
0019 % Copyright (C) 2004  Darren L. Weber
0020 %
0021 % This program is free software; you can redistribute it and/or
0022 % modify it under the terms of the GNU General Public License
0023 % as published by the Free Software Foundation; either version 2
0024 % of the License, or (at your option) any later version.
0025 %
0026 % This program is distributed in the hope that it will be useful,
0027 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0028 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0029 % GNU General Public License for more details.
0030 %
0031 % You should have received a copy of the GNU General Public License
0032 % along with this program; if not, write to the Free Software
0033 % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
0034 
0035 % $Revision: 1.4 $ $Date: 2005/05/18 23:04:05 $
0036 % Created:  10/2004, copyright 2004 Darren.Weber_at_radiology.ucsf.edu
0037 % Modified: 05/2005, Darren.Weber_at_radiology.ucsf.edu
0038 %                    baseline_samples can now be an array or a scalar input
0039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0040 
0041 
0042 version = '[$Revision: 1.4 $]';
0043 fprintf('\nEEG_BASELINE [v%s]\n',version(12:16)); tic
0044 
0045 if ~exist('baseline_samples','var'),
0046     error('no baseline_samples specified');
0047 end
0048 if isempty(baseline_samples),
0049     error('no baseline_samples specified');
0050 end
0051 if length(baseline_samples) == 1,
0052     baseline_samples = 1:baseline_samples;
0053 end
0054 
0055 number_samples = size(EEGdata,1);
0056 
0057 for epoch = 1:size(EEGdata,3),
0058 
0059     baseline_mean = mean(EEGdata(baseline_samples,:,epoch));
0060 
0061     baseline_mean = repmat(baseline_mean,number_samples,1);
0062 
0063     EEGbase(:,:,epoch) = EEGdata(:,:,epoch) - baseline_mean;
0064 
0065 end
0066 
0067 t = toc; fprintf('...done (%6.2f sec).\n\n',t);
0068 return

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003