MIT-LCP / physionet

A collection of tools for working with the PhysioNet repository.
http://physionet.org/
MIT License
69 stars 17 forks source link

read and convert to .mat for LTSTDB #31

Closed ranxiao closed 7 years ago

ranxiao commented 7 years ago

Hi All,

I have a problem trying to read data from LTSTDB using rdsamp in Matlab. It always returns a "out of memory" error. I have no such trouble reading data from MIT database though.

I also tried the ATM, but it will only returns the first 1 million data points.

Any suggestions and comments are much appreciated!

Thanks, Ran

tompollard commented 7 years ago

I had the same issue a few years ago and ended up processing files in the shell and then reading the data back into Matlab (and then eventually moved to Python). I think this relates to a memory limit in Java Virtual Machine.

ranxiao commented 7 years ago

Thank you Tom for the feedback.

To whom are still interested in using Matlab, one workaround I just found is using following piece of code with some tweaks. https://www.physionet.org/physiotools/matlab/rddata.m

Just switch the first few lines with the following codes since there are some bugs related to text scanning and then save the ECG to .mat in Matlab.

clc; clear all; %------ SPECIFY DATA ------------------------------------------------------ PATH= 'YOU PATH WHERE FILES ARE'; % path, where data are saved HEADERFILE= 's20021.hea'; % header-file in text format ATRFILE= 's20021.atr'; % attributes-file in binary format DATAFILE='s20021.dat'; % data-file

%------ LOAD HEADER DATA -------------------------------------------------- fprintf(1,'\n$> WORKING ON %s ...\n', HEADERFILE); signalh= fullfile(PATH, HEADERFILE); fid1=fopen(signalh,'r'); z= fgetl(fid1); A= sscanf(z, '%s %d %d %d',[1,3]); nosig= A(1); % number of signals sfreq=A(2); % sample rate of data SAMPLES2READ=A(3); % number of samples to be read % in case of more than one signal: % 2SAMPLES2READ samples are read clear A; for k=1:nosig z= fgetl(fid1); A= sscanf(z, '%s %d %d %s %d %d %d'); dformat(k)= A(1); % format; here only 212 is allowed gain(k)= A(2); % number of integers per mV bitres(k)= A(3); % bitresolution zerovalue(k)= A(4); % integer value of ECG zero point firstvalue(k)= A(5); % first integer value of signal (to test for errors) end fclose(fid1); clear A;

ranxiao commented 7 years ago

I finally cracked the puzzle. For those having similar problem, simply go to Matlab setting, under General, select "Java Heap Memory" and increase the memory size!

tompollard commented 7 years ago

Glad to hear you found a solution @ranxiao