mne-tools / mne-python

MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
https://mne.tools
BSD 3-Clause "New" or "Revised" License
2.72k stars 1.32k forks source link

Problem converting NIRx fNIRS data #12390

Open mkleemeyer opened 9 months ago

mkleemeyer commented 9 months ago

Dear experts, We are trying to convert NIRx fNIRS data using MNE-BIDS mainly following the extremely nice documentation https://mne.tools/mne-bids/stable/auto_examples/convert_nirs_to_bids.html (thanks for that!!). However, when trying to write_raw_bids, we get an error saying 'head' coordinate frame must contain nasion and left and right pre-auricular point landmarks, and its missing the nasion. Attempting to solve this, we came across mne.io.read_raw_nirx, which seems to read the (meta)data correctly. However, because we do not specify the file extension, the write function fails because Found no extension for raw file, assuming "BTi" format and appending extension .pdf. So it seems that I can either read in the data via mne.io.read_raw_snirf but then the meta data is incomplete or I can use mne.io.read_raw_nirx but then the write function fails because I cannot specify the file extension. This is the first fNIRS dataset we are converting though, so we are very likely not getting something... Do you have any advise on how to handle this?

welcome[bot] commented 9 months ago

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

sappelhoff commented 9 months ago

Hi!

To call write_raw_bids you need to pass a raw object. How do you obtain this raw object in the first place, if not using mne.io.read_raw_nirx?

I assume you have NIRX data?

I would suggest:

  1. read your NIRX data with mne-python
  2. write your NIRX data (without changes) to SNIRF with mne-nirs
  3. read the SNIRF data and convert to BIDS with mne-bids

See here for the NIRX->SNIRF conversion: https://mne.tools/mne-nirs/stable/auto_examples/general/plot_19_snirf.html

mkleemeyer commented 9 months ago

Thank you, @sappelhoff for the quick reply! I guess the tricky thing is, that even when using NIRx, we do get a .snirf file (among many others). So we obtained the raw object, by using mne.io.read_raw_snirf in the first place, which does work, only that the metadata are not complete. The way you suggested obviously works and makes much more sense:) Thanks once again!

drammock commented 9 months ago

This issue should be migrated to the mne-python repo so we can fix the fact that the landmark isn't read correctly... Unless the problem is that the landmark simply cannot be stored in the snirf file format (or it's a failure of the nirx device software that it is not included)?

sappelhoff commented 9 months ago

The way you suggested obviously works and makes much more sense

glad you have something that works for now!

This issue should be migrated to the mne-python repo so we can fix the fact that the landmark isn't read correctly

Thanks for chiming in @drammock, I agree that it'd be nice to fix this.

is that the landmark simply cannot be stored in the snirf file format

I don't know the SNIRF format in detail, but it would really surprise me if the format is at fault, as storing a NASION landmark is quite standard.

or it's a failure of the nirx device software that it is not included

possibly 🤔 I can't really say.

feel free to migrate this issue!

mkleemeyer commented 9 months ago

I understood from my colleague that we only have this issue, because we used quite an old NIRx device. So it may potentially never happen again, because with newer devices the format is different (corrected?). Not sure it is worth spending the effort...

PuddleJumper2018 commented 9 months ago

I understood from my colleague that we only have this issue, because we used quite an old NIRx device. So it may potentially never happen again, because with newer devices the format is different (corrected?). Not sure it is worth spending the effort...

In my opinion, it isn't the fault of the device (our NS2 is barely 12 months old) but the acquisition software - the Aurora version 2021.9.2 which we used for the experiment. I've got this version from NIRx support as we had issues with version compatibility. During analysis when loading the subject data I got the following warning: RuntimeWarning: MNE has not been tested with Aurora version 2021.9.0-12-g59d389a5-dirty raw = mne.io.read_raw_nirx(sub_folder, verbose=True) Since there's a new release of Aurora that is supposed to be BIDS compatible I guess that may not be an issue in the future?

larsoner commented 9 months ago

Since there's a new release of Aurora that is supposed to be BIDS compatible I guess that may not be an issue in the future?

Maybe but it would be good to get things working for you! So whether it's a one-off hack you all can use vs a proper fix in MNE-Python we'll have to see, but sharing a problematic file somehow (Dropbox?) would help. To add a proper fix to MNE-Python if it's possible for you to make a tiny recording (like 1-5 s) with your system and share the file we could add it to mne-testing-data and make it part of our regression testing.

I agree this is a MNE-Python bug so I'll transfer

welcome[bot] commented 9 months ago

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴