本文主要是介绍MIT-BIH ECG 心电数据+matlab绘图详解,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
本篇是为了补充MIT-BIH ECG 心电数据的下载和读取图解这篇博客,为大家提供方便。
该篇比较“久远”,所以网站的内容稍微有些改变,参见:
https://www.physionet.org/cgi-bin/atm/ATM
(1)新网站可以直接导出.mat文件,供matlab或Octave使用,以下图为例(当然你也可以尝试其他的内容):
(2)选中后下载相关文件即可:
mat文件当然是数据;
infor里面有储存的信息,如果仅仅有mat文件显然是不行的,因为mat中的数据后面还要处理一下(除非你不想以mV为纵坐标的单位。。)
注释后的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 == 0Name = '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/54425766for 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
elsefor 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}; % baseunits{i} = Infor{5}; % 单位end
endfclose(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) == 1legend(labels{1});
elselegend(labels);
end
xlabel('Time (sec)');
xlim([min(x) max(x)]); % 设置横坐标
end
整个操作其实超级简单,程序也不复杂,数据处理也不复杂,但大概大家缺的应该是资源获取的途径吧。
(3)关于ECG后续会有更新(弄点小波分析、频域分析什么的)。。。
(4)代码和数据见:MIT-BIH ECG 心电数据+matlab绘图详解
版权声明:本文为博主原创文章,未经博主允许不得转载。
这篇关于MIT-BIH ECG 心电数据+matlab绘图详解的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!