diff --git a/doc/changes/dev/13520.bugfix.rst b/doc/changes/dev/13520.bugfix.rst new file mode 100644 index 00000000000..1fd6fa28700 --- /dev/null +++ b/doc/changes/dev/13520.bugfix.rst @@ -0,0 +1 @@ +Preserve ``kit_system_id`` in forward-solution ``Info``, by :newcontrib: 'Melih Yayli' \ No newline at end of file diff --git a/doc/changes/names.inc b/doc/changes/names.inc index cc6800a1b49..1a9c62b9bea 100644 --- a/doc/changes/names.inc +++ b/doc/changes/names.inc @@ -210,6 +210,7 @@ .. _Matti Hämäläinen: https://research.aalto.fi/en/persons/matti-h%C3%A4m%C3%A4l%C3%A4inen/ .. _Matti Toivonen: https://github.com/mattitoi .. _Mauricio Cespedes Tenorio: https://github.com/mcespedes99 +.. _Melih Yayli: https://github.com/yaylim .. _Michael Straube: https://github.com/mistraube .. _Michal Žák: https://github.com/michalrzak .. _Michiru Kaneda: https://github.com/rcmdnk diff --git a/mne/forward/_make_forward.py b/mne/forward/_make_forward.py index e1264bd2fe6..9c2f2552cc9 100644 --- a/mne/forward/_make_forward.py +++ b/mne/forward/_make_forward.py @@ -496,7 +496,7 @@ def _prepare_for_forward( mri_id = dict(machid=np.zeros(2, np.int32), version=0, secs=0, usecs=0) info_trans = str(trans) if isinstance(trans, Path) else trans - info = Info( + kwargs_fwd_info = dict( chs=info["chs"], comps=info["comps"], # The forward-writing code always wants a dev_head_t, so give an identity one @@ -510,6 +510,11 @@ def _prepare_for_forward( bads=info["bads"], mri_head_t=mri_head_t, ) + + if "kit_system_id" in info: + kwargs_fwd_info["kit_system_id"] = info["kit_system_id"] + + info = Info(**kwargs_fwd_info) info._update_redundant() info._check_consistency() logger.info("") diff --git a/mne/forward/tests/test_make_forward.py b/mne/forward/tests/test_make_forward.py index b584202465c..9e94f0cbd44 100644 --- a/mne/forward/tests/test_make_forward.py +++ b/mne/forward/tests/test_make_forward.py @@ -270,6 +270,9 @@ def test_make_forward_solution_kit(tmp_path, fname_src_small): ) _compare_forwards(fwd, fwd_py, 157, n_src_small, meg_rtol=1e-3, meg_atol=1e-7) + # NEW TEST: ensure kit_system_id survives the forward-info rewrite + assert "kit_system_id" in fwd_py["info"] + @requires_mne def test_make_forward_solution_bti(fname_src_small):