Skip to content

Using surface source spaces with SourceSpaces.export_volume writes out all possible surface vertices #7886

Closed

Description

@susamerz

Describe the bug

Not necessarily a bug, but unexpected behaviour (at least for me):
Writing out surface source spaces from a mixed source space using export_volume always writes out the full list of vertices in the surface used to create the source space, not the vertices that are "inuse", i.e. sources. Is this intentional? If yes, would it be sensible to include an option to write only source vertices in use?

Steps to reproduce

'''
data_path = mne.datasets.sample.data_path()
subjects_dir = f'{data_path}/subjects'
spacing = 'ico2'
n_jobs=1
sphere = (0,0,0,0.12)
surf_src = mne.setup_source_space('fsaverage', spacing=spacing,
subjects_dir=subjects_dir,
n_jobs=n_jobs, add_dist=False)
lh_cereb= mne.setup_volume_source_space("fsaverage", mri=file_path+"/fsaverage/mri/aseg.mgz", sphere=sphere,
volume_label="Left-Cerebellum-Cortex", sphere_units="m")
rh_cereb= mne.setup_volume_source_space("fsaverage", mri=file_path+"/fsaverage/mri/aseg.mgz", sphere=sphere,
volume_label="Right-Cerebellum-Cortex", sphere_units="m")
src=surf_src + lh_cereb + rh_cereb
nii_name=file_path+"/MNESource_cm2.nii"
src.export_volume(nii_name, mri_resolution=True, use_lut=False, overwrite=True)

'''

Expected results

When exporting surface source spaces along with volumetric ones I would expect it to export only the surface vertices that are in use, and label voxels within the volume that do not coincide with the location of a source vertex that is in use as background/ 0

Actual results

When exporting surface sources along with volume sources the full vertex list gets written, regardless of how many vertices are in use

Activity

  1. agramfort commented on Jun 10, 2020

    @agramfort
    SponsorMember
  2. larsoner commented on Jun 10, 2020

    @larsoner
    Member

    Just looks to me like mis-translation of code 6 years ago, and these functions are rarely used so it has been missed...

  3. larsoner commented on Jun 10, 2020

    @larsoner
    Member

    Hmm, it might actually be because the vertices are quite difficult to see if you only include the ones in the source space. Also it creates an inconsistency with mri_resolution=True because the volume vertices will occupy the entire volume. But I think that's probably actually a bug, and it should only "color in" the voxels at the locations of the vertices, not the entire space that that voxel represents in the low-resolution / higher-spacing/zooms MRI.

  4. larsoner commented on Jun 10, 2020

    @larsoner
    Member

    Basically the question is, in mri_resolution=True, which voxels should be colored in? I would say "only those closest to where the vertex is in 3-space", but currently the answer is "all voxels in the regions represented by the low-resolution MRI and decimated surface meshes".

  5. larsoner commented on Jun 10, 2020

    @larsoner
    Member

    (I'm going to add a mri_resolution="sparse" option to allow either behavior)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions