Skip to content

[fNIRS] Misleading error message when the raw_data path does not exist #7913

@swy7ch

Description

@swy7ch

Describe the bug

When the path provided by the user does not exist (i.e. when the directory does not exist), the error message raised by the RAWNirx __init__ function is

RuntimeError: Expect one evt file, got 0

I think it should be something like

RuntimeError: The path you specified does not exist

since the error is not about the existence of a file, but rather about the directory's

Steps to reproduce

Create a RAWNirx instance by reading the data of a non-existent directory :

fnirs_raw_dir = 'a/path/that/doesnt/exist'

raw_intensity = mne.io.read_raw_nirx(fnirs_raw_dir,
                                         verbose=True).load_data()

Expected results

The error message tells the user the path to the specified directory does not exist.

Actual results

The error message tells the user the specified directory lacks an *.evt file (since it is the first file extension that is checked) but not that the directory does not exist: the existence of the directory is not checked, which is misleading the user.

Additional information

Platform: Windows-10-10.0.18362-SP0
Python: 3.8.3 (default, May 19 2020, 06:50:17) [MSC v.1916 64 bit (AMD64)]
Executable: C:\Users\juliend\Anaconda3\envs\mne_dev\python.exe
CPU: Intel64 Family 6 Model 58 Stepping 9, GenuineIntel: 8 cores
Memory: 15.6 GB

mne: 0.21.dev0
numpy: 1.18.1 {blas=mkl_rt, lapack=mkl_rt}
scipy: 1.4.1
matplotlib: 3.1.3 {backend=Qt5Agg}

sklearn: 0.22.1
numba: 0.49.1
nibabel: 3.1.0
cupy: Not found
pandas: 1.0.3
dipy: 1.1.1
mayavi: 4.7.2.dev0
pyvista: 0.25.3
vtk: 9.0.0
PyQt5: 5.9.2

--

Please note that adding

if not op.exists(fname):
    raise RuntimeError('The path you specified does not exist.')

or

if not op.isdir(fname):
    raise RuntimeError('The path you specified does not exist.')

at the start of __init function of RAWNirx does not [EDIT: see this comment] lead to raising the error, if fname is a non-existent path; there must be a "good" reason for that. I'm in to correct the behaviour if you think it should be fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions