python-neo
python-neo copied to clipboard
ZeroDivisionError - Unable to read an older Micromed file--test file needed
Describe the bug
Get a ZeroDivisionError when trying to read a micromed .trc file via MicromedIO(file_path).read(). The same file can be read with Wonambi (another python package) as wonambi.Dataset(file_path).
To Reproduce The error traceback is as follows.
Traceback (most recent call last):
File ".venv/lib/python3.11/site-packages/marimo/_runtime/executor.py", line 141, in execute_cell
exec(cell.body, glbls)
....
trc = MicromedIO(file_path).read()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.11/site-packages/neo/io/micromedio.py", line 13, in __init__
BaseFromRaw.__init__(self, filename)
File ".venv/lib/python3.11/site-packages/neo/io/basefromrawio.py", line 77, in __init__
self.parse_header()
File ".venv/lib/python3.11/site-packages/neo/rawio/baserawio.py", line 211, in parse_header
self._parse_header()
File ".venv/lib/python3.11/site-packages/neo/rawio/micromedrawio.py", line 176, in _parse_header
self._t_starts.append(seg_start / self._sampling_rate)
~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
ZeroDivisionError: float division by zero
Expected behaviour
The file should have been read. Based on the error, the ZeroDivisionError maybe caused by self._sampling_rate being 0 when it is read in the MicromedRawIO file as self._sampling_rate = float(np.unique(signal_channels["sampling_rate"])[0]).
But, I am able to access the sampling frequency in Wonambi as follows (it comes out to be 512 btw).
trc = wonambi.Dataset(file_path)
trc.header["s_freq"]
Environment:
- OS: Linux
- Python 3.11
- Neo 0.15.0.dev0 (the latest main branch)
- NumPy 2.2.5