TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
bni2hdr.m
Go to the documentation of this file.
1 function [HDR]=bni2hdr(arg1,arg3,arg4,arg5,arg6)
2 % BNI2HDR converts BNI header information into BioSig Header information
3 % HDR = BNI2HDR(HDR)
4 %
5 % INPUT:
6 % HDR.H1 contains ascii header
7 %
8 % OUTPUT:
9 % HDR.Label
10 % HDR.T0
11 % ...
12 %
13 % see also: SOPEN
14 
15 % $Id: bni2hdr.m 2205 2009-10-27 12:18:15Z schloegl $
16 % Copyright (c) 2007,2008 by Alois Schloegl <a.schloegl@ieee.org>
17 % This is part of the BIOSIG-toolbox http://biosig.sf.net/
18 
19 % This program is free software; you can redistribute it and/or
20 % modify it under the terms of the GNU General Public License
21 % as published by the Free Software Foundation; either version 3
22 % of the License, or (at your option) any later version.
23 %
24 % This program is distributed in the hope that it will be useful,
25 % but WITHOUT ANY WARRANTY; without even the implied warranty of
26 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 % GNU General Public License for more details.
28 %
29 % You should have received a copy of the GNU General Public License
30 % along with this program; if not, write to the Free Software
31 % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 
33 if isstruct(arg1),
34  HDR=arg1;
35 elseif exist(arg1,'file');
36  HDR.FileName = arg1;
37  [HDR.FILE.Path,HDR.FILE.Name,HDR.FILE.Ext]=fileparts(arg1);
38 end;
39 if ~isfield(HDR,'H1')
40  fid = fopen(fullfile(HDR.FILE.Path,HDR.FILE.Name,'.bni'),'rt');
41  HDR.H1 = char(fread(fid,[1,inf],'uint8'));
42  fclose(fid);
43 end;
44 
45 s = HDR.H1;
46 if ~strcmp(s(1:28),'FileFormat = BNI-1-BALTIMORE')
47  fprintf(HDR.FILE.stderr,'WARNING BNI2HDR: Header information is not Nicolet BNI format.\n');
48 end;
49 
50 while ~isempty(s),
51  [t,s]=strtok(s,[10,13]);
52  [t1,t2]=strtok(t,' =');
53  [t2,t3]=strtok(t2,' =');
54  if strcmp(t1,'PatientId')
55  HDR.Patient.Id = t2;
56  elseif strcmpi(t1,'Sex')
57  HDR.Patient.Sex = t2; % strncmpi(t2,'m',1)+2*strncmpi(t2,'f',1);
58  elseif strncmpi(t1,'medication',10)
59  HDR.Patient.Medication = t2;
60  elseif strncmpi(t1,'diagnosis',10)
61  HDR.Patient.Diagnosis = t2;
62  elseif strcmpi(t1,'MontageRaw')
63  [tmp1,tmp2,HDR.Label] = str2double(t2,',');
64  elseif strcmpi(t1,'Age')
65  HDR.Patient.Age = str2double(t2);
66  elseif strcmp(t1,'Date')
67  if any(t2=='/')
68  t2(t2=='/')=' ';
69  HDR.T0([2,3,1])=str2double(t2);
70  end;
71  elseif strcmp(t1,'Time')
72  t2(t2==':') = ' ';
73  HDR.T0(4:6) = str2double(t2);
74  elseif strcmp(t1,'Rate')
75  HDR.SampleRate = str2double(t2);
76  elseif strcmp(t1,'NchanFile')
77  HDR.NS = str2double(t2);
78  elseif strcmp(t1,'UvPerBit')
79  HDR.Cal = str2double(t2);
80  elseif strcmp(t1,'[Events]')
81  % not supported yet
82  s = [];
83  end;
84 end;
bni2hdr
function bni2hdr(in arg1, in arg3, in arg4, in arg5, in arg6)
str2double
function str2double(in s, in cdelim, in rdelim, in ddelim)