1 function [signal,H] =
tload(FILENAME,TI1,CHAN,EVENTFILE,TI2)
2 % TLOAD loads and triggers signal data.
4 % [signal,HDR] =
tload(FILENAME, TI, [CHAN,] EVENTFILE, AI)
6 % S = reshape(signal,HDR.size) returns the corresponding 3-dim Matrix
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.
21 % see also: SLOAD, SVIEW, SOPEN, ARTIFACT_SELECTION
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:
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.
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.
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.
44 if nargin<3; CHAN=0; end;
45 if isempty(CHAN), CHAN = 0; end;
46 if (CHAN<1) | ~isfinite(CHAN),
50 [s,HDR] =
sload(FILENAME,CHAN);
52 if nargin<5, TI2 = TI1(1:2); end;
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');
63 H.Classlabel = HDR.Classlabel(~HDR.ArtifactSelection);
65 H.ArtifactSelection = zeros(size(TRIG));
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))];
75 [signal,sz] =
trigg(s,TRIG,TI1(1),TI1(2),TI1(3));
83 H.DUR = diff(TI1)/H.SampleRate;
85 H.TRIG = (0:H.NRec-1)'*H.SPR;