[ENH] Add adjacency for cortical and volume labels - #14226
Merged
Conversation
raphbrd
requested review from
agramfort,
drammock,
larsoner and
wmvanvliet
as code owners
August 26, 2026 12:46
larsoner
reviewed
Aug 26, 2026
larsoner
left a comment
Member
There was a problem hiding this comment.
Just one tiny efficiency nitpick, otherwise LGTM! Let me know when you push and I'll mark for merge-when-green
wmvanvliet
approved these changes
Aug 26, 2026
larsoner
enabled auto-merge (squash)
August 26, 2026 14:38
Member
|
Member
|
(I'll push a fix) |
|
🎉 Congrats on merging your first pull request! 🥳 Looking forward to seeing more from you in the future! 💪 |
Contributor
|
Thanks @raphbrd! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR description
Fixes #8646
Add two functions in the public API to determine whether labels are adjacent in source spaces:
mne.label_adjacency(labels, src)for surface spaces.mne.volume_label_adjacency(src, subject, subjects_dir, aseg="auto", labels=None)for volumetric spaces.The typical inputs are any surface parcels and segmentation files from the FreeSurfer recon process (e.g., aparc.a2009s+aseg.mgz)
Additional information
Adjacency between labels is defined as having at least one adjacent voxel, based on the source-space adjacency computed using the existing
mne.source_estimate.spatial_src_adjacencyfunction.For the volumetric case, there is currently no dedicated label object. The current workaround is to use a list of surface labels with hemi='lh' by convention. If that's useful, we could add a
VolLabelobject in the future.