1function c = cfm(s,arg2,arg3,arg4,mode)
2% CFM - cerebral function monitor
3%       c = CFM(filename)
4%       c = CFM(s,Fs)
5%       c = CFM(s,HDR)
6
7% INPUT:
8%    s          raw data, one channel per column
9%    Fs         sampling rate
10%    HDR        header information
11%    filename   filename
12%
13% OUTPUT:
14%    c  s is filtered (2-12Hz), rectified, and downsampled to (1/min)
15
16
17%	$Id$
18%	Copyright (C) 2009 by Alois Schloegl <alois.schloegl@gmail.com>
19%    	This is part of the BIOSIG-toolbox http://biosig.sf.net/
20
21% This program is free software; you can redistribute it and/or
22% modify it under the terms of the GNU General Public License
23% as published by the Free Software Foundation; either version 3
24% of the  License, or (at your option) any later version.
25%
26% This program is distributed in the hope that it will be useful,
27% but WITHOUT ANY WARRANTY; without even the implied warranty of
28% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29% GNU General Public License for more details.
30%
31% You should have received a copy of the GNU General Public License
32% along with this program; if not, write to the Free Software
33% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
34
35
36if ischar(s)
37        [s,HDR]=sload(s);
38else
39        if size(s,1)<size(s,2),
40                warning('signal data must be ordered in columns')
41        end;
42        if isscalar(arg2)
43               HDR.SampleRate = arg2;
44        end;
45end;
46
47W = 60; % window length is 60 s
48B = fir1(HDR.SampleRate,[2,12]/HDR.SampleRate*2);
49c = rs(abs(filter(B,1,s)),W*HDR.SampleRate,1);
50% bp = log(filter( ones(W*HDR.SampleRate,1), W*HDR.SampleRate, abs(filter(B,1,tmp)) ))];
51
52
53