1 function [hyp,g1,g2] =
nk2hyp(fn)
2 % NK2HYP extracts the hypnogram from NihonKohden data
7 % hyp hypnogram in
'W1234R' encoding
8 % g hypnogram in 0=W,1,2,3,4,5=R encoding
12 % Copyright (C) 2010 by Alois Schloegl <a.schloegl@ieee.org>
13 % This is part of the BIOSIG-toolbox http:
16 % This program is free software; you can redistribute it and/or
17 % modify it under the terms of the GNU General Public License
18 % as published by the Free Software Foundation; either version 3
19 % of the License, or (at your option) any later version.
21 % This program is distributed in the hope that it will be useful,
22 % but WITHOUT ANY WARRANTY; without even the implied warranty of
23 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 % GNU General Public License
for more details.
26 % You should have received a copy of the GNU General Public License
27 % along with
this program;
if not, write to the Free Software
28 % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 [p,f,e] = fileparts(fn);
33 fn = fullfile(p,[f,
'.dat']);
35 dat = fread(fid,inf,
'uint8');
41 while all(dat(pos+[-1,0])==255)
44 nn = [[1,256]*dat(pos+[1:2]),nn];
46 if (nn(1)~=1) || any(diff(nn)~=1)