Skip to content

Overflow Error with read_raw_cnt reader #13547

@teonbrooks

Description

@teonbrooks

Description of the problem

Hi team,

I'm reading a Neuroscan file (cnt) and I have run into an error with the reader. I'm getting an OverflowError as seen below. I did some digging and I came across an issue in the past that seems very similar to this one (#12907).

It looks like it has something to do with numpy's move to v2. I was able to get the file to read when downgrading numpy==1.26.4, and it worked with mne==1.11.0.

Steps to reproduce

To reproduce, you will need numpy>=2.


import mne


raw = mne.io.read_raw_cnt("945flankers_ready.cnt")

Link to data

https://huggingface.co/datasets/jalauer/Gruendler2009/blob/main/data/945flankers_ready.cnt

Expected results

>>> raw
<RawCNT | 945flankers_ready.cnt, 66 x 1166162 (2332.3 s), ~587.3 MiB, data loaded>

Actual results

OverflowError                             Traceback (most recent call last)
File ~/miniforge3/envs/neuralset/lib/python3.12/site-packages/mne/io/cnt/cnt.py:545, in RawCNT.__init__(self, input_fname, eog, misc, ecg, emg, data_format, date_format, header, preload, verbose)
    544 try:
--> 545     info, cnt_info = _get_cnt_info(
    546         input_fname, eog, ecg, emg, misc, data_format, _date_format, header
    547     )
    548 except Exception:

File ~/miniforge3/envs/neuralset/lib/python3.12/site-packages/mne/io/cnt/cnt.py:346, in _get_cnt_info(input_fname, eog, ecg, emg, misc, data_format, date_format, header)
    345 if data_format == "auto":
--> 346     if n_samples == 0 or data_size // (n_samples * n_channels) not in [2, 4]:
    347         warn(
    348             "Could not define the number of bytes automatically. "
    349             "Defaulting to 2."
    350         )

OverflowError: Python integer 8922283537 out of bounds for int32

Additional information

In [2]: mne.sys_info()
Platform             Linux-5.15.0-1061-nvidia-x86_64-with-glibc2.35
Python               3.12.11 | packaged by conda-forge | (main, Jun  4 2025, 14:45:31) [GCC 13.3.0]
Executable           /private/home/teonbrooks/miniforge3/envs/neuralset/bin/python3.12
CPU                  Intel(R) Xeon(R) Gold 6230 CPU @ 2.10GHz (80 cores)
Memory               754.5 GiB

Core
├☒ mne               1.9.0 (outdated, release 1.11.0 is available!)
├☑ numpy             2.3.2 (OpenBLAS 0.3.30 with 80 threads)
├☑ scipy             1.16.1
└☑ matplotlib        3.10.5 (backend=agg)

Numerical (optional)
├☑ sklearn           1.7.1
├☑ numba             0.63.1
├☑ nibabel           5.3.2
├☑ pandas            2.3.2
├☑ h5py              3.14.0
└☐ unavailable       nilearn, dipy, openmeeg, cupy, h5io

Visualization (optional)
└☐ unavailable       pyvista, pyvistaqt, vtk, qtpy, ipympl, pyqtgraph, mne-qt-browser, ipywidgets, trame_client, trame_server, trame_vtk, trame_vuetify

Ecosystem (optional)
├☑ mne-bids          0.16.0
├☑ pybv              0.7.6
└☐ unavailable       mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline, neo, eeglabio, edfio, mffpy

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions