Skip to content

Deep source modeling (phase 1) - #14130

Open
payamsash wants to merge 3 commits into
mne-tools:mainfrom
payamsash:enh/subcortical-surface-source-space
Open

Deep source modeling (phase 1)#14130
payamsash wants to merge 3 commits into
mne-tools:mainfrom
payamsash:enh/subcortical-surface-source-space

Conversation

@payamsash

Copy link
Copy Markdown
Contributor

Reference issue (if any)

First phase of #14097, also see #6784

What does this implement/fix?

adds setup_subcortical_source_space which should/will support both label (aseg) and surface (e.g coming from CBM).

Additional information

This is just a Proof-of-concept with sample subject.

@payamsash
payamsash requested a review from larsoner as a code owner August 4, 2026 09:40
@payamsash

Copy link
Copy Markdown
Contributor Author

you can test it with this small code snippet:

import mne
from mne.datasets import sample

subjects_dir = sample.data_path() / "subjects"
subject = "sample"

# label
src_label = mne.setup_subcortical_source_space(
    subject, label=["Left-Hippocampus", "Left-Amygdala"], subjects_dir=subjects_dir
)
print(src_label.kind)

# surface (e.g for CBM)
surface = subjects_dir / subject / "surf" / "lh.white"
src_surface = mne.setup_subcortical_source_space(
    subject, surface=surface, subjects_dir=subjects_dir, keep_largest_component=False
)
print(src_surface.kind)

# cortex + subcortical
cortex_src = mne.setup_source_space(
    subject, spacing="oct4", add_dist=False, subjects_dir=subjects_dir, verbose=False
)
mixed = mne.SourceSpaces(list(cortex_src) + list(src_label))
print(mixed.kind)

# quick plot 
brain = mne.viz.Brain(
    subject,
    subjects_dir=subjects_dir,
    hemi="lh",
    surf="white",
    alpha=0.3,
    background="white",
    cortex="low_contrast",
)
brain.add_volume_labels(labels=["Left-Hippocampus", "Left-Amygdala"])

@ttaiv

ttaiv commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Thank you @payamsash! I ran you test code snippet using a cerebellar surface for sample from CMB and it worked well. I created a source space with cerebellum and cortex with mixed = src_surface + cortex_src and was able to plot it with mixed.plot().

Comment thread mne/_fiff/constants.py
FIFF.FIFFV_MNE_SURF_LEFT_HEMI = 101
FIFF.FIFFV_MNE_SURF_RIGHT_HEMI = 102
FIFF.FIFFV_MNE_SURF_MEG_HELMET = 201 # Use this irrespective of the system
FIFF.FIFFV_MNE_SURF_SUBCORTICAL_ID_BASE = 1000 # + aseg value, e.g. hippocampus

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, see this PR. I also added a temp one here: mne/_fiff/tests/test_constants.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants