You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I installed mne and mne-nirs, and I have some nirs file like "1.nirs"
I use raw_intensity = mne.io.read_raw_nirx('1.nirs', verbose=True), and there is OSError: Need a directory for fname but found a file at ".......\1.nirs".
Can you help me how to read my nirs file? and I want to use function mne.preprocessing.nirs.scalp_coupling_index with the raw data.
The OSError: Need a directory for fname but found a file... error is a very common issue when reading NIRx data.
The Problem:
The function mne.io.read_raw_nirx() is designed to read the parent directory that contains all the NIRx files (like .nirs, .hdr, etc.). It should not be given the path to a single file like 1.nirs.
The Fix:
Instead of passing the file path:
# This will cause an errorraw=mne.io.read_raw_nirx("/path/to/1.nirs")
Pass the folder path that contains the NIRx files:
Alternative:
If your data is in a different fNIRS format (like SNIRF), you may need to use a different reader function such as mne.io.read_raw_snirf().
In principle we could try to be smart enough to use .parent in the case that .is_file() passes. But I think the error message we have is okay and this is more of a usage issue so I'll close. But if someone wants to improve the docs that's welcome!
Thanks for the feedback, @larsoner! I'd be happy to help improve the docs to make this clearer for users.
I could add a note to the read_raw_nirx docstring or the fNIRS tutorial clarifying that:
The function expects a directory path, not a file path
Common error messages and their solutions
Would a PR adding this clarification be welcome? I can work on it!
Activity
drammock commentedon Jul 28, 2025
What device/software was used to record the data? Did you read through https://mne.tools/dev/auto_tutorials/io/30_reading_fnirs_data.html?
sachinu25 commentedon Aug 2, 2025
If your file is from another vendor (e.g., Hitachi, SNIRF, etc.), use the matching function:
SNIRF: mne.io.read_raw_snirf('file.snirf')
Hitachi: mne.io.read_raw_hitachi('file.csv')
natinew77-creator commentedon Dec 7, 2025
Hi, I can help with this!
The
OSError: Need a directory for fname but found a file...error is a very common issue when reading NIRx data.The Problem:
The function
mne.io.read_raw_nirx()is designed to read the parent directory that contains all the NIRx files (like.nirs,.hdr, etc.). It should not be given the path to a single file like1.nirs.The Fix:
Instead of passing the file path:
Pass the folder path that contains the NIRx files:
Alternative:
If your data is in a different fNIRS format (like SNIRF), you may need to use a different reader function such as
mne.io.read_raw_snirf().Reference:
For more details, you can refer to the MNE-Python tutorial on Importing data from fNIRS devices.
I hope this helps!
larsoner commentedon Dec 11, 2025
In principle we could try to be smart enough to use
.parentin the case that.is_file()passes. But I think the error message we have is okay and this is more of a usage issue so I'll close. But if someone wants to improve the docs that's welcome!natinew77-creator commentedon Dec 11, 2025
Thanks for the feedback, @larsoner! I'd be happy to help improve the docs to make this clearer for users.
I could add a note to the read_raw_nirx docstring or the fNIRS tutorial clarifying that:
The function expects a directory path, not a file path
Common error messages and their solutions
Would a PR adding this clarification be welcome? I can work on it!
DOC: Clarify read_raw_nirx expects directory path, not file path
DOC: Clarify read_raw_nirx expects directory path, not file path