# \[fNIRS\] Group analysis

**URL:** <https://mne.discourse.group/t/fnirs-group-analysis/2231>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [June 24, 2020, 8:40am UTC](https://mne.discourse.group/t/fnirs-group-analysis/2231 "2020-06-24T08:40:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 24, 2020, 8:40am UTC](https://mne.discourse.group/t/fnirs-group-analysis/2231/1 "2020-06-24T08:40:21Z")

</div>

External Email - Use Caution

Hello ladies and gentlemen,

I already checked for the matter in the mailing list archive and searched through the code, but couldn't find what I was hoping for.  
Is there a suite of tools/library to perform group analysis with Epoch/Raw instances?

Let me clarify. I can already perform data analysis/conversion for one dataset concerning one performance of an experiment. I would like to either directly perform such processing for a group of datasets, or use the converted data (i.e. the Epochs) of several datasets to obtain one single figure of haemodynamic response. I encountered several difficulties to analyze Epochs from several since the channels would be "duplicated" as they exist for the first and the second Epochs sets, leading to obvious errors.

Sorry if I missed the thread where it has been discussed, and thanks in advance,

David  
-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20200624/5afc84f7/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20200624/5afc84f7/attachment.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 24, 2020, 9:41am UTC](https://mne.discourse.group/t/fnirs-group-analysis/2231/2 "2020-06-24T09:41:41Z")

</div>

External Email - Use Caution

hi David,

what you mean by group analysis? can you be more specific?  
GLM style analysis?

Alex

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 24, 2020, 10:17am UTC](https://mne.discourse.group/t/fnirs-group-analysis/2231/3 "2020-06-24T10:17:29Z")

</div>

External Email - Use Caution

Hmmm. I'm really sorry, I don't quite know the specific terms for data analysis. To get some context, I'm part of the tech team in our lab : I'm not the one analyzing data, but I provide tools to others to do so (they're not devs, and some are not even scientists per se - they study cognition, but more at a functional level).

SO. From what I've understood, they would like to show a corellation between the performance of a precise action and haemodynamic changes. As of today, they use the Homer2/3 libraries along with MATLAB, but we would like to move on to open source projects.

They used a NIRSport to get the relevant raw data, which I can process using the fNIRS library, but only one at a time. What I would like to get, is the ability to :  
1. convert the data from each performance of the experiment into an Epoch  
2. squash the results into one single usable object  
3. process this object, if needed  
4. get figures with the average haemodynamic response of the group

Now I could obviously create an Epoch list after processing each set, but then comes the question of \*averaging\* the results. I tried to use the epoch.add\_channels method to have one Epoch object, but then the other methods (such as epoch.plot\_image) break because channels are duplicated.

Hope it is clearer,

David

> De: "Alexandre Gramfort" \<alexandre.gramfort at inria.fr\>  
> ?: "mne\_mailing\_list" \<mne\_analysis at nmr.mgh.harvard.edu\>  
> Envoy?: Mercredi 24 Juin 2020 11:41:41  
> Objet: Re: [Mne\_analysis] [fNIRS] Group analysis

> External Email - Use Caution

> hi David,

> what you mean by group analysis? can you be more specific?  
> GLM style analysis?

> Alex

> > External Email - Use Caution

> > Hello ladies and gentlemen,

> > I already checked for the matter in the mailing list archive and searched  
> > through the code, but couldn't find what I was hoping for.  
> > Is there a suite of tools/library to perform group analysis with Epoch/Raw  
> > instances?

> > Let me clarify. I can already perform data analysis/conversion for one dataset  
> > concerning one performance of an experiment. I would like to either directly  
> > perform such processing for a group of datasets, or use the converted data  
> > (i.e. the Epochs) of several datasets to obtain one single figure of  
> > haemodynamic response. I encountered several difficulties to analyze Epochs  
> > from several since the channels would be "duplicated" as they exist for the  
> > first and the second Epochs sets, leading to obvious errors.

> > Sorry if I missed the thread where it has been discussed, and thanks in advance,

> > David  
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > Mne\_analysis mailing list  
> > Mne\_analysis at nmr.mgh.harvard.edu  
> > [Mne\_analysis Info Page](https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis)
> 
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> Mne\_analysis mailing list  
> Mne\_analysis at nmr.mgh.harvard.edu  
> [Mne\_analysis Info Page](https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis)

-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20200624/8d2229cb/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20200624/8d2229cb/attachment.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 24, 2020, 3:45pm UTC](https://mne.discourse.group/t/fnirs-group-analysis/2231/4 "2020-06-24T15:45:05Z")

</div>

External Email - Use Caution

> They used a NIRSport to get the relevant raw data, which I can process  
> using the fNIRS library, but only one at a time.

In MNE you should be able to read these directly with read\_raw\_nirx  
\<[https://mne.tools/dev/generated/mne.io.read\_raw\_nirx.html&gt;\](https://mne.tools/dev/generated/mne.io.read_raw_nirx.html&gt;%5C).

> 1. convert the data from each performance of the experiment into an Epoch

2. squash the results into one single usable object

> 3. process this object, if needed  
> 4. get figures with the average haemodynamic response of the group

Can you look at the fNIRS tutorial  
\<[Page Redirection](https://mne.tools/dev/auto_tutorials/preprocessing/plot_70_fnirs_processing.html#sphx-glr-auto-tutorials-preprocessing-plot-70-fnirs-processing-py&gt);  
to see if it clears up how you would process a single subject's data? From  
there, you can look into tutorials on how to combine data across subjects,  
which are the same for MEG, EEG, and NIRS data in MNE (so you can look at  
the MEG/EEG tutorials for ideas). There is also the experimental  
[GitHub - mne-tools/mne-nirs: Process Near-Infrared Spectroscopy Data in MNE](https://github.com/mne-tools/mne-nirs/) repository where experimental APIs  
are being developed, but it sounds like you won't need these (e.g., GLM).

Now I could obviously create an Epoch list after processing each set, but

> then comes the question of \*averaging\* the results. I tried to use the  
> epoch.add\_channels method to have one Epoch object, but then the other  
> methods (such as epoch.plot\_image) break because channels are duplicated.

Sounds like you probably want epochs.average() to get trial-averaged  
(Evoked) results for each subject, then use grand\_average  
\<[https://mne.tools/dev/generated/mne.grand\_average.html&gt](https://mne.tools/dev/generated/mne.grand_average.html&gt); to average across  
all participants.

Eric  
-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20200624/9f64b4b4/attachment-0001.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20200624/9f64b4b4/attachment-0001.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [June 25, 2020, 9:03am UTC](https://mne.discourse.group/t/fnirs-group-analysis/2231/5 "2020-06-25T09:03:57Z")

</div>

External Email - Use Caution

Alright things start to get clearer. I'll double-check the other tutorials to see what I can do, but I do think that epoch.average() and grand\_average() are what I'm looking for. Thanks !

Have a good day,

David

> De: "Eric Larson" \<larson.eric.d at gmail.com\>  
> ?: "mne\_mailing\_list" \<mne\_analysis at nmr.mgh.harvard.edu\>  
> Envoy?: Mercredi 24 Juin 2020 17:45:05  
> Objet: Re: [Mne\_analysis] [fNIRS] Group analysis

> External Email - Use Caution

> > They used a NIRSport to get the relevant raw data, which I can process using the  
> > fNIRS library, but only one at a time.

> In MNE you should be able to read these directly with [  
> [mne.io.read\_raw\_nirx — MNE 1.7.0.dev17+g20174f448 documentation](https://mne.tools/dev/generated/mne.io.read_raw_nirx.html) | read\_raw\_nirx ] .

> > 1. convert the data from each performance of the experiment into an Epoch

> > 2. squash the results into one single usable object  
> > 3. process this object, if needed  
> > 4. get figures with the average haemodynamic response of the group

> Can you look at the [  
> [Page Redirection](https://mne.tools/dev/auto_tutorials/preprocessing/plot_70_fnirs_processing.html#sphx-glr-auto-tutorials-preprocessing-plot-70-fnirs-processing-py)  
> \> fNIRS tutorial ] to see if it clears up how you would process a single  
> subject's data? From there, you can look into tutorials on how to combine data  
> across subjects, which are the same for MEG, EEG, and NIRS data in MNE (so you  
> can look at the MEG/EEG tutorials for ideas). There is also the experimental [  
> [GitHub - mne-tools/mne-nirs: Process Near-Infrared Spectroscopy Data in MNE](https://github.com/mne-tools/mne-nirs/) | [GitHub - mne-tools/mne-nirs: Process Near-Infrared Spectroscopy Data in MNE](https://github.com/mne-tools/mne-nirs/)  
> ] repository where experimental APIs are being developed, but it sounds like  
> you won't need these (e.g., GLM).

> > Now I could obviously create an Epoch list after processing each set, but then  
> > comes the question of \*averaging\* the results. I tried to use the  
> > epoch.add\_channels method to have one Epoch object, but then the other methods  
> > (such as epoch.plot\_image) break because channels are duplicated.

> Sounds like you probably want epochs.average() to get trial-averaged (Evoked)  
> results for each subject, then use [  
> [mne.grand\_average — MNE 1.7.0.dev17+g20174f448 documentation](https://mne.tools/dev/generated/mne.grand_average.html) | grand\_average ] to  
> average across all participants.

> Eric

> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> Mne\_analysis mailing list  
> Mne\_analysis at nmr.mgh.harvard.edu  
> [Mne\_analysis Info Page](https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis)

-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20200625/358fde2f/attachment-0001.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20200625/358fde2f/attachment-0001.html)
