1 function [POS,HDR] =
stell(HDR)
2 % STELL returns file position of signal data files
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.
9 % HDR.FILE.POS contains the position of the HDR-Identifier in Blocks
11 % See also: SOPEN, SREAD, SWRITE, SCLOSE, SSEEK, SREWIND, STELL, SEOF
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:
19 POS = ftell(HDR.FILE.FID);
21 [HDR.ERROR,HDR.ErrNo] = ferror(HDR.FILE.FID);
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);
37 % the code below is obsolete
39 if strmatch(HDR.TYPE,{
'CTF'}),
40 POS = (POS-HDR.HeadLen)/HDR.AS.bpb;
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;
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;
52 elseif strmatch(HDR.TYPE,{
'ACQ',
'AINF',
'EDF',
'BDF',
'EPL',
'GDF',
'RDF',
'SIGIF',
'BrainVision',
'EEProbe-CNT',
'EEProbe-AVR',
'FIF',
'native',
'MFER',
'TMS32',
'WG1'}),
56 fprintf(2,
'Error STELL: format %s not supported',HDR.TYPE);
60 fprintf(2,
'Warning STELL: %s File position error %i %i\n', HDR.FileName, POS, HDR.FILE.POS);