TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
identify_eog_channels.m
Go to the documentation of this file.
1 function chEOG=identify_eog_channels(fn,x);
2 % IDENTIFY_EOG_CHANNELS returns bipolar EOG channels for
3 % correcting of EOG artifacts using regression analysis
4 %
5 % EOGchan = IDENTIFY_EOG_CHANNELS(...)
6 %
7 % EOGchan is a sparse matrix of size number_of_channels x 2.
8 % The sparsity ensures that missing samples of unrelated channels
9 % do not affect the data.
10 %
11 % [...] = IDENTIFY_EOG_CHANNELS(filename)
12 % [...] = IDENTIFY_EOG_CHANNELS(HDR)
13 % filename or HDR struct can be used
14 % [...] = IDENTIFY_EOG_CHANNELS(...,'x')
15 % looks for EOG channels whos Label start with x
16 %
17 % see also: GET_REGRESS_EOG, SLOAD
18 %
19 % Reference(s):
20 % [1] Schlogl A, Keinrath C, Zimmermann D, Scherer R, Leeb R, Pfurtscheller G.
21 % A fully automated correction method of EOG artifacts in EEG recordings.
22 % Clin Neurophysiol. 2007 Jan;118(1):98-104. Epub 2006 Nov 7.
23 % http://dx.doi.org/10.1016/j.clinph.2006.09.003
24 % http://pub.ist.ac.at/~schloegl/publications/schloegl2007eog.pdf
25 
26 % $Id: identify_eog_channels.m 2649 2011-03-09 09:52:44Z schloegl $
27 % Copyright (C) 2006,2007,2009,2010 by Alois Schloegl
28 % This is part of the BIOSIG-toolbox http://biosig.sf.net/
29 
30 % Biosig is free software; you can redistribute it and/or
31 % modify it under the terms of the GNU Library General Public
32 % License as published by the Free Software Foundation; either
33 % Version 3 of the License, or (at your option) any later version.
34 %
35 % This library is distributed in the hope that it will be useful,
36 % but WITHOUT ANY WARRANTY; without even the implied warranty of
37 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
38 % Library General Public License for more details.
39 %
40 % You should have received a copy of the GNU Library General Public
41 % License along with this library; if not, write to the
42 % Free Software Foundation, Inc., 59 Temple Place - Suite 330,
43 % Boston, MA 02111-1307, USA.
44 
45 
46 if ischar(fn),
47  HDR=sopen(fn);
48  HDR=sclose(HDR);
49 elseif isstruct(fn)
50  HDR=fn;
51 end;
52 
53 % graz
54 g1 = strmatch('EOG-left',HDR.Label);
55 g2 = strmatch('EOG-central',HDR.Label);
56 g3 = strmatch('EOG-right',HDR.Label);
57 if isempty([g1,g2,g3])
58  g1 = strmatch('EOG:ch01',HDR.Label);
59  g2 = strmatch('EOG:ch02',HDR.Label);
60  g3 = strmatch('EOG:ch03',HDR.Label);
61 end;
62 
63 % berlin
64 if nargin<2,
65  v1 = strmatch('eogv1',lower(HDR.Label));
66  v2 = strmatch('eogv2',lower(HDR.Label));
67  v0 = strmatch('eogv',lower(HDR.Label));
68  v3 = strmatch('eogvp',lower(HDR.Label));
69  v4 = strmatch('eogvn',lower(HDR.Label));
70 
71  h1 = strmatch('eogh1',lower(HDR.Label));
72  h2 = strmatch('eogh2',lower(HDR.Label));
73  h0 = strmatch('eogh' ,lower(HDR.Label));
74  h3 = strmatch('eoghp',lower(HDR.Label));
75  h4 = strmatch('eoghn',lower(HDR.Label));
76 else
77  v1 = [];
78  v2 = [];
79  v0 = [];
80  v3 = strmatch('xeogvp',lower(HDR.Label));
81  v4 = strmatch('xeogvn',lower(HDR.Label));
82 
83  h1 = [];
84  h2 = [];
85  h0 = [];
86  h3 = strmatch('xeoghp',lower(HDR.Label));
87  h4 = strmatch('xeoghn',lower(HDR.Label));
88 end;
89 
90 g = [g1;g2;g3];
91 v = [v1,v2,v3,v4];
92 if isempty(v), v=v0; end;
93 h = [h1,h2,h3,h4];
94 if isempty(h), h=h0; end;
95 if length(g)==3,
96  chEOG = sparse([g1,g2,g2,g3],[1,1,2,2],[1,-1,1,-1],HDR.NS,2);
97 elseif length(g)==2,
98  chEOG = sparse([g1,g2,g3],[1,1],[1,-1],HDR.NS,1);
99 else
100  c = (length(v)>0);
101  sz2 = (length(v)>0) + (length(h)>0);
102  if length(v)==1,
103  chEOG = sparse(v,c,1,HDR.NS,sz2);
104  elseif length(v)==2,
105  chEOG = sparse(v,[c,c],[1,-1],HDR.NS,sz2);
106  else
107  chEOG = 0;
108  end;
109  if length(h)==1,
110  chEOG = chEOG+sparse(h,1+c,1,HDR.NS,1+c);
111  elseif length(h)==2,
112  chEOG = chEOG+sparse(h,[1,1]+c,[1,-1],HDR.NS,1+c);
113  end;
114 end;
115 
116 if size(chEOG,2)<2,
117  warning('EOG channels are missing, or were not recognized');
118 end;
sclose
function sclose(in HDR)
identify_eog_channels
function identify_eog_channels(in fn, in x)
sopen
function sopen(in arg1, in PERMISSION, in CHAN, in MODE, in arg5, in arg6)