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

Minor bug in volume source space export #8004

Closed
susamerz opened this issue Jul 13, 2020 · 0 comments · Fixed by #8006
Closed

Minor bug in volume source space export #8004

susamerz opened this issue Jul 13, 2020 · 0 comments · Fixed by #8006

Comments

@susamerz
Copy link

Describe the bug

When exporting a source space that is larger than the mri (i.e has clipping) the warning fails, with error KeyError: 'kind' from
File "***/mne-python/mne/source_space.py", line 517, in export_volume
warn(f'{n_diff} {src["kind"]} vertices lay outside of volume '

I think "kind" here should be "type"

n.b. this seems to have been introduced with #7888

Steps to reproduce

import mne
import nibabel as nb
import numpy as np

data_path= mne.datasets.data_path()
subjects_dir = f'{data_path}/subjects'

aseg_img=nb.load(f'{subjects_dir}/fsaverage/mri/aparc+aseg.mgz')
aseg_data=aseg_img.dataobj
aseg_affine=aseg_img.get_affine()

aseg_affine[:3,:3]*=0.7
new_aseg=nb.MGHImage(aseg_data,aseg_affine)
new_name=f'{subjects_dir}/fsaverage/mri/translated_aseg.mgz'
nb.save(new_aseg,new_name)

sphere = (0,0,0,0.2)

surface_src = mne.setup_source_space("fsaverage", spacing='oct6', surface='white',
                             subjects_dir=subjects_dir, add_dist=False)
lh_cereb = mne.setup_volume_source_space("fsaverage", mri=f'{subjects_dir}/fsaverage/mri/translated_aseg.mgz', sphere=sphere,
                                        volume_label="Left-Cerebellum-Cortex", sphere_units="m")

src = surface_src + lh_cereb

nii_name="test.nii"
src.export_volume(nii_name, mri_resolution="sparse", use_lut=False, overwrite=True)

Expected results

expected it to report the clipped voxels as a warning

Actual results

Key error

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 a pull request may close this issue.

1 participant