Sunday, June 26, 2016

Convert MIT-BIH Polysomnographic data to mat (Matlab) format

.mat file could be loaded directly into Matlab. But MIT-BIH Polysomnographic data is not a .mat format. although, https://www.physionet.org/cgi-bin/atm/ATM offers a converter that could convert to .mat format, but be careful, it only gives you first 1000000 points, but not all data. So how to convert the whole data file to .mat? Fortunately, the convertion tool "wfdb2mat" is also offered by www.physionet.org. Just go https://www.physionet.org/physiotools/, click "Software Index" https://www.physionet.org/physiotools/software-index.shtml. And find WFDB links
https://www.physionet.org/physiotools/wfdb.shtml, click it. Find "Ready-to-run, precompiled binaries" https://www.physionet.org/physiotools/binaries/. OK, in this page you will find the tool in binary format. I use windows, so I downloaded the windows version.

Here is a command line example:

bin\wfdb2mat -r slpdb/slp14 -f 0 -t 21600  -s 2 >slp14m.info

Make sure you have .hea file along with .dat file. The last command will produce slp14m.mat and other stuffs. slp14m.mat is just you want. Try to load it into matlab:

eegdata = load('slp14m.mat');

All are done!

Post a Comment