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
7 % HDR =
eload(filename)
9 % filename Filename of Event information
10 % HDR.EVENT contains the EVENT information
13 % see also: SLOAD, SVIEW, SOPEN
18 % $Id:
eload.m 2205 2009-10-27 12:18:15Z schloegl $
19 % Copyright (C) 1997-2004 by Alois Schloegl
21 % This is part of the BIOSIG-toolbox http:
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.
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.
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.
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;
52 elseif isfield(tmp,'EVENT')
57 elseif strcmp(HDR.TYPE,'GDF');
60 HDR.EVENT.Fs = H.SampleRate;
63 elseif strncmp(HDR.TYPE,'BrainVision',11);
65 if isfield(HDR.EVENT,'TeegType')
66 ix = strmatch('New Segment',HDR.EVENT.TeegType);
67 HDR.EVENT.TYP(ix)=hex2dec('7ffe');
69 for k1 = 1:length(HDR.EVENT.Desc)
70 tmp = HDR.EVENT.Desc{k1};
71 %HDR.TRIG = HDR.EVENT.POS(HDR.EVENT.TYP<10);
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');
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');
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');
119 elseif strncmp(tmp,'S',1)
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');
132 HDR.EVENT.TYP(k1) = n;
135 elseif strcmp(tmp,'s') | strcmp(tmp,'stop') | strcmp(tmp,'stopp'),
136 HDR.EVENT.TYP(k1) = bitxor(hex2dec('8300'),HDR.EVENT.TYP(k1-1));
140 if (length(n)==1) & (~v)
141 HDR.EVENT.TYP(k1) = n;
145 HDR.EVENT.TYP = HDR.EVENT.TYP(:);
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);
158 %%% Artifact database of the sleep EEG
159 elseif strcmp(HDR.FILE.Ext,'txt') & strmatch(HDR.FILE.Name,['h000201';'h000901';'h001001']);
162 elseif strcmp(HDR.FILE.Ext,'txt') & strmatch(HDR.FILE.Name,['b000101';'b000401';'c000701';'c001701';'m000401';'m000901']);
165 elseif strcmp(HDR.FILE.Ext,'txt') & strmatch(HDR.FILE.Name,['n000101';'n000401';'p000101';'p000201';'s000201']);
168 elseif strcmp(HDR.FILE.Ext,'txt') & strmatch(HDR.FILE.Name,['u000601']);
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);
179 fprintf(2,'Warning ELOAD: file %s is not recognized as event file.\n',filename);