0001 function EEG=baseline_EEG(EEG,bsln_wind,verblevel)
0002
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
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