|
13 | 13 | from mne.datasets import testing |
14 | 14 | from mne.transforms import (Transform, apply_trans, rotation, translation, |
15 | 15 | scaling, read_trans, _angle_between_quats, |
16 | | - rot_to_quat) |
| 16 | + rot_to_quat, invert_transform) |
17 | 17 | from mne.coreg import (fit_matched_points, create_default_subject, scale_mri, |
18 | 18 | _is_mri_subject, scale_labels, scale_source_space, |
19 | 19 | coregister_fiducials, get_mni_fiducials, Coregistration) |
@@ -235,6 +235,17 @@ def test_scale_mri_xfm(tmp_path, few_surfaces): |
235 | 235 | mni = mne.vertex_to_mni(vertices, hemis, subject_to, |
236 | 236 | subjects_dir=tempdir) |
237 | 237 | 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) |
238 | 249 |
|
239 | 250 |
|
240 | 251 | def test_fit_matched_points(): |
|
0 commit comments