TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
adb2event.m
Go to the documentation of this file.
1 function [EVENT,cc] = adb2event(fn,Fs)
2 % ADB2EVENT loads and artifact scoring file of the
3 % artifact database (ADB) of sleep EEG [1]
4 % and converts the data into event information
5 %
6 % [s,H] = sload(filename.edf)
7 % H.EVENT = adb2event([H.FILE.Name,'.txt], H.SampleRate);
8 %
9 % see also: SOPEN, SREAD, SSEEK, STELL, SCLOSE, SWRITE, SEOF
10 %
11 % Reference(s):
12 % [1] Artifact database of sleep EEG. Available online http://www.dpmi.tu-graz.ac.at/ADB/
13 % [2] A. Schlögl, P. Anderer, M.-J. Barbanoj, G. Klösch,G. Gruber, J.L. Lorenzo, O. Filz, M. Koivuluoma, I. Rezek, S.J. Roberts,A. Värri, P. Rappelsberger, G. Pfurtscheller, G. Dorffner
14 % Artifact processing of the sleep EEG in the "SIESTA"-project,
15 % Proceedings EMBEC'99, Part II, pp.1644-1645, 4-7. Nov. 1999,Vienna, Austria.
16 % [3] A. Schlögl, P. Anderer, S.J. Roberts, M. Pregenzer, G.Pfurtscheller.
17 % Artefact detection in sleep EEG by the use of Kalman filtering.
18 % Proceedings EMBEC'99, Part II, pp.1648-1649, 4-7. Nov. 1999,Vienna, Austria.
19 % [4] A. Schlögl, P. Anderer, M.-J. Barbanoj, G. Dorffner, G. Gruber, G. Klösch, J.L. Lorenzo, P. Rappelsberger, G. Pfurtscheller.
20 % Artifacts in the sleep EEG - A database for the evaluation of automated processing methods.
21 % Proceedings of the Third International Congress of the World Federation of Sleep Research Societies (WFSRS). Editors: H. Schulz. P.L. Parmeggiani, and M. Chase. Sleep Research Online 1999:2 (Supplement 1), p. 586.
22 % available online: http://www.sro.org/cftemplate/wfsrscongress/indiv.cfm?ID=19998586
23 
24 
25 % This program is free software; you can redistribute it and/or
26 % modify it under the terms of the GNU General Public License
27 % as published by the Free Software Foundation; either version 2
28 % of the License, or (at your option) any later version.
29 %
30 % This program 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.
34 %
35 % You should have received a copy of the GNU General Public License
36 % along with this program; if not, write to the Free Software
37 % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 
39 % $Revision: 1.2 $
40 % $Id: adb2event.m 2205 2009-10-27 12:18:15Z schloegl $
41 % (C) 1997-2004 by Alois Schloegl <a.schloegl@ieee.org>
42 % This is part of the BIOSIG-toolbox http://biosig.sf.net/
43 
44 ma = load(fn);
45 
46 % code from MAK2BIN.M (C) 1998-2004 A. Schlögl
47 ERG = zeros(size(ma));
48 
49 %%%% one artifact %%%%
50 for k=0:9,
51  if exist('OCTAVE_VERSION')==5
52  ERG = ERG+(ma==k)*2^k;
53  else
54  ERG(ma==k) = 2^k;
55  end;
56 end;
57 
58 %%%% more than one artifact %%%%
59 [i,j] = find(ma>9);
60 L='123456789';
61 for k=1:length(i),
62  b=int2str(ma(i(k),j(k)));
63  erg=0;
64  for l=1:9,
65  if any(b==L(l)), erg=erg+2^l; end;
66  end;
67  ERG(i(k),j(k)) = erg;
68 end;
69 
70 N = 0;
71 POS = [];
72 TYP = [];
73 DUR = [];
74 CHN = [];
75 cc = zeros(1,10);
76 for k = 1:9,
77  for c = 1:7;%size(ERG,2),
78  tmp = [0;~~(bitand(ERG(:,c),2^k));0];
79 
80  cc(k+1) = cc(k+1) + sum(tmp);
81  pos = find(diff(tmp)>0);
82  pos2 = find(diff(tmp)<0);
83  n = length(pos);
84 
85  POS = [POS; pos(:)];
86  TYP = [TYP; repmat(k,n,1)];
87  CHN = [CHN; repmat(c,n,1)];
88  DUR = [DUR; pos2(:)-pos(:)];
89  N = N + n;
90  end;
91 end;
92 
93 EVENT.Fs = 1;
94 if nargin>1,
95  EVENT.Fs = Fs;
96 end;
97 
98 [tmp,ix] = sort(POS);
99 EVENT.POS = (POS(ix)-1)*EVENT.Fs+1;
100 EVENT.TYP = TYP(ix) + hex2dec('0100');
101 EVENT.CHN = CHN(ix);
102 EVENT.DUR = DUR(ix)*EVENT.Fs;
103 EVENT.N = N;
sload
function sload(in FILENAME, in varargin)
adb2event
function adb2event(in fn, in Fs)