Home > matlabmk > baseline_EEG.m

baseline_EEG

PURPOSE ^

function EEG=baseline_EEG(EEG,bsln_wind,verblevel)

SYNOPSIS ^

function EEG=baseline_EEG(EEG,bsln_wind,verblevel)

DESCRIPTION ^

function EEG=baseline_EEG(EEG,bsln_wind,verblevel)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function EEG=baseline_EEG(EEG,bsln_wind,verblevel)
0002 %function EEG=baseline_EEG(EEG,bsln_wind,verblevel)
0003 
0004 if nargin<2,
0005     error('Baseline time window not specified.');
0006 end
0007 
0008 if nargin<3.
0009     verblevel=2;
0010 end
0011 
0012 fname=[EEG.filepath EEG.filename];
0013 
0014 %Baseline all trials
0015 if ~isempty(bsln_wind),
0016     if verblevel,
0017         fprintf('Baselining the data from %d to %d ms.\n',bsln_wind(1), ...
0018             bsln_wind(2));
0019     end
0020     if bsln_wind(2)<bsln_wind(1),
0021         error('Baseline time window start point (%d ms) is after its end point (%d ms).', ...
0022             bsln_wind(1),bsln_wind(2));
0023     end
0024     if bsln_wind(1)<EEG.times(1),
0025         error('Baseline time window (%d to %d ms) begins before earliest time point in file %s (%d ms).', ...
0026             bsln_wind(1),bsln_wind(2),fname,EEG.times(1));
0027     else
0028         bsln_start=find_tpt(bsln_wind(1),EEG.times);
0029     end
0030     if bsln_wind(2)>EEG.times(end),
0031         error('Baseline time window (%d to %d ms) extends beyond latest time point in file %s (%d ms).', ...
0032             bsln_wind(1),bsln_wind(2),fname,EEG.times(end));
0033     else
0034         bsln_end=find_tpt(bsln_wind(2),EEG.times);
0035     end
0036     
0037     data_sz=size(EEG.data);
0038     EEG.data=rmbase(EEG.data,data_sz(2),bsln_start:bsln_end);
0039     EEG.data=reshape(EEG.data,data_sz(1),data_sz(2),data_sz(3));
0040 end

Generated on Tue 10-May-2016 16:37:45 by m2html © 2005