mne-tools / mne-python

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

Support fNIRS data with more than two wavelengths (e.g. Shimadzu devices or broadband fNIRS) #9816

Open ryssamoffat opened 2 years ago

ryssamoffat commented 2 years ago

Describe the new feature or enhancement

Support for fNIRS data acquired with three wavelengths, specifically from Shimadzu fNIRS devices.

Describe your proposed implementation

Using mne-python v0.24.dev0 and mne-nirs v0.1.2.dev, read_raw_snirf() will not load fNIRS data with 3 wavelengths (780, 805, 830) and expects only 2 wavelengths. The error message is "NIRS channels not ordered correctly. Channels must be ordered as source detector pairs with alternating frequencies: 780 & 805"

Using previous versions of mne-python (0.21.2) and mne-nirs (v0.0.1), it was possible to load the 3-wavelength data then to use drop_channels() to remove the channels associated with wavelength 830 before proceeding.

Here is some some sample data: sample_shimadzu_data.snirf

Thanks in advance!

welcome[bot] commented 2 years ago

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

larsoner commented 2 years ago

@rob-luke ideas?

rob-luke commented 2 years ago

Thanks Ryssa,

Could you provide a few more pieces of info:


But the report is clear and makes sense to me. Thank you for sharing the data, that enabled me to reproduce the error locally. Currently MNE only supports two wavelength systems. We added additional checks and warnings in the last year, so that is why you now get an error.

We could add support for multi wavelength fNIRS data. This would require a medium amount of effort from someone, primarily in the Beer Lambert conversion to haemoglobin, and updating our sanity checks throughout the functions. The PR would need to have some research done on to how this extra information is usually utilised, I have some guesses, but it should be properly investigated including in literature and comparison to other software packages like Homer.

But if you are happy to simply throw away the third wavelength and use MNE as it is now, then it would be considerably less work to update the SNIRF reader to not assume two wavelengths. If we update the SNIRF reader to read arbitrary number of wavelengths (or let user specify the wavelengths they want) would that be sufficient to start with @ryssamoffat?

ryssamoffat commented 2 years ago

Hi Rob,

Hardware: Shimadzu LightNIRS

Acquisition Software: Shimadzu's own software called "fNIRS", v1.0 (version numbers do not seem to be updated). Data can be exported for use in other software as a TXT file with either with raw intensity (column for each of the 3 wavelengths) or haemoglobin values (columns for HbO, HbR and HbT).

Conversion to SNIRF: Shimadzu provided a script for conversion to NIRS, to which I added the Homer 3 functions to further convert the data to SNIRF. The Shim2Nirs2Snirf.m script requires an SD file with the probe position information. Both can be found here.

Feature request: Added support for multiwavelength fNIRS data would be wonderful. In the mean time, the option to load more than two wavelengths and discard one would be very helpful for setting up pipelines!

Please let me know if you need any more information.

rob-luke commented 2 years ago

Thanks Ryssa for the details,

I think we should add support for processing fNIRS data with an arbitrary number of wavelengths in MNE. Broadband fNIRS was a big topic at the recent fNIRS 2021 conference and will be added to more commercial devices and be utilised by more labs. Adding support for multiple wavelengths in the SNIRF file is definetly the way to go, rather than adding support for each vendor format individually. @ryssamoffat could your team open a pull request to make this change? If not, then I can chip away at it, but with no specific timeline.

A short term pragmatic solution may be to take the haemoglobin concentrations as exported by the vendor software and read them using the instructions at https://mne.tools/dev/auto_tutorials/io/30_reading_fnirs_data.html#custom-data-import (being sure to drop the HbT column).

ryssamoffat commented 2 years ago

Thanks Rob. Unfortunately we won't be able to open a pull request. As for the suggestion to load the haemoglobin concentrations, I'll start with that, thank you!

rob-luke commented 2 years ago

Ok, and I will note in this thread as we make steps towards this goal.