Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: API for subcortical surface source spaces #6784

Open
larsoner opened this issue Sep 18, 2019 · 2 comments
Open

ENH: API for subcortical surface source spaces #6784

larsoner opened this issue Sep 18, 2019 · 2 comments

Comments

@larsoner
Copy link
Member

larsoner commented Sep 18, 2019

It turns out (I think!) you can take just about any subcortical ROI and turn it into a surface using a few FreeSurfer commands:

mri_tessellate aseg.mgz 17 lh.hippocampus.orig
mri_tessellate aseg.mgz 53 rh.hippocampus.orig
mris_extract_main_component lh.hippocampus.orig lh.hippocampus.orig
mris_extract_main_component rh.hippocampus.orig rh.hippocampus.orig
mris_smooth -nw lh.hippocampus.orig lh.hippocampus.smooth
mris_smooth -nw rh.hippocampus.orig rh.hippocampus.smooth

The .smooth surfaces look reasonable for the MNE sample subject:

Screenshot from 2019-08-16 14-50-48

And they can be inflated to a sphere (so that they can be subdivided via ico/oct) with:

mris_inflate -no-save-sulc lh.hippocampus.smooth lh.hippocampus.inflated
mris_inflate -no-save-sulc rh.hippocampus.smooth rh.hippocampus.inflated
mris_sphere -q lh.hippocampus.inflated lh.hippocampus.qsphere
mris_sphere -q rh.hippocampus.inflated rh.hippocampus.qsphere

Here is a starting API proposal:

  1. setup_source_space(..., surf='...') allow surf to be a list/tuple of names in aseg.mgz, not just surf/ files. The default would stay 'white', which is an alias for (as would be pial and other cortical surfaces) ('lh.white', 'rh.white') to create a cortical surface source space.
  2. Currently we use FIFF.FIFFV_MNE_SURF_LEFT_HEMI = 101 for left, 102 for right; maybe we should use 1000+aseg_value for any non-cortical surface, and left/right hemi would keep their "special" / exceptional values of 101 and 102 (their numbers in aseg.mgz appear to be 2 or 3 and 41 or 42)
  3. The .kind for a SourceSpaces with just these surfaces would be not 'surf' (keep this for cortical surf source spaces only) but instead 'subcortical_surf' or something. And combinations of cortical surf + subcortical surf would be, as usual, 'mixed'.
  4. Figure out morphing somehow. In theory we might be able to do this procedure for fsaverage and use FreeSurfer commands to align the surfaces (make .sphere instead of just .qsphere surfaces). Now that make_morph_maps is not horribly slow anymore, creating the morph maps on the fly might be acceptable since these surfaces in general will have way fewer vertices.
  5. Improve plotting to support multiple surfaces.
@larsoner larsoner added this to the 0.20 milestone Sep 18, 2019
@agramfort
Copy link
Member

agramfort commented Sep 18, 2019 via email

@larsoner larsoner added this to To do in woodshole coding sprint (2019) via automation Sep 19, 2019
@larsoner larsoner modified the milestones: 0.20, 0.21 Mar 4, 2020
@larsoner larsoner modified the milestones: 0.21, 0.22 Aug 31, 2020
@larsoner larsoner modified the milestones: 0.22, 0.23 Dec 1, 2020
@larsoner larsoner modified the milestones: 0.23, 0.24 Apr 19, 2021
@larsoner larsoner modified the milestones: 0.24, 0.25 Oct 22, 2021
@larsoner larsoner removed this from the 1.0 milestone Jan 12, 2022
@larsoner
Copy link
Member Author

larsoner commented Nov 3, 2023

From a meeting with @jasmainak it seems like a tentative workable plan is:

  1. Leave subcortical segmentation to a separate Python package for now (it's a hard problem that takes a while to run, so a separate tool makes sense)
  2. Get that package to output FreeSurfer-compatible .surf files to subjects_dir/subject/... somewhere (surf/subcort.lh.*?)
  3. Build source space support for those files using a variant of the API above. Depending on how FreeSurfer-like the outputs are, it might make sense to create a separate mne.setup_subcortical_source_space, e.g., if the spacing parameter no longer makes sense.
  4. Figure out how to support across-subject smoothing using SourceMorph

Good next steps would be:

  • @jasmainak share code with me for segmenting cerebellum with me
  • I run it on sample
  • Examine outputs
  • Try hacking something with mne.setup_source_space from it, then forward, then inverse. Then visualize traces with matplotlib for now

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

No branches or pull requests

2 participants