TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
fepi2gdf.m
Go to the documentation of this file.
1 %function [s,H]=fepi2gdf(fn);
2 % FEPI2GDF Freiburger epilepsy database converted into GDF format
3 
4 % $Id: fepi2gdf.m 2205 2009-10-27 12:18:15Z schloegl $
5 % (C) 2005,2006,2008 by Alois Schloegl <a.schloegl@ieee.org>
6 % This is part of the BIOSIG-toolbox http://biosig.sf.net/
7 
8 % This program is free software; you can redistribute it and/or
9 % modify it under the terms of the GNU General Public License
10 % as published by the Free Software Foundation; either version 3
11 % of the License, or (at your option) any later version.
12 
13 
14 if 1,
15 fid=fopen('epilepsydatabase.csv');
16 t=char(fread(fid,[1,inf],'uint8'));
17 fclose(fid);
18 [n,v,sa]=str2double(t,';',[10,13]);
19 end;
20 
21 fn = dir('*.asc');
22 x = strvcat({fn.name});
23 id = unique(x(:,10:13),'rows');
24 for k=length(id)+(-2:0);%1:length(id)
25  r=str2num(id(k,:));
26  f = [fn(1).name(1:9),id(k,:)];
27 
28  sno = find(r==n(:,1));
29 
30  HDR.TYPE = 'GDF';
31  HDR.FileName = [f,'.gdf'];
32  HDR.Patient.Sex = strtok(sa{sno,2},'"');
33  HDR.Patient.Age = n(sno,3);
34  HDR.T0 = clock;
35  HDR.Patient.Birthday = HDR.T0;
36  HDR.Patient.Birthday(1) = HDR.T0(1) - HDR.Patient.Age;
37 
38  HDR.NS = 6;
39  HDR.DigMax = (2^15-1)*ones(HDR.NS,1);
40  HDR.DigMin = (-2^15)*ones(HDR.NS,1);
41  HDR.PhysMax = HDR.DigMax;
42  HDR.PhysMin = HDR.DigMin;
43  HDR.GDFTYP = repmat(3,HDR.NS);
44  HDR.FLAG.UCAL = 1;
45  HDR.SampleRate = 256;
46  HDR.Dur = 1/256;
47  s = [];
48  for k1 = 1:6,
49  t = load([f,'_',int2str(k1),'.asc']);
50  s(:,k1) = t;
51  end;
52  HDR.NRec = size(s,1);
53  HDR.SPR = 1;
54 
55  HDR = sopen(HDR,'w');
56  HDR = swrite(HDR,s);
57  HDR = sclose(HDR);
58 
59  sview(HDR.FileName);
60  drawnow;
61 end;
sclose
function sclose(in HDR)
swrite
function swrite(in HDR, in data)
sopen
function sopen(in arg1, in PERMISSION, in CHAN, in MODE, in arg5, in arg6)
str2double
function str2double(in s, in cdelim, in rdelim, in ddelim)