How can I read local ecg file using wfdb app?
Show older comments
I only have a .dat file (no .hea file) which contains all 12 ecg leads.
I download and configure the wfdb app for matlab.
Then I run the following code,
[signal, fs, tm] = rdsamp('ecgfile.dat');
And then I got the error below,
This is my matlab directory, my .dat file is located in F:\Open ECG file data.

Could anyone help me solve this problem?
regards.
4 Comments
Same problem faced.
Addng the following line in line 91 in rdsamp.m solved my problem, hope it helps yours too.
config.WFDB_PATH = 'C:\yourfolder\mcode\';
'yourfolder' is the folder storing your .dat file.
Only works if data were put directly under the 'mcode' folder created by WFDB.
Pretty messy to store data here though, need better solution...
Susan
on 3 Aug 2022
Thanks for sharing your experience. I'm facing the same issue.
As you suggrested, I have add the following line in line 91 in rdsamp.m file, i.e.,
config.WFDB_PATH = 'C:\User\Desktop\test\mcode\';
All the .dat files are stored in a folder called "test" with the path "C:\User\Desktop\test". In the test folder, I have two more folders called "mcode" and "database" which are generated by wfdb toolbox.
However, I get the following error
Could not find record: test.dat. Search path is set to: 'C:\User\Desktop\test\mcode\'
Any idea how to solve this issue?
Thanks in advance!
Julia Liu
on 4 Aug 2022
In my case,
My .dat file is saved under D:\zMATLAB\WFDB\mcode\
The following test1.m is also saved and ran under D:\zMATLAB\WFDB\mcode\
In rdsamp.m, from line 86 - 94,
persistent javaWfdbExec config
if(isempty(javaWfdbExec))
[javaWfdbExec,config]=getWfdbClass('rdsamp');
end
config.WFDB_PATH = 'D:\zMATLAB\WFDB\mcode\'; %%%%%%% added line
%Set default pararamter values
inputs={'recordName','signalList','N','N0','rawUnits','highResolution'};
outputs={'signal','Fs','tm'};
Susan
on 4 Aug 2022
@Julia Liu Thanks for your through explanation. I made sure the .dat file and test1.m are saved under 'C:\User\Desktop\test\mcode\', However, I still get the same error:
any idea?
Error using rdsamp (line 204)
Could not find record: SE8ECG4E. Search path is set to: 'C:\User\Desktop\test\mcode\'
Answers (2)
Star Strider
on 30 Dec 2020
0 votes
7 Comments
Kevin T
on 31 Dec 2020
Star Strider
on 31 Dec 2020
Edited: Star Strider
on 31 Dec 2020
I can’t get that Physionet ‘rdsamp’ file to run — I get some sort of Java error — so I abandoned the attempt and deleted the entire directory contiaining it and whatever else it depends on. The documentation is almost completely lacking in any sort of useful information.
Physionet used to provide MATLAB ‘.mat’ files that could be imported using load. I have no idea whatever became of that capability, since I can’t find it on the Physionet site (that used to be called ‘Physionet ATM’). I haven’t used Physionet in a few years because of those changes, although I still have several ‘.mat’ files that I use occasionally to test code.
I cannot help you with this, so I will delete my Answer in a few mninutes. I have no idea how to get that file to work. I suggest you ask Physionet about this. Please post whatever solution they offer back here so others can benefit.
EDIT — (31 Dec 2020 at 20:32)
A few minutes ago, I received an e-mail from Tom Pollard at PhysioNet, and am posting the the relevant excerpt of it:
—————
It sounds like you are interested in the Matlab software, which is primarily maintained by Ikaro Silva and Benjamin Moody (https://github.com/ikarosilva/wfdb-app-toolbox). If you have issues with this software, then a good approach would be to raise an issue on the GitHub repository (https://github.com/ikarosilva/wfdb-app-toolbox).
From the error message that you've shown, it looks like there are a couple of things happening:
(1) In your command ([signal, fs, tm] = rdsamp('ecgfile.dat');) the package appears to default to searching online for a file called `ecgfile.dat`, instead of searching locally.
(2) The package is using the incorrect URL (http://physionet.org/physiobank/database) for its online search.
The fixes are:
(1) In your specific case, as the files are local, you could try specifying the file path to your rdsamp argument. e.g. `rdsamp('path/to/file/ecgfile.dat')`. I would suggest avoiding spaces in directory names (e.g. "open_ecg_data" instead of "Open ECG file data") because the spaces can be tricky to work with at the command line.
(2) The Matlab software maintainers should update the hardcoded search URL in the package itself.
The screenshot you have shown mentions the ATM, a web tool that can be used to extract records. This tool is available at: https://archive.physionet.org/cgi-bin/atm/. I'm not sure that the ATM it is really needed in your case. Using the WFDB software should be a more efficient way of parsing .dat files and converting them to .mat format if necessary.
If you are familiar with Python, then you might also consider using the Python WFDB software for working with the dat files. There is an example notebook at: https://github.com/MIT-LCP/wfdb-python/blob/master/demo.ipynb that may be helpful in getting started with this.
Best wishes,
Tom
---
Tom Pollard
MIT Laboratory for Computational Physiology,
Institute for Medical Engineering and Science,
E25-505, 45 Carleton St, Cambridge, MA 02142
—————
Kevin T
on 3 Jan 2021
Star Strider
on 3 Jan 2021
My pleasure!
I forwarded the full email I received on 31 Dec 2020 to MathWorks (what I posted here is a relevant excerpt) and suggested that since so many people use PhysioNet with MATLAB that it would be worth considering some sort of collaboration to make the tools more user-friendly.
I have not yet visited the GitHub section. That might provide more information, since File Exchange and GitHub are in some ways linked.
Susan
on 4 Aug 2022
@Star Strider I am getting the same error as Kevin got. As you suggested, I did ''Use the fullfile function to generate the file name with the correct path, then use that result as the argument for ‘rdsamp’." However still getting the same error. it seems the package defaults to searching online for my .dat file instead of searching locally even though I set the path . Any suggestions? thanks in advance!
Star Strider
on 5 Feb 2024
Mohammed Abdenacer Merbouti
on 5 Feb 2024
Edited: Mohammed Abdenacer Merbouti
on 5 Feb 2024
0 votes
There should be at least the following three issues taken care of:
- The ".dat" file should always have its ".hea" file with it. The header (.hea) file contains plain text and can be easily deduced from the other ".hea" files of similar records.
- You should not pass the full path of the record file to the function "rdsamp".
- For example, let's say your matlab and record files have the following paths:
- F:\Open ECG file data\reader.m
- F:\Open ECG file data\records\rec001.dat
- F:\Open ECG file data\records\rec001.hea
- Then you should call "rdsamp" in the reader.m file as follows:
- [signal, fs, tm] = rdsamp('\records\rec001');
3. The full path of the records should not exceed 256 characters.
Categories
Find more on Bartlett in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!