Skip to content

how to read my own nirs file with MNE? #13353

Description

@shijian97

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.

Activity

  1. drammock commented on Jul 28, 2025

    @drammock
    Member

    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?

  2. sachinu25 commented on Aug 2, 2025

    @sachinu25

    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')

  3. natinew77-creator commented on Dec 7, 2025

    @natinew77-creator
    Contributor

    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 like 1.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 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!

  4. larsoner commented on Dec 11, 2025

    @larsoner
    Member

    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!

  5. natinew77-creator commented on Dec 11, 2025

    @natinew77-creator
    Contributor

    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!

  6. added a commit that references this issue on Dec 11, 2025
    aa218f7
  7. added a commit that references this issue on Dec 25, 2025
    48b5755
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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