Skip to content

Commit ac45cbe

Browse files
authored
MAINT: Extra test for coreg (#10549)
1 parent 2f53da7 commit ac45cbe

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

mne/tests/test_coreg.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from mne.datasets import testing
1414
from mne.transforms import (Transform, apply_trans, rotation, translation,
1515
scaling, read_trans, _angle_between_quats,
16-
rot_to_quat)
16+
rot_to_quat, invert_transform)
1717
from mne.coreg import (fit_matched_points, create_default_subject, scale_mri,
1818
_is_mri_subject, scale_labels, scale_source_space,
1919
coregister_fiducials, get_mni_fiducials, Coregistration)
@@ -235,6 +235,17 @@ def test_scale_mri_xfm(tmp_path, few_surfaces):
235235
mni = mne.vertex_to_mni(vertices, hemis, subject_to,
236236
subjects_dir=tempdir)
237237
assert_allclose(mni, mni_from, atol=1e-3) # 0.001 mm
238+
# Check head_to_mni (the `trans` here does not really matter)
239+
trans = rotation(0.001, 0.002, 0.003) @ translation(0.01, 0.02, 0.03)
240+
trans = Transform('head', 'mri', trans)
241+
pos_head_from = np.random.RandomState(0).randn(4, 3)
242+
pos_mni_from = mne.head_to_mni(
243+
pos_head_from, subject_from, trans, tempdir)
244+
pos_mri_from = apply_trans(trans, pos_head_from)
245+
pos_mri = pos_mri_from * scale
246+
pos_head = apply_trans(invert_transform(trans), pos_mri)
247+
pos_mni = mne.head_to_mni(pos_head, subject_to, trans, tempdir)
248+
assert_allclose(pos_mni, pos_mni_from, atol=1e-3)
238249

239250

240251
def test_fit_matched_points():

0 commit comments

Comments
 (0)