Error reading cnt file.

  • MNE version: 1.8.0
  • Operating System: macOS 15
  • Python version: 3.12

Upon trying to read a cnt file using mne.io.read_raw_cnt(file_path, data_format='int32', preload=True), I get the following error. I have made sure that this is not because of a bad file, as the same error occurs with plenty other files.

samps = samps.reshape((n_chunks, f_channels, channel_offset), order=β€œC”)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: cannot reshape array of size 2665278 into shape (390625,64,1)

I do understand that to reproduce the error, one will need the file and I will be happy to send it over.

Observations:

  • The error occurs during the data load. i.e. with preload=False the error only occurs when raw.load_data() is called.
  • No error when calling raw.get_data(start=0, stop=100) (for small stop values)

Is this a bug? or am I doing something wrong?

This does sound like a bug, but before submitting a new issue, do you know which software produced the files? You’re saying that the issue is not likely caused by a bad file, but there are cases where a program exports files that do not follow the format specifications. Therefore, it would be helpful if you checked if other tools can load your data, such as BioSig (pip install biosig should work at least on Windows; if you are on macOS or Linux, see their install instructions).

And just to make sure, there are two different file formats which use the .cnt extension, namely Neuroscan and ANT Neuro. The function mne.io.read_raw_cnt() reads the former, whereas you need mne.io.read_raw_ant() for the latter (this will be available in the next release).

I believe the file was produced by Neuroscan. I did not try using other tools.
But what I did was parse the file using Kaitai by defining the structure with the help of Various EEG file formats and Conventions. I could successfully parse the whole file including all the metadata. So I am sure that the file is good.

I also found out that MNE version 1.3.0 does not produce an error. (I do not know which version caused the break)

Moreover, I could not find mne.io.read_raw_ant, was this deprecated?

Alright, since it did work in MNE 1.3 it is very likely a bug. Could you please open an issue? Also, read_raw_cnt() is the correct function to read a Neuroscan file; read_raw_ant() (which will be available in MNE 1.9) reads ANT Neuro files (which also happen to have the .cnt extension).

1 Like