Repository navigation
how to read my own nirs file with MNE? #13353
Description
Activity
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?
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')
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 functionmne.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:# This will cause an error raw = mne.io.read_raw_nirx("/path/to/1.nirs")
Pass the folder path that contains the NIRx files:
# Correct usage raw = mne.io.read_raw_nirx("/path/to/nirx_data_folder/")
Alternative:
If your data is in a different fNIRS format (like SNIRF), you may need to use a different reader function such asmne.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!
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!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!- added a commit that references this issue
on Dec 11, 2025 - added a commit that references this issue
on Dec 25, 2025
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_indexwith the raw data.