TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
biosig2eeglabevent.m
Go to the documentation of this file.
1 % biosig2eeglabevent() - convert biosig events to EEGLAB event structure
2 %
3 % Usage:
4 % >> eeglabevent = biosig2eeglabevent( biosigevent, interval )
5 %
6 % Inputs:
7 % biosigevent - BioSig event structure
8 % interval - Period to extract events for, in frames.
9 % Default [] is all.
10 %
11 % Outputs:
12 % eeglabevent - EEGLAB event structure
13 %
14 % Author: Arnaud Delorme, SCCN, INC, UCSD, 2006-
15 
16 % Copyright (C) 13 2006- Arnaud Delorme, Salk Institute, arno@salk.edu
17 %
18 % This program is free software; you can redistribute it and/or modify
19 % it under the terms of the GNU General Public License as published by
20 % the Free Software Foundation; either version 2 of the License, or
21 % (at your option) any later version.
22 %
23 % This program is distributed in the hope that it will be useful,
24 % but WITHOUT ANY WARRANTY; without even the implied warranty of
25 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 % GNU General Public License for more details.
27 %
28 % You should have received a copy of the GNU General Public License
29 % along with this program; if not, write to the Free Software
30 % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 
32 function event = biosig2eeglabevent(EVENT, interval)
33 
34 if nargin < 2
35  interval = [];
36 end;
37 
38 event = [];
39 disp('Importing data events...');
40 
41 % If the interval variable is empty, import all events.
42 if isempty(interval)
43  if isfield(EVENT, 'Teeg')
44  event = EVENT.Teeg;
45  end
46  if isfield(EVENT, 'TYP')
47  for index = 1:length( EVENT.TYP )
48  event(index).type = EVENT.TYP(index);
49  end
50  end
51  if isfield(EVENT, 'POS')
52  for index = 1:length( EVENT.POS )
53  event(index).latency = EVENT.POS(index);
54  end
55  end
56  if isfield(EVENT, 'DUR')
57  if any( [ EVENT.DUR ] )
58  for index = 1:length( EVENT.DUR )
59  event(index).duration = EVENT.DUR(index);
60  end
61  end
62  end
63  if isfield(EVENT, 'CHN')
64  if any( [ EVENT.CHN ] )
65  for index = 1:length( EVENT.CHN )
66  event(index).chanindex = EVENT.CHN(index);
67  end
68  end
69  end
70 % If a subinterval was specified, select only events that fall in that range, and
71 % edit duration field if it exceeds that range.
72 elseif isfield(EVENT,'POS')
73  count = 1;
74  for index = 1:length(EVENT.POS)
75  pos_tmp = EVENT.POS(index) - interval(1) + 1;
76  if pos_tmp > 0 & EVENT.POS(index) <= interval(2)
77  event(count).latency = pos_tmp;
78  if isfield(EVENT, 'TYP'), event(count).type = EVENT.TYP(index); end
79  if isfield(EVENT, 'CHN'), event(count).chanindex = EVENT.CHN(index); end
80  if isfield(EVENT, 'DUR')
81  event(count).duration = min(EVENT.DUR(index), interval(2) - EVENT.POS(index));
82  end
83  count = count + 1;
84  end
85  end
86 end
biosig2eeglabevent
function biosig2eeglabevent(in EVENT, in interval)