Order of vertices in morphed source spaces
See original GitHub issueHi,
When morphing the source space of fsaverage to ‘sample’, the order of the morphed vertices is not preserved. The first 10 vertices of the morphed source space do not correspond to those of fsaverage:
fsaverage:
Morphed fsaverage -> sample:
import mne
import os
from mne.datasets.sample import data_path
from mayavi import mlab # noqa
from surfer import Brain # noqa
data_path = data_path()
subjects_dir = data_path + "/subjects/"
os.environ['SUBJECTS_DIR'] = subjects_dir
fname_fs = subjects_dir + "fsaverage/bem/fsaverage-ico-5-src.fif"
src_fs = mne.read_source_spaces(fname_fs)
src_sample = mne.morph_source_spaces(src_fs, subject_to="sample",
subjects_dir=subjects_dir)
sources = np.arange(10)
for subject, src in zip(["fsaverage", "sample"], [src_fs, src_sample]):
brain = Brain(subject, 'lh', 'inflated', subjects_dir=subjects_dir)
surf = brain.geo['lh']
vertices = src[0]["vertno"][sources]
mlab.points3d(surf.x[vertices], surf.y[vertices],
surf.z[vertices], color=(1, 0, 0), scale_factor=6.)
mlab.savefig("%s-sources.png" % subject)
This can be fixed by removing np.sort
in https://github.com/mne-tools/mne-python/blob/master/mne/source_space.py#L2639
` to['vertno'] = np.sort(best[fro['vertno']])`
Then, the first 10 vertices of the morphed source space do match those of fsaverage:
Morphed fsaverage -> sample (after removing np.sort):
When sorting the vertices one loses their correspondance which is the purpose of morphing. The resulting forward operators based on these morphed source spaces would have completely mismatched locations.
Written with @agramfort
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Morph volumetric source estimate--discrepancy in number of ...
Every subject starts with an oct6 source space, 8196 vertices total (4098 per hemi); Some get excluded during forward computation, say for one ......
Read more >Morphing source estimates: Moving data from one brain to ...
In this tutorial we will morph different kinds of source estimation results between individual subject spaces using mne.SourceMorph object.
Read more >[Mne_analysis] "equalized" source spaces
The source spaces always store vertices in ascending order (this is due at the ... Thus the selection of vertices is preserved by...
Read more >Shape discrimination along morph-spaces - ScienceDirect.com
The shapes in a morph space are constructed using weighted combinations of vertices drawn from the two base shapes, with each vertex in...
Read more >Object-space Morphing
An unacceptable morph sequence ... Corresponding features of the source and ... Object-space Morphing source. (C) Gershon Elber, Technion. The Vertex path.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it’s more complicated than this. I talked to @larsoner
MNE-C also outputs sorted vertices and I don’t know why. We need @mshamalainen wisdom on this. For me it defeats the purpose of source space morphing as with this sorting you still have to do stc.morph for group studies.
If we remove the np.sort then we might break stuff like backward compat with MNE-C and also some of our functions require stc.vertno to be sorted. Or at least if it’s not you get a ValueError…
no but I am not sure we can fix it in a reasonable way.