mne-tools / mne-python

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

MNE Python for fNIRS? #3539

Closed mcaffini closed 8 years ago

mcaffini commented 8 years ago

Hi all,

I successfully tested some of the MNE Python methods and classes in my fNIRS data processing workflow. I wonder if anyone else is interested in this and whether it's worth to write some code in this direction. I can also swallow the bitter pill and keep labeling my fNIRS data as "eeg", but maybe we could seize the day to start something useful. Happy to share more of what I did if needed.

Let's discuss it! :-)

larsoner commented 8 years ago

I see no problem with asking to add a fNIRS channel type to the FIF tags and making the appropriate adjustments in our code. @agramfort @jaeilepp do you agree?

larsoner commented 8 years ago

@mcaffini do you have some small data file that you can share? What format is it?

jaeilepp commented 8 years ago

Sure, why not.

larsoner commented 8 years ago

Can you ask the Neuromag folks?

agramfort commented 8 years ago

fine with me.

mcaffini commented 8 years ago

Dear all, sorry for the late reply. @Eric89GXL I use the ISS Imagent. fNIRS raw data come from different technologies (continuous wave, frequency domain, time domain) and each instruments has its own format, but they all eventually get transformed into oxyhemoglobin (HbO) and deoxyhemoglobin (HbR) concentrations (this transformation process is different for different technologies). Maybe we skip this step and we directly start from a numpy array containing the concentrations? This way we would only need two tags like fNIRS-HbO and fNIRS-HbR...

jaeilepp commented 8 years ago

Maybe we skip this step and we directly start from a numpy array containing the concentrations?

Sounds reasonable. We probably don't want to provide the 'preprocessing' steps for this transformation anyway.

jaeilepp commented 8 years ago

Actually, it sounds like we would need a tag for fNIRS channel type and for two units (HbO and HbR). Am I right?

mcaffini commented 8 years ago

What do you mean with unit? If you have in mind each channel having two independent tracks/signals (HbO and HbR), that sounds good!

larsoner commented 8 years ago

Physical units, preferably of the SI variety -- for EEG it's V (commonly viewes as uV) and for MEG it's T and T/m (more commonly viewed as fT / fT/cm).

mcaffini commented 8 years ago

OK, then for fNIRS is molar concentration (M=mol/l=mol/dm3, usually as μM, proper SI unit would be mol/m3). Each channel gives two independent signals (HbO and HbR) with the same unit (μM). How do we refer to each one separately?

jaeilepp commented 8 years ago

Ok, yeah. I'm thinking that maybe we need just one channel type with two kinds (like we have with MEG channels mag and grad). Makes sense? Although it might be the easier to have just two types. Not sure which is better.

mcaffini commented 8 years ago

One type with two kinds makes more sense to me. That way you can pick all HbO with 'hbo', all HbR with 'hbr', or both with 'fnirs' (no caps to be consistent with the other tags?), the same way you pick magnetometers with 'mag', gradiometers with 'grad', ... or everything MEG with 'meg'. Adding total hemoglobin (HbT or hbt) is trivial (but not necessary) being the algebraic sum of HbO and HbR.

In http://martinos.org/mne/stable/generated/mne.pick_types.html would it look like this?

[...] meg : bool or string If True include all MEG channels. If False include None. If string it can be 'mag', 'grad', 'planar1' or 'planar2' to select only magnetometers, all gradiometers, or a specific type of gradiometer.

fnirs: bool or string If True include all fNIRS channels. If False include None. If string it can be 'hbo', 'hbr', 'hbt' to select only oxyhemoglobin, deoxyhemoglobin, or total hemoglobin (algebraic sum of hbo and hbr). [...]

agramfort commented 8 years ago

yes that sounds good to me

agramfort commented 8 years ago

@jaeilepp what did we converge on regarding fif constants?

jaeilepp commented 8 years ago

No response from Elekta yet.

jaeilepp commented 8 years ago

Here they are:

fnirs_hbo 300  "FNIRS oxyhemoglobin"
fnirs_hbr 301  "FNIRS deoxyhemoglobin"
fnirs 1100 "Functional near-infrared spectroscopy"
FIFF.FIFFV_FNIRS_CH     = 1100
agramfort commented 8 years ago

cool

thx @jaeilepp

let's get this merged

agramfort commented 7 years ago

@mcaffini there is a new public dataset with EEG + NIRS:

https://www.depositonce.tu-berlin.de/handle/11303/6271

maybe a good way to have a first example of NIRS with MNE?

mcaffini commented 7 years ago

Thanks @agramfort very interesting, I'll give it a shot. I have completed my fNIRS analysis with MNE and I have also coded the source space reconstruction using a Monte Carlo method for the forward solution. Still interested in a tutorial for the MNE website?

dengemann commented 7 years ago

Yes, this sounds really cool. Go for it!

On Sat, Apr 15, 2017 at 6:30 AM Matteo Caffini notifications@github.com wrote:

Thanks @agramfort https://github.com/agramfort very interesting, I'll give it a shot. I have completed my fNIRS analysis with MNE and I have also coded the source space reconstruction using a Monte Carlo method for the forward solution. Still interested in a tutorial for the MNE website?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mne-tools/mne-python/issues/3539#issuecomment-294285017, or mute the thread https://github.com/notifications/unsubscribe-auth/AB0fikyOd7OhQNVnt9zU_pSM7qC7QnNPks5rwJwogaJpZM4JvR-h .

agramfort commented 7 years ago

Thanks @agramfort https://github.com/agramfort very interesting, I'll give it a shot. I have completed my fNIRS analysis with MNE and I have also coded the source space reconstruction using a Monte Carlo method for the forward solution. Still interested in a tutorial for the MNE website?

I don't know about the forward code I would to see it but basic raw data viz would already be neat I think.

mcaffini commented 7 years ago

I prepared a Jupyter notebook tutorial with basic fNIRS data analysis, here. Of course comments and suggestions are more then welcome. :-)

agramfort commented 7 years ago

we cannot really comment code with a rendered notebook

could be done with public data available from a website so we can write a data fetcher? maybe not start from a custom .mat file which generates a lot of boiler plate code which clutters the example/tutorial

mcaffini commented 7 years ago

@agramfort the notebook as well as the npy file with data should be downloadable for testing from my repo. The provided dataset comes from my lab and is real data, but we can change dataset and fetch it online, no problem. Btw, I don't see any boilerplate code (apart from numpy.load :-D).

agramfort commented 7 years ago

can you make a tutorial script in a PR so we can comment line by line?