# Pipelines for Mouse Data Analysis in MNE-Python

**URL:** <https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414>\
**Category:** Support & Discussions\
**Tags:** ﻿source-localization, eeg, visualization\
**Created:** [March 3, 2024, 4:13am UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414 "2024-03-03T04:13:07Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Davi1990](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@Davi1990](https://mne.discourse.group/u/Davi1990)\
**Post date:** [March 3, 2024, 4:13am UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/1 "2024-03-03T04:13:07Z")

</div>

Dear MNE-Python Community,

I am currently engaged in analyzing EEG mouse data and I would like to use MNE-Python as usual. I wanted to reach out to see if there are existing pipelines or modules that could potentially streamline my workflow. Before reinventing the wheel, I’d like to explore any available resources within the MNE-Python ecosystem that could expedite my data analysis process.

Thank you in advance for your assistance and support.

Dave

---

<div class="post-metadata">

**Author:** ![Nab8338](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/nab8338/32/3405_2.png) [@Nab8338](https://mne.discourse.group/u/Nab8338)\
**Post date:** [March 4, 2024, 10:12am UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/2 "2024-03-04T10:12:11Z")

</div>

Hello,

These are some well-known EEG processing pipelines that are fully automated (although parameterizable):  
MNE-BIDS-Pipeline: [MNE-BIDS-Pipeline](https://mne.tools/mne-bids-pipeline/stable/)  
PREP pipeline: [pyprep.PrepPipeline — pyprep 0.4.3+7.ge4840d9 documentation](https://pyprep.readthedocs.io/en/latest/generated/pyprep.PrepPipeline.html)

Hope that helps

---

<div class="post-metadata">

**Author:** ![Davi1990](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@Davi1990](https://mne.discourse.group/u/Davi1990)\
**Post date:** [March 5, 2024, 2:29am UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/3 "2024-03-05T02:29:45Z")

</div>

I know this pipeline! Not sure what do you mean with this suggestions…is there a surface-based reconstruction of mouse brain?

---

<div class="post-metadata">

**Author:** ![Nab8338](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/nab8338/32/3405_2.png) [@Nab8338](https://mne.discourse.group/u/Nab8338)\
**Post date:** [March 5, 2024, 9:40am UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/4 "2024-03-05T09:40:43Z")

</div>

If you are not just looking for pipelines or modules to expedite eeg processing, but tools to find inverse solution and work directly on the sources then there are the MNE tutorials (putting them here in case you don’t know them):  
[https://mne.tools/stable/auto\_tutorials/forward/index.html](https://mne.tools/stable/auto_tutorials/forward/index.html)  
[https://mne.tools/stable/auto\_tutorials/inverse/index.html](https://mne.tools/stable/auto_tutorials/inverse/index.html)

I’ve also found MNE-Connectivity’s examples and tutorials useful and well done:

[https://mne.tools/mne-connectivity/stable/auto\_examples/mixed\_source\_space\_connectivity.html](https://mne.tools/mne-connectivity/stable/auto_examples/mixed_source_space_connectivity.html)

[https://mne.tools/mne-connectivity/stable/auto\_examples/mne\_inverse\_label\_connectivity.html](https://mne.tools/mne-connectivity/stable/auto_examples/mne_inverse_label_connectivity.html)

Their first part (before calculating connectivity) typically illustrates ways of solving the inverse problem with MNE-python.

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [March 5, 2024, 12:02pm UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/5 "2024-03-05T12:02:03Z")

</div>

@Nab8338 To my understanding, @Davi1990 is looking for assistance specifically to process mouse, not human, data.

I don’t think MNE-Python is of much use there for anything other than sensor-space analysis.

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![Nab8338](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/nab8338/32/3405_2.png) [@Nab8338](https://mne.discourse.group/u/Nab8338)\
**Post date:** [March 5, 2024, 1:01pm UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/6 "2024-03-05T13:01:34Z")

</div>

Oh sorry my own coffee-less brain missed the most important word in the question. Indeed. I don’t know anything either using mne-python to do source localization in the mouse brain, good luck in your quest.

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [March 5, 2024, 4:12pm UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/7 "2024-03-05T16:12:56Z")

</div>

> [@richard](#):
>
> I don’t think MNE-Python is of much use there for anything other than sensor-space analysis.

I generally agree, though if one did have mouse BEM meshes and a mouse source space from some other software (and electrode locations), in principle our inverse code could still work? Though there are a few assumptions about the BEM layers that are based on human anatomy that might need to be hacked (e.g., IIRC “outer skin” is computed from “outer skull” as a fixed offset distance normal to the skull surface; that distance probably differs in mice)

---

<div class="post-metadata">

**Author:** ![Davi1990](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@Davi1990](https://mne.discourse.group/u/Davi1990)\
**Post date:** [March 5, 2024, 5:48pm UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/8 "2024-03-05T17:48:13Z")

</div>

> [@drammock](#):
>
> I generally agree, though if one did have mouse BEM meshes and a mouse source space from some other software (and electrode locations), in principle our inverse code could still work? Though there are a few assumptions about the BEM layers that are based on human anatomy that might need to be hacked (e.g., IIRC “outer skin” is computed from “outer skull” as a fixed offset distance normal to the skull surface; that distance probably differs in mice)

Thank you for your response. That’s exactly what I was considering, but I wanted to ensure I wasn’t reinventing the wheel. I appreciate your clarification on the potential challenges with adapting BEM meshes and source space from other software for mouse models. I will keep you in the loop and please let me know if anything else comes to your mind

---

<div class="post-metadata">

**Author:** ![Davi1990](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@Davi1990](https://mne.discourse.group/u/Davi1990)\
**Post date:** [March 13, 2024, 4:25pm UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/9 "2024-03-13T16:25:40Z")

</div>

Just wanted to drop you a quick update on the project. I’ve managed to snag some 3D surface models of the mouse brain and skull, all in .obj format. No skin this time since we placed the electrodes directly on the skull after lifting the scalp.

Now comes the fun part: figuring out how to whip up BEM, src objects, and .surf files (for FreeSurfer).

Your insights would be super helpful

Thanks

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [March 13, 2024, 7:02pm UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/10 "2024-03-13T19:02:47Z")

</div>

> [@Davi1990](#):
>
> I’ve managed to snag some 3D surface models of the mouse brain and skull, all in .obj format. No skin this time since we placed the electrodes directly on the skull after lifting the scalp.

[this tutorial](https://mne.tools/stable/auto_tutorials/forward/80_fix_bem_in_blender.html) talks about using blender to edit `.obj` files and export them in a format that is useable by MNE-Python. I suspect you will run into problems having only a 2-layer BEM though; @larsoner will probably know off the top of his head if that will crash / where to adjust MNE-Python code to accommodate it.

---

<div class="post-metadata">

**Author:** ![larsoner](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/larsoner/32/3_2.png) [@larsoner](https://mne.discourse.group/u/larsoner)\
**Post date:** [March 14, 2024, 3:52pm UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/11 "2024-03-14T15:52:13Z")

</div>

I don’t think the forward code in MNE-Python was meant to solve this sort of problem. It seems more like something OpenMEEG was designed for ☹

---

<div class="post-metadata">

**Author:** ![nikhil777shingte](https://avatars.discourse-cdn.com/v4/letter/n/9de0a6/32.png) [@nikhil777shingte](https://mne.discourse.group/u/nikhil777shingte)\
**Post date:** [March 16, 2024, 8:49pm UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/12 "2024-03-16T20:49:56Z")

</div>

Hi @Davi1990 , I am also currently looking into processing eeg data using mne python that we have collected from mouse. Could you please let me know if you have any success in this ? Thanks.

---

<div class="post-metadata">

**Author:** ![Davi1990](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@Davi1990](https://mne.discourse.group/u/Davi1990)\
**Post date:** [March 16, 2024, 9:20pm UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/13 "2024-03-16T21:20:45Z")

</div>

Hi @nikhil777shingte thanks for your message. My data has been already preprocessed actually. So I am mainly looking for source modelling here. Let me know if you want to connect to explore this further

---

<div class="post-metadata">

**Author:** ![nikhil777shingte](https://avatars.discourse-cdn.com/v4/letter/n/9de0a6/32.png) [@nikhil777shingte](https://mne.discourse.group/u/nikhil777shingte)\
**Post date:** [March 16, 2024, 11:07pm UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/14 "2024-03-16T23:07:07Z")

</div>

That would be super helpful. Could you please send me email to [shingte777nikhil@gmail.com](mailto:shingte777nikhil@gmail.com), and we can connect from there.

---

<div class="post-metadata">

**Author:** ![loresalm](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/loresalm/32/3014_2.png) [@loresalm](https://mne.discourse.group/u/loresalm)\
**Post date:** [March 19, 2024, 11:50am UTC](https://mne.discourse.group/t/pipelines-for-mouse-data-analysis-in-mne-python/8414/15 "2024-03-19T11:50:06Z")

</div>

Hey @Davi1990 Thank you for the update, and for starting this discussion.  
If you want to convert a .obj file into a .surf file you can use the following code:

```python
import mne

obj_file_path = "path/to/file.obj"
verts, faces = surf_dict = mne.read_surface(obj_file_path, file_format='obj')

surf_file_path = "path/to/surface.surf"
mne.write_surface(surf_file_path, verts, faces, overwrite=True, file_format="freesurfer")

```

I have recently looked into MNE source localization because I wanted to use a 4-layer BEM (in humans).  
After a lot of trial and error, I reached the following conclusions:

- It is possible to adapt the BEM model’s source code to make BEM models with any number of layers.

- As long as the BEM model is made correctly the inverse/forward solution will work. You need to remove all the if statements that check if the BEM model has exactly 3 layers.

- It’s unclear to me why MNE forces the users to have exactly 3 layers even if the mathematical model used to make the source localization works with any number of layers. For more information about the model I found this line of the [Source code](https://github.com/mne-tools/mne-python/blob/maint/1.6/mne/bem.py#L83) that points to [this article](https://ieeexplore.ieee.org/document/256433)

I also take the chance to point to these two questions that are related to the topic but haven’t been answered at the moment:

- [BEM with more than 3 layers](https://mne.discourse.group/t/eeg-source-localization-bem-model-with-more-than-3-surfaces/7497)
- [IP skipping layer](https://mne.discourse.group/t/head-model-and-forward-computation-skipping-layer-and-ip-approach/8006)

Good luck with your project and keep us updated with your progress.
