TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
stell.m
Go to the documentation of this file.
1 function [POS,HDR] = stell(HDR)
2 % STELL returns file position of signal data files
3 % HDR = stell(HDR)
4 % returns the location of the HDR-signal file position indicator in the specified file.
5 % Position is indicated in Blocks from the beginning of the file. If -1 is returned,
6 % it indicates that the query was unsuccessful;
7 % HDR-struct is a struct obtained by SOPEN.
8 %
9 % HDR.FILE.POS contains the position of the HDR-Identifier in Blocks
10 %
11 % See also: SOPEN, SREAD, SWRITE, SCLOSE, SSEEK, SREWIND, STELL, SEOF
12 
13 
14 % $Id: stell.m 2205 2009-10-27 12:18:15Z schloegl $
15 % (C) 1997-2005,2007 by Alois Schloegl <a.schloegl@ieee.org>
16 % This is part of the BIOSIG-toolbox http://biosig.sf.net/
17 
18 
19 POS = ftell(HDR.FILE.FID);
20 if POS<0,
21  [HDR.ERROR,HDR.ErrNo] = ferror(HDR.FILE.FID);
22  return;
23 end;
24 POS = (POS-HDR.HeadLen)/HDR.AS.bpb;
25 if (POS<0) || (POS>HDR.NRec*HDR.SPR)
26  fprintf(2,'Warning STELL: %s File - invalid file position %i %i\n', HDR.FileName, POS, HDR.FILE.POS);
27 elseif ~isfield(HDR.FILE,'POS')
28  fprintf(2,'Error STELL: format %s not supported',HDR.TYPE);
29 elseif HDR.FILE.POS~=POS,
30  fprintf(2,'Warning STELL: %s File position error %i %i\n', HDR.FileName, POS, HDR.FILE.POS);
31 else
32  HDR.FILE.POS=POS;
33 end;
34 
35 return;
36 
37 % the code below is obsolete
38 
39 if strmatch(HDR.TYPE,{'CTF'}),
40  POS = (POS-HDR.HeadLen)/HDR.AS.bpb;
41  HDR.ERROR = [];
42  HDR.ErrNo = 0;
43 
44  if (HDR.AS.startrec+HDR.AS.numrec)~=POS,
45  fprintf(2,'Warning STELL: File postion error in EDF/GDF/BDF-toolbox.\n')
46  HDR.AS.startrec = POS;
47  end;
48 
49 elseif strmatch(HDR.TYPE,{'AINF','BKR','ISHNE','CNT','EEG','AVG','MIT','RG64','LABVIEW','Nicolet','EGI','SMA','SND','WAV','AIF','CFWB','DEMG','alpha','BCI2000','ET-MEG','Sigma'}),
50  POS = (POS-HDR.HeadLen)/HDR.AS.bpb;
51 
52 elseif strmatch(HDR.TYPE,{'ACQ','AINF','EDF','BDF','EPL','GDF','RDF','SIGIF','BrainVision','EEProbe-CNT','EEProbe-AVR','FIF','native','MFER','TMS32','WG1'}),
53  POS = HDR.FILE.POS;
54 
55 else
56  fprintf(2,'Error STELL: format %s not supported',HDR.TYPE);
57 end;
58 
59 if HDR.FILE.POS~=POS,
60  fprintf(2,'Warning STELL: %s File position error %i %i\n', HDR.FileName, POS, HDR.FILE.POS);
61 end;
62 HDR.FILE.POS=POS;
stell
function stell(in HDR)