?? scpopen.m
字號(hào):
function [HDR]=scpopen(HDR,PERMISSION,arg3,arg4,arg5,arg6)
% SCPOPEN reads SCP-ECG files
%
% HDR = scpopen(Filename,PERMISSION);
%
% HDR contains the Headerinformation and internal data
%
% see also: SOPEN, SREAD, SSEEK, STELL, SCLOSE, SWRITE, SEOF
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
% $Revision: 1.11 $
% $Id: scpopen.m,v 1.11 2004/07/02 16:17:02 schloegl Exp $
% (C) 2004 by Alois Schloegl
% a.schloegl@ieee.org
% This is part of the BIOSIG-toolbox http://biosig.sf.net/
if nargin<1, PERMISSION='rb'; end;
VER = version;
fid = fopen(HDR.FileName,PERMISSION,'ieee-le');
if ~isempty(findstr(PERMISSION,'r')), %%%%% READ
HDR.FILE.CRC = fread(fid,1,'uint16');
HDR.FILE.Length = fread(fid,1,'uint32');
HDR.data = [];
DHT = [0,1,-1,2,-2,3,-3,4,-4,5,-5,6,-6,7,-7,8,-8,9,-9;0,1,5,3,11,7,23,15,47,31,95,63,191,127,383,255,767,511,1023]';
prefix = [1,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,10,10];
%PREFIX = [0,4,5,12,13,28,29,60,61,124,125,252,253,508,509,1020,1021,1022,1023];
PREFIX = [0,4,5,12,13,28,29,60,61,124,125,252,253,508,509,1020,1021,1022,1023]'.*2.^[32-prefix]';
codelength = [1,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,18,26];
mask = [1,7,7,15,15,31,31,63,63,127,127,255,255,511,511,1023,1023,1023,1023]'.*2.^[32-prefix]';
%MASK = dec2bin(mask);
%mask = [1,7,7,15,15,31,31,63,63,127,127,255,255,511,511,1023,1023,1023,1023]';
mask2 = [1,7,7,15,15,31,31,63,63,127,127,255,255,511,511,1023,1023,1023,1023]';
PREFIX2 = DHT(:,2);
HT19999 = [prefix',codelength',ones(length(prefix),1),DHT];
HT = [prefix',codelength',ones(length(prefix),1),DHT];
dd = [0:255]';
ACC = zeros(size(dd));
c = 0;
for k2 = 1:8,
ACC = ACC + (dd>127).*(2^c);
dd = mod(dd*2, 256);
c = c + 1;
end;
K = 0;
section.CRC = fread(fid,1,'uint16');
while ~feof(fid)
pos = ftell(fid);
section.ID = fread(fid,1,'uint16');
section.Length = fread(fid,1,'uint32');
section.Version = fread(fid,[1,2],'uint8');
section.tmp = fread(fid,[1,6],'uint8');
K = K + 1;
HDR.Section{K} = section;
if section.ID==0,
for k = 1:((section.Length-16)/10),
HDR.Block(k).id = fread(fid,1,'uint16');
HDR.Block(k).length = fread(fid,1,'uint32');
HDR.Block(k).startpos = fread(fid,1,'uint32');
end;
elseif section.ID==1,
tag = 0;
k1 = 0;
while tag~=255,
tag = fread(fid,1,'uchar');
len = fread(fid,1,'uint16');
field = fread(fid,[1,len],'uchar');
if tag == 0,
HDR.Patient.LastName = char(field);
elseif tag == 1,
HDR.Patient.FirstName = char(field);
elseif tag == 2,
HDR.Patient.ID = char(field);
elseif tag == 3,
HDR.Patient.LastName2 = char(field);
elseif tag == 4,
HDR.Patient.Age = str2double(char(field(1:2)));
tmp = field(3);
if tmp==0, unit=' ';
elseif tmp==1, unit='Y';
elseif tmp==2, unit='M';
elseif tmp==3, unit='W';
elseif tmp==4, unit='d';
elseif tmp==5, unit='h';
end;
HDR.Patient.AgeUnit = unit;
elseif tag == 5,
% HDR.Patient.DateOfBirth = [field(1:2)*[1;256],field(3:4)];
elseif tag == 6,
HDR.Patient.Height = field(1:2)*[1;256];
tmp = field(3);
if tmp==0, unit=' ';
elseif tmp==1, unit='cm';
elseif tmp==2, unit='inches';
elseif tmp==3, unit='mm';
end;
HDR.Patient.HeightUnit = unit;
elseif tag == 7,
HDR.Patient.Weight = field(1:2)*[1;256];
tmp = field(3);
if tmp==0, unit=' ';
elseif tmp==1, unit='kg';
elseif tmp==2, unit='g';
elseif tmp==3, unit='pound';
elseif tmp==4, unit='ounce';
end;
HDR.Patient.WeightUnit = unit;
elseif tag == 8,
HDR.Patient.Sex = field;
elseif tag == 9,
HDR.Patient.Race = field;
elseif tag == 10,
HDR.Patient.Medication = field;
elseif tag == 11,
HDR.Patient.BloodPressure.Systolic = field*[1;256];
elseif tag == 12,
HDR.Patient.BloodPressure.Diastolic = field*[1;256];
elseif tag == 13,
HDR.Patient.Diagnosis = char(field);
elseif tag == 14,
HDR.SCP1.AcquiringDeviceID = char(field);
elseif tag == 15,
HDR.SCP1.AnalyisingDeviceID = char(field);
elseif tag == 16,
HDR.SCP1.AcquiringInstitution = char(field);
elseif tag == 17,
HDR.SCP1.AnalyzingInstitution = char(field);
elseif tag == 18,
HDR.SCP1.AcquiringDepartment = char(field);
elseif tag == 19,
HDR.SCP1.AnalyisingDepartment = char(field);
elseif tag == 20,
HDR.SCP1.Physician = char(field);
elseif tag == 21,
HDR.SCP1.LatestComfirmingPhysician = char(field);
elseif tag == 22,
HDR.SCP1.Technician = char(field);
elseif tag == 23,
HDR.SCP1.Room = char(field);
elseif tag == 24,
HDR.SCP1.Emergency = field;
elseif tag == 25,
HDR.T0(1,1:3) = [field(1:2)*[1;256],field(3:4)];
elseif tag == 26,
HDR.T0(1,4:6) = field(1:3);
elseif tag == 27,
HDR.Filter.HighPass = field(1:2)*[1;256]/100;
elseif tag == 28,
HDR.Filter.LowPass = field(1:2)*[1;256]/100;
elseif tag == 28,
HDR.Filter.BitMap = field;
elseif tag == 30,
HDR.SCP1.FreeText = char(field);
elseif tag == 31,
HDR.SCP1.ECGSequenceNumber = char(field);
elseif tag == 32,
HDR.SCP1.MedicalHistoryCodes = char(field);
elseif tag == 33,
HDR.SCP1.ElectrodeConfigurationCodes = field;
elseif tag == 34,
HDR.SCP1.Timezone = field;
elseif tag == 35,
HDR.SCP1.MedicalHistory = char(field);
elseif tag == 255,
% section terminator
end;
end;
elseif section.ID==2, % Huffman tables
HDR.SCP2.NHT = fread(fid,1,'uint16');
HDR.SCP2.NCT = fread(fid,1,'uint16');
if HDR.SCP2.NHT~=19999,
NHT = HDR.SCP2.NHT;
else
NHT = 0;
end;
k3 = 0;
for k1 = 1:NHT,
for k2 = 1:HDR.SCP2.NCT,
tmp = fread(fid,3,'uint8') ;
HDR.SCP2.prefix = tmp(1);
HDR.SCP2.codelength = tmp(2);
HDR.SCP2.TableModeSwitch = tmp(3);
tmp(4) = fread(fid,1,'int16');
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -