How can I read a ".dat" and ".hea" file in to MATLAB?

347 次查看(过去 30 天)
Currently i am working on project which use Photo Plythismo Graph (ppg). But the data is in .dat and .hea format.
I am looking a code to get a visualize view of these PPG.
If anyone have any idea about this please add a comment on this post. Your help would be greatly appreciate and it really help my project.
  2 个评论
Diwakar Diwakar
Diwakar Diwakar 2023-5-20
you can use the rdmat and rdann functions from the WFDB Toolbox for MATLAB. Here's an example of how you can load the .dat, .hea, and .atr files:
% Add the WFDB Toolbox for MATLAB to your MATLAB path
addpath('path/to/wfdb-matlab');
% Specify the file paths for the .dat, .hea, and .atr files
datFile = 'path/to/ecg_data.dat';
heaFile = 'path/to/ecg_data.hea';
atrFile = 'path/to/ecg_data.atr';
% Load the .dat file
ecgSignal = rdmat(datFile);
% Load the .hea file to get the sampling frequency
heaInfo = readheader(heaFile);
fs = heaInfo.freq;
% Load the .atr file to get the beat annotations
[~, beatAnnotations] = rdann(heaInfo.recordname, 'atr', 1);
% Perform further processing or analysis with the loaded data
% ...
% Example: Plotting the ECG signal
t = (0:length(ecgSignal)-1) / fs;
figure;
plot(t, ecgSignal);
xlabel('Time (s)');
ylabel('Amplitude');
title('ECG Signal');
% Example: Display beat annotations
disp(beatAnnotations);
Make sure to replace 'path/to/wfdb-matlab', 'path/to/ecg_data.dat', 'path/to/ecg_data.hea', and 'path/to/ecg_data.atr' with the appropriate file paths in your system.
The WFDB Toolbox for MATLAB provides functions to read and process PhysioNet data, including the MIT-BIH Arrhythmia Database files (.dat, .hea, .atr). It allows you to load the ECG signal, extract beat annotations, and perform various signal processing and analysis tasks.
You can download the WFDB Toolbox for MATLAB from the PhysioNet website (https://physionet.org/content/wfdb-app-matlab/). Make sure to follow the installation instructions provided to set up the toolbox in MATLAB.
Note: If you encounter any issues loading the dataset using the rdmat and rdann functions, please ensure that the files are in the correct format and that the toolbox is properly installed and configured in MATLAB.
Indrayudh Datta
Indrayudh Datta 2023-7-11
Hey! I tried running this code on the Online MatLab platform and It keeps throwing the following erros:
Error using rdmat Could not open file: /MATLAB Drive/100.dat.hea !
This happends when I define the file path and mention the file extension as .dat
When I do not mention the file extension and only the file name, I get the following error
Error in rdmat (line 144) load([recordName '.mat']);
Any idea what I am doing wrong?

请先登录,再进行评论。

回答(2 个)

Andrea Nemcova
Andrea Nemcova 2021-9-7
Hello,
I am one of the authors of this database and I am glad you chose the BUT PPG database for your research. May I ask you what is your research dealing with?
More information about the database is included in this brand new article: https://www.hindawi.com/journals/bmri/2021/3453007/ .
The data are in standard WFDB format (very common on Physionet). This format (including .dat and .hea) can be read using WFDB toolbox https://archive.physionet.org/physiotools/matlab/wfdb-app-matlab/ .
I hope this helps. If you have any further question, feel free to ask.
Best regards,
Andrea Nemcova

Monika Jaskolka
Monika Jaskolka 2021-7-4
To import dat files I use the mdfimport tool found on the Matab File Exchange

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by