Skip to content

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

@susamerz

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

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