资源简介
MIT-BIH ECG 心电数据(1min,具体信息里面有,像采样率什么的),里面有mat文件;
plotSTM可以用来matlab绘图;
程序有详解;
代码片段和文件信息
%% usage: plotATM(‘RECORDm‘)
% This function reads a pair of files (RECORDm.mat and RECORDm.info) generated
% by ‘wfdb2mat‘ from a PhysioBank record baseline-corrects and scales the time
% series contained in the .mat file and plots them. The baseline-corrected
% and scaled time series are the rows of matrix ‘val‘ and each
% column contains simultaneous samples of each time series.
%
% ‘wfdb2mat‘ is part of the open-source WFDB Software Package available at
% http://physionet.org/physiotools/wfdb.shtml
% If you have installed a working copy of ‘wfdb2mat‘ run a shell command
% such as
% wfdb2mat -r 100s -f 0 -t 10 >100sm.info
% to create a pair of files (‘100sm.mat‘ ‘100sm.info‘) that can be read
% by this function.
%
% The files needed by this function can also be produced by the
% PhysioBank ATM at
% http://physionet.org/cgi-bin/ATM
%
function h = plotATM(Name)
if nargin == 0
Name = ‘100m‘;
end
%% 读取数据
infoName = strcat(Name ‘.info‘);
matName = strcat(Name ‘.mat‘);
Octave = exist(‘OCTAVE_VERSION‘);
load(matName); % 采样值变量的名字为val
fid = fopen(infoName ‘rt‘);
fgetl(fid); % 第一行
fgetl(fid); % 第二行
fgetl(fid); % 第三行
[freqint] = sscanf(fgetl(fid) ‘Sampling frequency: %f Hz Sampling interval: %f sec‘); % 得到采样频率和采样间隔
interval = freqint(2); % 取采样间隔
fgetl(fid); % 第五行
if(Octave) % 一种软件:http://blog.csdn.net/Forlogen/article/details/54425766
for i = 1:size(val 1)
R = strsplit(fgetl(fid) char(9));
signal{i} = R{2};
gain(i) = str2num(R{3});
base(i) = str2num(R{4});
units{i} = R{5};
end
else
for i = 1:size(val 1)
Infor = textscan(fgetl(fid)‘%d%s%f%f%s‘‘delimiter‘‘\t‘);
row = Infor{1};
signal{i} = Infor{2}; % 导联名称
gain(i) = Infor{3}; % 增益
base(i) = Infor{4}; % base
units{i} = Infor{5}; % 单位
end
end
fclose(fid);
%% 数据处理并作图
val(val==-32768) = NaN;
for i = 1:size(val 1)
val(i :) = (val(i :) - base(i)) / gain(i); % 转化为mV
end
x = (1:size(val 2)) * interval; % 采样时间
plot(x‘ val‘);
for i = 1:length(signal)
labels{i} = strcat(signal{i}‘(‘ units{i}‘)‘);
end
if length(signal) == 1
legend(labels{1});
else
legend(labels);
end
xlabel(‘Time (sec)‘);
xlim([min(x) max(x)]); % 设置横坐标
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-11-30 15:56 ECG\
文件 312 2017-11-30 15:56 ECG\100m.info
文件 43224 2017-11-30 15:56 ECG\100m.mat
文件 2383 2017-11-30 15:56 ECG\plotATM.asv
文件 2419 2017-11-30 15:56 ECG\plotATM.m
评论
共有 条评论