TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
tload.m
Go to the documentation of this file.
1 function [signal,H] = tload(FILENAME,TI1,CHAN,EVENTFILE,TI2)
2 % TLOAD loads and triggers signal data.
3 %
4 % [signal,HDR] = tload(FILENAME, TI, [CHAN,] EVENTFILE, AI)
5 %
6 % S = reshape(signal,HDR.size) returns the corresponding 3-dim Matrix
7 %
8 % FILENAME name of file, or list of filenames, wildcards '*' are supported.
9 % The files must contain the trigger information.
10 % TI trigger interval [t1,t2,t3] in seconds, relative to TRIGGER point
11 % The interval [t1,t2] defines the trigger segment, t3 is
12 % optional and determines the number of NaN's after each trial.
13 % CHAN list of selected channels
14 % default=0: loads all channels
15 % EVENTFILE file of artifact scoring
16 % AI Artifactinterval [t1,t2] in seconds, relative to TRIGGER point
17 % Trials with artifacts within this segment are removed.
18 % By default AI=TI, AI enables to select the critical period.
19 %
20 %
21 % see also: SLOAD, SVIEW, SOPEN, ARTIFACT_SELECTION
22 
23 
24 % $Id: tload.m 2205 2009-10-27 12:18:15Z schloegl $
25 % Copyright (C) 2004-2005 by Alois Schloegl <a.schloegl@ieee.org>
26 % This is part of the BIOSIG-toolbox http://biosig.sf.net/
27 
28 % This library is free software; you can redistribute it and/or
29 % modify it under the terms of the GNU Library General Public
30 % License as published by the Free Software Foundation; either
31 % Version 2 of the License, or (at your option) any later version.
32 %
33 % This library is distributed in the hope that it will be useful,
34 % but WITHOUT ANY WARRANTY; without even the implied warranty of
35 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36 % Library General Public License for more details.
37 %
38 % You should have received a copy of the GNU Library General Public
39 % License along with this library; if not, write to the
40 % Free Software Foundation, Inc., 59 Temple Place - Suite 330,
41 % Boston, MA 02111-1307, USA.
42 
43 
44 if nargin<3; CHAN=0; end;
45 if isempty(CHAN), CHAN = 0; end;
46 if (CHAN<1) | ~isfinite(CHAN),
47  CHAN=0;
48 end;
49 
50 [s,HDR] = sload(FILENAME,CHAN);
51 if nargin>3,
52  if nargin<5, TI2 = TI1(1:2); end;
53  HDR = artifact_selection({HDR,EVENTFILE},TI2);
54 end;
55 
56 H = HDR;
57 TRIG = HDR.TRIG;
58 if isfield(HDR,'ArtifactSelection'),
59  fprintf(1,'TLOAD: Due to Artifact_Selection, %i (out of %i) trials have been removed from %s \n', sum(HDR.ArtifactSelection),length(TRIG),HDR.FileName);
60  TRIG = TRIG(~HDR.ArtifactSelection);
61  if isfield(HDR,'Classlabel');
62  22,
63  H.Classlabel = HDR.Classlabel(~HDR.ArtifactSelection);
64  end;
65  H.ArtifactSelection = zeros(size(TRIG));
66 end;
67 
68 TI1 = TI1*HDR.SampleRate;
69 if length(TI1)<3, TI1(3)=0; end;
70 if HDR.FLAG.TRIGGERED & (any(TI1<1) | any(TI1>HDR.SPR))
71  fprintf(2,'Warning TLOAD: data is already triggered - invalid trigger interval\n');
72  [signal,sz] = trigg(s,TRIG,1,HDR.SPR,TI1(2)-TI1(1)-HDR.SPR+TI1(3));
73  signal = [signal(:,1+end+TI1(1):end),signal(:,1:end+TI1(1))];
74 else
75  [signal,sz] = trigg(s,TRIG,TI1(1),TI1(2),TI1(3));
76 end;
77 signal = signal';
78 
79 H.EVENT = [];
80 H.size = sz([2,3,1]);
81 H.FLAG.TRIGGERED = 1;
82 H.SPR = sz(2);
83 H.DUR = diff(TI1)/H.SampleRate;
84 H.NRec = sz(3);
85 H.TRIG = (0:H.NRec-1)'*H.SPR;
86 
artifact_selection
function artifact_selection(in fn, in t1, in t2)
trigg
function trigg(in s, in TRIG, in pre, in post, in gap)
tload
function tload(in FILENAME, in TI1, in CHAN, in EVENTFILE, in TI2)
sload
function sload(in FILENAME, in varargin)