1 function [datatyp,limits,datatypes,numbits,GDFTYP] =
gdfdatatype(GDFTYP)
2 % GDFDATATYPE converts number into data type according to the definition of the GDF format [1].
4 % [datatyp,limits,datatypes,numbits,GDFTYP]=
gdfdatatype(gdftyp)
7 % See also: SOPEN, SREAD, SWRITE, SCLOSE
10 % [1] A. Schlögl, O. Filz, H. Ramoser, G. Pfurtscheller, GDF - A general dataformat
for biosignals, Technical Report, 2004.
11 % available online at: http:
13 % This program is free software; you can redistribute it and/or
14 % modify it under the terms of the GNU General Public License
15 % as published by the Free Software Foundation; either version 3
16 % of the License, or (at your option) any later version.
18 % $Id:
gdfdatatype.m 2619 2011-02-14 10:25:07Z schloegl $
19 % (C) 1997-2005,2008 by Alois Schloegl <a.schloegl@ieee.org>
20 % This is part of the BIOSIG-toolbox http:
24 GDFTYP = cellstr(GDFTYP);
28 gdftyp = repmat(NaN,size(GDFTYP));
30 if strncmpi(GDFTYP{k},
'char',4)
32 elseif strncmpi(GDFTYP{k},
'int8',4)
34 elseif strncmpi(GDFTYP{k},
'uint8',5)
36 elseif strncmpi(GDFTYP{k},
'int16',5)
38 elseif strncmpi(GDFTYP{k},
'uint16',6)
40 elseif strncmpi(GDFTYP{k},
'int32',5)
42 elseif strncmpi(GDFTYP{k},
'uint32',6)
44 elseif strncmpi(GDFTYP{k},
'int64',5)
46 elseif strncmpi(GDFTYP{k},
'uint64',6)
48 elseif strncmpi(GDFTYP{k},
'float32',7) || strcmp(GDFTYP{k},
'float')
50 elseif strncmpi(GDFTYP{k},
'float64',7) || strcmp(GDFTYP{k},
'double')
52 elseif strncmpi(GDFTYP{k},
'float128',7)
54 elseif strncmpi(GDFTYP{k},
'bit',3)
59 elseif strncmpi(GDFTYP{k},
'ubit',4)
71 limits = repmat(NaN,length(GDFTYP),3);
72 numbits = repmat(NaN,size(GDFTYP));
74 for k=1:length(GDFTYP),
81 limit = [-128,127,128];
89 limit = [-2^15,2^15-1,-2^15];
93 limit = [0,2^16,2^16];
97 limit = [-2^31,2^31-1,-2^31];
101 limit = [0,2^32,2^32];
105 limit = [-2^63,2^63-1,-2^63];
109 limit = [0,2^64,2^64];
113 limit = [-(2-2^-23)*2^127,(2-2^-23)*2^127,NaN];
117 limit = [-realmax,realmax,NaN];
120 datatyp=(
'float128');
121 limit = [-inf,inf,NaN];
123 elseif (GDFTYP(k)>255) && (GDFTYP(k)<512)
124 nbits = GDFTYP(k)-255;
125 datatyp=[
'bit',int2str(nbits)];
126 limit = [-(2^(nbits-1)),2^(nbits-1)-1,-(2^(nbits-1))];
127 elseif (GDFTYP(k)>511) && (GDFTYP(k)<768)
128 nbits = GDFTYP(k)-511;
129 datatyp=[
'ubit',int2str(nbits)];
130 limit = [0,2^nbits,2^nbits];
132 fprintf(2,
'Error GDFREAD: Invalid GDF channel type\n');
134 limit = [NaN,NaN,NaN];
137 datatypes{k} = datatyp;