Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read_raw_cnt() only raises one type of error #13005

Closed
withmywoessner opened this issue Dec 5, 2024 · 1 comment · Fixed by #13007
Closed

read_raw_cnt() only raises one type of error #13005

withmywoessner opened this issue Dec 5, 2024 · 1 comment · Fixed by #13007
Labels

Comments

@withmywoessner
Copy link
Contributor

Description of the problem

Hello! I have been working with Neuroscan CNT files through MNE again recently and I noticed that some of the exceptions raised were changed in #12792. Here is how it is currently implemented:

  input_fname = path.abspath(input_fname)
        try:
            info, cnt_info = _get_cnt_info(
                input_fname, eog, ecg, emg, misc, data_format, _date_format, header
            )
        except Exception:
            raise RuntimeError(
                "Could not read header from *.cnt file. mne.io.read_raw_cnt "
                "supports Neuroscan CNT files only. If this file is an ANT Neuro CNT, "
                "please use mne.io.read_raw_ant instead."
            )

I was wondering if I could change it to something more robust; that way I can get more specific information if the file I am trying to read doesn't exist or something similar.

Steps to reproduce

mne.io.read_raw_cnt('test.cnt', preload=True, verbose=True) (Use random nonexistent file name)

Link to data

No response

Expected results

No such file or directory: 'test.cnt'

Actual results

RuntimeError: Could not read header from *.cnt file. mne.io.read_raw_cnt supports Neuroscan CNT files only. If this file is an ANT Neuro CNT, please use mne.io.read_raw_ant instead.

Additional information

(I am not sure why it says I am in 1.6.0.dev202+g9b57c5168 instead of 1.8. I can see the latest changes.)

(PySide6=6.7.3)
├☑ ipympl 0.9.4
├☑ pyqtgraph 0.13.7
├☑ mne-qt-browser 0.6.3
├☑ ipywidgets 8.1.5
├☑ trame_client 3.5.0
├☑ trame_server 3.2.3
├☑ trame_vtk 2.8.12
└☑ trame_vuetify 2.7.2

Ecosystem (optional)
├☑ mne-bids 0.15.0
├☑ mne-connectivity 0.5.0
├☑ neo 0.13.4
├☑ eeglabio 0.0.3
├☑ edfio 0.4.5
├☑ mffpy 0.10.0
├☑ pybv 0.7.6
└☐ unavailable mne-nirs, mne-features, mne-icalabel, mne-bids-pipeline

To update to the latest supported release version to get bugfixes and improvements, visit https://mne.tools/stable/install/updating.html

@larsoner
Copy link
Member

larsoner commented Dec 5, 2024

Agreed we should add a got:\n{_explain_exception(...)} or similiar to actually give the underlying exception as well. We have a helper _explain_exception in mne.utils that I think should format the exception nicely. Feel free to add it to #13007 if you want!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants