TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
eload.m
Go to the documentation of this file.
1 function [HDR] = eload(filename,Fs)
2 % ELOAD loads EVENT data
3 % Event information is often stored in different formats.
4 % ELOAD tries to load different formats into a unified
5 % form
6 %
7 % HDR = eload(filename)
8 %
9 % filename Filename of Event information
10 % HDR.EVENT contains the EVENT information
11 %
12 %
13 % see also: SLOAD, SVIEW, SOPEN
14 %
15 
16 
17 % $Revision: 1.2 $
18 % $Id: eload.m 2205 2009-10-27 12:18:15Z schloegl $
19 % Copyright (C) 1997-2004 by Alois Schloegl
20 % a.schloegl@ieee.org
21 % This is part of the BIOSIG-toolbox http://biosig.sf.net/
22 
23 % This library is free software; you can redistribute it and/or
24 % modify it under the terms of the GNU Library General Public
25 % License as published by the Free Software Foundation; either
26 % Version 2 of the License, or (at your option) any later version.
27 %
28 % This library is distributed in the hope that it will be useful,
29 % but WITHOUT ANY WARRANTY; without even the implied warranty of
30 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 % Library General Public License for more details.
32 %
33 % You should have received a copy of the GNU Library General Public
34 % License along with this library; if not, write to the
35 % Free Software Foundation, Inc., 59 Temple Place - Suite 330,
36 % Boston, MA 02111-1307, USA.
37 
38 
39 HDR = getfiletype(filename);
40 
41 if strcmp(HDR.TYPE,'MAT')
42  tmp = load('-mat',filename);
43  if isfield(tmp,'eventmatrix') & isfield(tmp,'samplerate')
44  %%% F. Einspieler's Event information
45  HDR.EVENT.POS = tmp.eventmatrix(:,1);
46  HDR.EVENT.TYP = tmp.eventmatrix(:,2);
47  HDR.EVENT.CHN = tmp.eventmatrix(:,3);
48  HDR.EVENT.DUR = tmp.eventmatrix(:,4);
49  HDR.EVENT.Fs = tmp.samplerate;
50  HDR.TYPE = 'EVENT';
51 
52  elseif isfield(tmp,'EVENT')
53  HDR.EVENT = EVENT;
54  HDR.TYPE = 'EVENT';
55  end;
56 
57 elseif strcmp(HDR.TYPE,'GDF');
58  H = sopen(HDR,'r'); H=sclose(H);
59  HDR.EVENT = H.EVENT;
60  HDR.EVENT.Fs = H.SampleRate;
61  HDR.TYPE = 'EVENT';
62 
63 elseif strncmp(HDR.TYPE,'BrainVision',11);
64  HDR = sopen(HDR,'r'); HDR=sclose(HDR);
65  if isfield(HDR.EVENT,'TeegType')
66  ix = strmatch('New Segment',HDR.EVENT.TeegType);
67  HDR.EVENT.TYP(ix)=hex2dec('7ffe');
68  end;
69  for k1 = 1:length(HDR.EVENT.Desc)
70  tmp = HDR.EVENT.Desc{k1};
71  %HDR.TRIG = HDR.EVENT.POS(HDR.EVENT.TYP<10);
72  if 0,
73 
74  elseif strncmp(tmp,'TargetCode',10)
75  HDR.EVENT.TYP(k1) = str2double(tmp(11:12))+hex2dec('0300');
76  elseif strcmp(tmp,'BeginOfTrial')
77  HDR.EVENT.TYP(k1) = hex2dec('0300');
78  elseif strcmp(tmp,'hit')
79  HDR.EVENT.TYP(k1) = hex2dec('0381');
80  elseif strcmp(tmp,'wrong')
81  HDR.EVENT.TYP(k1) = hex2dec('0382');
82 
83  % eye movements
84  elseif strcmpi(tmp,'augen links')
85  HDR.EVENT.TYP(k1) = hex2dec('0431');
86  elseif strcmpi(tmp,'augen rechts')
87  HDR.EVENT.TYP(k1) = hex2dec('0432');
88  elseif strcmpi(tmp,'augen hoch') | strcmpi(tmp,'augen oben')
89  HDR.EVENT.TYP(k1) = hex2dec('0433');
90  elseif strcmpi(tmp,'augen unten') | strcmpi(tmp,'augen runter')
91  HDR.EVENT.TYP(k1) = hex2dec('0434');
92  elseif strcmpi(tmp,'augen offen')
93  HDR.EVENT.TYP(k1) = hex2dec('8430');
94  elseif strcmpi(tmp,'augen zu')
95  HDR.EVENT.TYP(k1) = hex2dec('0430');
96  elseif strcmp(tmp,'blinzeln')
97  HDR.EVENT.TYP(k1) = hex2dec('0439');
98 
99  % muscle movements
100  elseif strcmp(tmp,'EMG links')
101  HDR.EVENT.TYP(k1) = hex2dec('0441');
102  elseif strcmp(tmp,'EMG rechts')
103  HDR.EVENT.TYP(k1) = hex2dec('0442');
104  elseif strcmpi(tmp,'kopf bewegen')
105  HDR.EVENT.TYP(k1) = hex2dec('0443');
106  elseif strcmp(tmp,'zunge an')
107  HDR.EVENT.TYP(k1) = hex2dec('0444');
108  elseif strcmp(tmp,'Kiefer anspannen')
109  HDR.EVENT.TYP(k1) = hex2dec('0445');
110  elseif strcmp(tmp,'zunge aus')
111  HDR.EVENT.TYP(k1) = hex2dec('8444');
112  elseif strcmp(tmp,'kopf beißen') | strcmp(tmp,'kopf beißen'),
113  HDR.EVENT.TYP(k1) = hex2dec('0446');
114  elseif strcmp(tmp,'EMG fuss')
115  HDR.EVENT.TYP(k1) = hex2dec('0447');
116  elseif strcmp(tmp,'Arme bewegen')
117  HDR.EVENT.TYP(k1) = hex2dec('0449');
118 
119  elseif strncmp(tmp,'S',1)
120  n = str2double(tmp(2:end));
121  if n==11, % hit (left)
122  HDR.EVENT.TYP(k1) = hex2dec('0381');
123  elseif n==12, % hit (right)
124  HDR.EVENT.TYP(k1) = hex2dec('0381');
125  elseif n==21, % miss (left)
126  HDR.EVENT.TYP(k1) = hex2dec('0382');
127  elseif n==22, % miss (right)
128  HDR.EVENT.TYP(k1) = hex2dec('0382');
129  elseif n==60, % feedback onset
130  HDR.EVENT.TYP(k1) = hex2dec('030d');
131  else
132  HDR.EVENT.TYP(k1) = n;
133  end;
134 
135  elseif strcmp(tmp,'s') | strcmp(tmp,'stop') | strcmp(tmp,'stopp'),
136  HDR.EVENT.TYP(k1) = bitxor(hex2dec('8300'),HDR.EVENT.TYP(k1-1));
137 
138  elseif ~isempty(tmp)
139  [n,v,s] = str2double(tmp(2:end));
140  if (length(n)==1) & (~v)
141  HDR.EVENT.TYP(k1) = n;
142  end;
143  end;
144  end;
145  HDR.EVENT.TYP = HDR.EVENT.TYP(:);
146 
147  if isfield(HDR.EVENT,'POS');
148  ix1 = find(HDR.EVENT.TYP<10);
149  ix2 = find(HDR.EVENT.TYP==100);
150  HDR.EVENT.TYP(ix2,1) = HDR.EVENT.TYP(ix2-1)+hex2dec('8000');
151  ix0 = find((HDR.EVENT.TYP>0)&(HDR.EVENT.TYP<10));
152  HDR.TRIG = HDR.EVENT.POS(ix0);
153  HDR.Classlabel = HDR.EVENT.TYP(ix0);
154  end;
155 
156  HDR = bv2biosig_events(H);
157 
158  %%% Artifact database of the sleep EEG
159 elseif strcmp(HDR.FILE.Ext,'txt') & strmatch(HDR.FILE.Name,['h000201';'h000901';'h001001']);
160  HDR.EVENT = adb2event(filename,100);
161  HDR.TYPE = 'EVENT';
162 elseif strcmp(HDR.FILE.Ext,'txt') & strmatch(HDR.FILE.Name,['b000101';'b000401';'c000701';'c001701';'m000401';'m000901']);
163  HDR.EVENT = adb2event(filename,200);
164  HDR.TYPE = 'EVENT';
165 elseif strcmp(HDR.FILE.Ext,'txt') & strmatch(HDR.FILE.Name,['n000101';'n000401';'p000101';'p000201';'s000201']);
166  HDR.EVENT = adb2event(filename,256);
167  HDR.TYPE = 'EVENT';
168 elseif strcmp(HDR.FILE.Ext,'txt') & strmatch(HDR.FILE.Name,['u000601']);
169  HDR.EVENT = adb2event(filename,400);
170  HDR.TYPE = 'EVENT';
171 
172 elseif strcmp(HDR.TYPE,'WSCORE_EVENT')
173  %HDR.EVENT.POS = HDR.EVENT.POS; % already defined
174  HDR.EVENT.TYP = HDR.EVENT.WSCORETYP; % code assignment not
175  fprintf(2,'Warning ELOAD: Event Codes in file %s do not not follow the standard codes of BIOSIG.\n',filename);
176  %defined
177 
178 else
179  fprintf(2,'Warning ELOAD: file %s is not recognized as event file.\n',filename);
180 
181 end;
sclose
function sclose(in HDR)
bv2biosig_events
function bv2biosig_events(in EVENT)
eload
function eload(in filename, in Fs)
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)
getfiletype
function getfiletype(in arg1)
adb2event
function adb2event(in fn, in Fs)