I have a collection of EDF files containing EEG signal data. I am using pyedflib
to access the files, however I am frequently having difficulty reading signals from some of the files. Basically, there are a number of files for which I get arrays of all 0s when I try to read the signal values. Given:
def get_sig(fname):
import pyedflib
f=pyedflib.EdfReader(fname)
file_dur=f.getFileDuration()
fs=int(inFile.getSignalHeader(0)['sample_rate'])
chan_names=f.getSignalLabels()
#note... channel names and file duration are captured correctly
sig=f.readSignal(4)
return sig
This returns an array of length 'file_dur' * 'fs', however the result is an array of all 0's and the following warning is displayed:
read -1, less than 8965120 requested!!!
Does anyone have any ideas what could cause a problem like this? Unfortunately, I can't share any of the data as it is PHI, but if there is any additional information that could be helpful just ask.
A couple extra notes:
- I have also tried
sig=f.readSignal(4,start=0,n=100)
to make sure that it isn't a problem with the beginning of the file or anything of the sort and it returns an array of all 0s of length 100. - The values are correct when I examine them in Matlab (i.e. non-zero).
- The problem appears to be file specific (some are processed correctly while others are not), however I can't find any differences between the files other than the actual signal values
- The index 4 used in
f.readSignal(4)
is not hardcoded in my full application, this is simply for demonstration purposes (in my example files, 4 corresponds to EEG channel F4).
Thanks!
P.S. I'm adding this to the pyedflib wiki as well.