2 % Spatial filter provides different spatial filters.
10 % NS number of channels
11 % s data matrix (one column per channel)
12 % Mode
'Mono': monopolar
13 %
'CAR': common average reference
14 %
'Laplace': Hjorth
's Laplacian
15 % 'bipolar
': all posible combinations of bipolar channels
16 % 'PCA
': Principle Component Analysis
17 % 'ICA
': Independent Component Analysis
18 % 'CSP
': Common Spatial patterns
19 % 'ALL
': Combination of all
21 % $Id: spatialfilter.m 2202 2009-10-27 12:06:45Z schloegl $
22 % Copyright (C) 2008 by Alois Schloegl <a.schloegl@ieee.org>
23 % This is part of the BIOSIG-toolbox http://biosig.sf.net/
25 % BioSig is free software: you can redistribute it and/or modify
26 % it under the terms of the GNU General Public License as published by
27 % the Free Software Foundation, either version 3 of the License, or
28 % (at your option) any later version.
30 % BioSig is distributed in the hope that it will be useful,
31 % but WITHOUT ANY WARRANTY; without even the implied warranty of
32 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 % GNU General Public License for more details.
35 % You should have received a copy of the GNU General Public License
36 % along with BioSig. If not, see <http://www.gnu.org/licenses/>.
44 elseif isstruct(arg1) && isfield(arg1,'NS
')
48 if strcmpi(Mode,'bipolar
')
49 W = sparse(NS,NS*(NS-1)/2);
54 W([k1,k2],n) = [1,-1];
55 Label{n} = sprintf('Bip #%i-#%i
',k1,k2);
59 elseif strcmpi(Mode,'Mono
')
61 Label = cellstr(int2str([1:NS]'));
62 for k=1:NS,Label{k} = [
'Mono #',int2str(k)]; end;
64 elseif strcmpi(Mode,
'CAR')
65 W = [eye(NS) - 1/NS, ones(NS,1)/NS];
66 Label = cellstr(int2str([1:NS]'));
67 for k=1:NS,Label{k} = [
'CAR #',int2str(k)]; end;
68 Label{NS+1} =
'CAR REF';
70 elseif strcmpi(Mode,
'ICA')
73 warning(
'ICA not supported yet');
74 %
for k=1:size(W,2),Label{k} = [
'ICA #',int2str(k)]; end;
76 elseif strcmpi(Mode,
'PCA')
78 error('PCA requires data matrix s')
81 for k=1:size(W,2),Label{k} = [
'PCA #',int2str(k)]; end;
84 elseif strcmpi(Mode,
'CSP')
85 if isempty(s) || nargin<3
86 error('CSP requires data matrix s and s2')
88 [W,D] = eig(covm(s,'E'),covm(s2,'E'));
89 for k=1:size(W,2),Label{k} = [
'CSP #',int2str(k)]; end;
92 elseif strcmpi(Mode,
'ALL')
97 Label = [L1(:); L2(:); L3(:)];
103 Label = [Label; L1(:); L2(:)];
106 elseif strcmpi(Mode,
'Laplace')
107 error('Laplace not supported yet');
110 error(sprintf('%s not supported yet',Mode));