MIT-BIH ECG plot ECG data Detailed + matlab

Benpian to complement the download MIT-BIH ECG ECG data and graphic reading this blog, to provide convenience for everyone.

The article comparing "old", so the content of the site is slightly changed, see:
https://www.physionet.org/cgi-bin/atm/ATM

(1) The new site can be exported directly .mat file for matlab or Octave using the following figure as an example (of course, you can also try other content):
Web Content

(2) When you select a file to download:
Downloads
mat data file, of course;
Infor information stored inside, if there are only a mat file is clearly not enough, because the data behind the mat had to deal with it (unless you do not want to mV as ordinate units ..)

After the Notes matlab code:

%% 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

In fact, the whole operation super simple, not complicated procedures, data processing is not complicated, but we probably lack of resources should be the way to get it.

(3) there will be follow-up on ECG update (get some wavelet analysis , frequency domain analysis or something). . .

(4) See code and data: the MIT-BIH ECG data the ECG plot Detailed + matlab

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed.

Published 14 original articles · won praise 19 · views 30000 +

Guess you like

Origin blog.csdn.net/qq_24694761/article/details/78677321