Closed jrudoler closed 3 years ago
Can you provide some sample code that reproduces the problem and/or a file that reproduces the problem?
Apologies for the long delay.
import pyedflib
# version 0.1.18, but relevant code in the 0.1.22 release is unchanged
print(pyedflib.__version__)
# read in EDF file with 118 channels
# the file itself should not be relevant, I think it's just out of bounds behavior and has nothing to do with with the data itself
pedf = pyedflib.EdfReader('/data/eeg/R1556J_1/behavioral/RepFR1/session_0/elemem/R1556J_1_20210503/eeg_data.edf')
print(f"{pedf.signals_in_file} signals in the file" )
# Try accessing channel 200 when there are only 118
pedf.getLabel(200)
As a results I get the following output:
0.1.18
118 signals in the file
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-43-507333b0de7e> in <module>()
9
10 # Try accessing channel 200 when there are only 118
---> 11 pedf.getLabel(200)
/home1/jrudoler/anaconda3/envs/cml37/lib/python3.7/site-packages/pyedflib/edfreader.py in getLabel(self, chn)
439 return self._convert_string(self.signal_label(chn).rstrip())
440 else:
--> 441 return self._convert_string('')
442
443 def getPrefilter(self,chn):
/home1/jrudoler/anaconda3/envs/cml37/lib/python3.7/site-packages/pyedflib/edfreader.py in _convert_string(self, s)
94 return s.decode("latin")
95 else:
---> 96 return s.decode("utf-8", "strict")
97
98 def getHeader(self):
AttributeError: 'str' object has no attribute 'decode'
have you tried installing the master version? (new release coming soon). there have been some fixes w.r.t that
pip install git+https://github.com/holgern/pyedflib.git
If the problem persists: can you send me a sample file via wetransfer.com, or alternatively if it's confidential send the link to cgkkibhj0rj@temp.mailbox.org so I can have a closer look and write a test case for this exception.
The problem does still persist. Making sure I can send properly anonymized data before following up via email.
If there are only 32 channels, and you want to access channel 200, it makes sense that this throws an error?
However, I changed the error to be more verbose.
It now will throw an IndexError
.
I hope this resolves your problem
For the out of bounds channel condition,
self._convert_string('')
throws the following error:AttributeError: 'str' object has no attribute 'decode'