%检测QRS波并且保存到文件里面(pan_tompkin, wrann等)

%function [qrspos,qrsnum] = BeatDetAndSaveResult(file_name, ann_name)
% 检测QRS波并且保存到文件里面
% file_name -- 分析文件名
% ann_name  -- 检测结果保存的文件扩展名
% qrspos -- qrs position vector, row vector
% qrsnum -- qrs number, qrsnum= length(qrspos)

clc; clear; close all;
fdir = 'G:\data\physionet-data\MIT\';
cd (fdir);
file_name = '100';
ann_name = 'pan';

% 采样率等信息
[siginfo,Fs] = wfdbdesc(file_name);

% read samples
[sig, fs, tm] = rdsamp(file_name);
plot(tm, sig); grid on;

% 检测通道1的QRS
[qrs_amp_raw,qrs_i_raw,delay] = pan_tompkin(sig(:,1) ,Fs(1,1),1);

% 保存分析结果
Ann = qrs_i_raw ;
Ann = Ann(:);

[Ann,ia,ic] = unique(Ann);
N = length(Ann);


Typ_p(size(Ann)) = 'N';
Typ_p(:) = 'N';
Typ = Typ_p(:);
subtype(size(Ann)) = 0;
chan(size(Ann))  = 0;
num(size(Ann)) = 0;

wrann(file_name,ann_name,Ann,Typ,subtype,chan,num);
[ann,type,subtype,chan,num]=rdann(file_name,ann_name);



qrspos = qrs_i_raw;
qrsnum = length(qrspos);

你可能感兴趣的:(生理信号分析,数据分析)