資源簡(jiǎn)介
rddata.m -- MIT-BIH ECG 信號(hào)的數(shù)據(jù)讀取Matlab程序.m
代碼片段和文件信息
%?This?programm?reads?ECG?data?which?are?saved?in?format?212.
%?(e.g.?100.dat?from?MIT-BIH-DB?cu01.dat?from?CU-DB...)
%?The?data?are?displayed?in?a?figure?together?with?the?annotations.
%?The?annotations?are?saved?in?the?vector?ANNOT?the?corresponding
%?times?(in?seconds)?are?saved?in?the?vector?ATRTIME.
%?The?annotations?are?saved?as?numbers?the?meaning?of?the?numbers?can
%?be?found?in?the?codetable?“ecgcodes.h“?available?at?www.physionet.org.
%
%?ANNOT?only?contains?the?most?important?information?which?is?displayed
%?with?the?program?rdann?(available?on?www.physionet.org)?in?the?3rd?row.
%?The?4th?to?6th?row?are?not?saved?in?ANNOT.
%
%
%??????created?on?Feb.?27?2003?by
%??????Robert?Tratnig?(Vorarlberg?University?of?Applied?Sciences)
%??????(email:?rtratnig@gmx.at)
%
%??????algorithm?is?based?on?a?program?written?by
%??????Klaus?Rheinberger?(University?of?Innsbruck)
%??????(email:?klaus.rheinberger@uibk.ac.at)
%
%-------------------------------------------------------------------------
clc;?clear?all;
%------?SPECIFY?DATA?------------------------------------------------------
%------?指定數(shù)據(jù)文件?-------------------------------------------------------
PATH=?‘H:\比賽\數(shù)據(jù)1‘;?%?指定數(shù)據(jù)的儲(chǔ)存路徑
HEADERFILE=?‘100.hea‘;??????%?.hea?格式,頭文件,可用記事本打開(kāi)
ATRFILE=?‘100.atr‘;?????????%?.atr?格式,屬性文件,數(shù)據(jù)格式為二進(jìn)制數(shù)
DATAFILE=‘100.dat‘;?????????%?.dat?格式,ECG?數(shù)據(jù)
SAMPLES2READ=2048;??????????%?指定需要讀入的樣本數(shù)
????????????????????????????%?若.dat文件中存儲(chǔ)有兩個(gè)通道的信號(hào):
????????????????????????????%?則讀入?2*SAMPLES2READ?個(gè)數(shù)據(jù)?
%------?LOAD?HEADER?DATA?--------------------------------------------------
%------?讀入頭文件數(shù)據(jù)?-----------------------------------------------------
%
%?示例:用記事本打開(kāi)的117.hea?文件的數(shù)據(jù)
%
%??????117?2?360?650000
%??????117.dat?212?200?11?1024?839?31170?0?MLII
%??????117.dat?212?200?11?1024?930?28083?0?V2
%??????#?69?M?950?654?x2
%??????#?None
%
%-------------------------------------------------------------------------
fprintf(1‘\\n$>?WORKING?ON?%s?...\n‘?HEADERFILE);?%?在Matlab命令行窗口提示當(dāng)前工作狀態(tài)
%?
%?【注】函數(shù)?fprintf?的功能將格式化的數(shù)據(jù)寫(xiě)入到指定文件中。
%?表達(dá)式:count?=?fprintf(fidformatA...)
%?在字符串‘format‘的控制下,將矩陣A的實(shí)數(shù)數(shù)據(jù)進(jìn)行格式化,并寫(xiě)入到文件對(duì)象fid中。該函數(shù)返回所寫(xiě)入數(shù)據(jù)的字節(jié)數(shù)?count。
%?fid?是通過(guò)函數(shù)?fopen?獲得的整型文件標(biāo)識(shí)符。fid=1,表示標(biāo)準(zhǔn)輸出(即輸出到屏幕顯示);fid=2,表示標(biāo)準(zhǔn)偏差。
%
signalh=?fullfile(PATH?HEADERFILE);????%?通過(guò)函數(shù)?fullfile?獲得頭文件的完整路徑
fid1=fopen(signalh‘r‘);????%?打開(kāi)頭文件,其標(biāo)識(shí)符為?fid1?,屬性為‘r‘--“只讀”
z=?fgetl(fid1);?????????????%?讀取頭文件的第一行數(shù)據(jù),字符串格式
A=?sscanf(z?‘%*s?%d?%d?%d‘[13]);?%?按照格式?‘%*s?%d?%d?%d‘?轉(zhuǎn)換數(shù)據(jù)并存入矩陣?A?中
nosig=?A(1);????%?信號(hào)通道數(shù)目
sfreq=A(2);?????%?數(shù)據(jù)采樣頻率
clear?A;????????%?清空矩陣?A?,準(zhǔn)備獲取下一行數(shù)據(jù)
for?k=1:nosig???????????%?讀取每個(gè)通道信號(hào)的數(shù)據(jù)信息
????z=?fgetl(fid1);
????A=?sscanf(z?‘%*s?%d?%d?%d?%d?%d‘[15]);
????dformat(k)=?A(1);???????????%?信號(hào)格式;?這里只允許為?212?格式
????gain(k)=?A(2);??????????????%?每?mV?包含的整數(shù)個(gè)數(shù)
????bitres(k)=?A(3);????????????%?采樣精度(位分辨率)
????zerovalue(k)=?A(4);?????????%?ECG?信號(hào)零點(diǎn)相應(yīng)的整數(shù)值
????firstvalue(k)=?A(5);????????%?信號(hào)的第一個(gè)整數(shù)值?(用于偏差測(cè)試)
end;
fclose(fid1);
clear?A;
%------?LO
評(píng)論
共有 條評(píng)論