Skip to content

Commit 1931320

Browse files
FIX: correct spacing attribute in SourceMorph when src_to is provided (#13687)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8806b8a commit 1931320

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

doc/changes/dev/13687.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug in :func:`~mne.compute_source_morph` where :attr:`mne.SourceMorph.spacing` was set incorrectly when ``src_to`` is provided, by `Famous077`_.

mne/morph.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,11 @@ def compute_source_morph(
292292
assert morph_mat.shape[0] == n_verts
293293

294294
vertices_to = vertices_to_surf + vertices_to_vol
295+
295296
if src_to is not None:
296297
assert len(vertices_to) == len(src_to)
298+
# set spacing to None when src_to is provided
299+
spacing = None
297300
morph = SourceMorph(
298301
subject_from,
299302
subject_to,

mne/tests/test_morph.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,17 @@ def test_surface_vector_source_morph(tmp_path):
308308
source_morph_surf = compute_source_morph(
309309
inverse_operator_surf["src"], subjects_dir=subjects_dir, smooth=1, warn=False
310310
) # smooth 1 for speed
311+
src_to_fs = mne.read_source_spaces(
312+
subjects_dir / "fsaverage" / "bem" / "fsaverage-ico-5-src.fif"
313+
)
314+
morph_with_src_to = compute_source_morph(
315+
inverse_operator_surf["src"],
316+
subjects_dir=subjects_dir,
317+
src_to=src_to_fs,
318+
smooth=1,
319+
warn=False,
320+
)
321+
assert morph_with_src_to.spacing is None
311322
assert source_morph_surf.subject_from == "sample"
312323
assert source_morph_surf.subject_to == "fsaverage"
313324
assert source_morph_surf.kind == "surface"

0 commit comments

Comments
 (0)