2 % REGRESS_EOG yields the regression coefficients
for
3 % correcting EOG artifacts in EEG recordings as described in [1].
4 % Typically, EOG correction is a two-step procedure. The first step
5 % estimates the correction coefficient, the second step uses them
8 % Step 1: estimating the correction coefficients:
13 % NOTE: it is recommended that
this data segments (D, filename) contain
14 % segments with large eye movement artifacts only; other artifacts
15 % (e.g. saturation, electrode movement, muscle, etc) should be
18 % Step 2: Corrected data is obtained by
19 % S2 = S1 * R.r0; % without offset correction
20 % S2 = [ones(size(S1,1),1),S1] * R.r1; % with offset correction
23 % EL list of eeg channels: those channels will be corrected
24 % OL eog/ecg channels.
25 %
if OL is a vector, it represents the list of noise channels
26 %
if OL is a matrix, OL derives the noise channels through rereferencing.
27 % This is useful
if the EOG is recorded monopolar, but the bipolar EOG
28 % should be used
for for artefact reduction (because the global EEG should remain),
29 % One can define OL = sparse([23,24,25,26],[1,1,2,2],[1,-1,1,-1])
30 % resulting in two noise channels defined as bipolar channels #23-#24 and #25-#26
32 % OL = IDENTIFY_EOG_CHANNELS(filename)
33 % R.r1, R.r0 rereferencing matrix
for correcting artifacts with and without offset correction
34 % R.b0 coefficients of EOG influencing EEG channels
35 % S2 corrected EEG-signal
37 % see also: IDENTIFY_EOG_CHANNELS, SLOAD, GET_REGRESS_EOG
40 % [1] Schlogl A, Keinrath C, Zimmermann D, Scherer R, Leeb R, Pfurtscheller G.
41 % A fully automated correction method of EOG artifacts in EEG recordings.
42 % Clin Neurophysiol. 2007 Jan;118(1):98-104. Epub 2006 Nov 7.
46 % This program is free software; you can redistribute it and/or
47 % modify it under the terms of the GNU General Public License
48 % as published by the Free Software Foundation; either version 3
49 % of the License, or (at your option) any later version.
51 % This program is distributed in the hope that it will be useful,
52 % but WITHOUT ANY WARRANTY; without even the implied warranty of
53 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54 % GNU General Public License
for more details.
56 % You should have received a copy of the GNU General Public License
57 % along with
this program;
if not, write to the Free Software
58 % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
60 % $Id:
regress_eog.m 2649 2011-03-09 09:52:44Z schloegl $
61 % (C) 1997-2007,2008,2009 by Alois Schloegl <a.schloegl@ieee.org>
62 % This is part of the BIOSIG-toolbox http:
71 ny = find(~any(nx,2));
74 elseif size(D,1)==size(D,2)
83 R.datatype = 'ArtifactCorrection_Regression';
86 R.Mode = 1; % correction of the mean
87 R.Mode = 0; % correction without mean
90 if size(nx,1)==1, % list of noise channel
92 else % noise channels are defined through rereferencing (e.g. bipoloar channels)
93 tmp = H.NS+(1:size(nx,2));
95 a(2:size(nx,1)+1,tmp+1) = nx;
96 if rank(full(nx)) < size(nx,2),
97 fprintf(2,'Warning REGRESS_EOG: referencing matrix is singular! \n');
105 r1 = sparse(2:H.NS+1,1:H.NS,1);
107 b0 = -inv(C([1; nx+1], [1; nx+1])) * C([1; nx+1], ny+1);
108 r0(nx,ny) = b0(2:end,:); % rearrange channel order
109 r1([1;1+nx], ny) = b0; % rearrange channel order
111 R.b0 = b0; % correction coefficients, useful for visualization
112 R.r0 = a(2:end,2:end)*r0;
115 if size(D,1)==size(D,2),
119 % S = D * R.r0; % without offset correction
120 S = [ones(size(D,1),1),D] * R.r1; % with offset correction