Skip to content

Conversation

@yaylim
Copy link

@yaylim yaylim commented Dec 1, 2025

When working with KIT MEG systems, the kit_system_id field is an important piece of metadata associated with the recording setup. Previously, this field was lost during construction of the Info object used in the forward-solution pipeline, which made it unavailable in downstream contexts where it may be needed (e.g., during data conversion or when accessing KIT-specific metadata). This PR ensures that kit_system_id is preserved whenever it is present in raw.info. An explicit if check adds the field only when it exists, so the behavior remains consistent for non-KIT datasets while maintaining important metadata for KIT recordings.

When raw.info contains a kit_system_id, the function  make_forward_solution expects this value to be present during forward computation and raises an error if it is missing. Previously, the kit_system_id field was unintentionally dropped when constructing the Info object used for the forward solution, leading to this failure.
This PR resolves the issue by preserving the kit_system_id field during Info creation. An explicit if check ensures that the field is added only when it is present in raw.info; if it is not present, no kit_system_id is included. This maintains consistency with the original metadata while avoiding unnecessary or incorrect fields.
@yaylim yaylim requested a review from agramfort as a code owner December 1, 2025 21:21
@welcome
Copy link

welcome bot commented Dec 1, 2025

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴

@yaylim yaylim closed this Dec 1, 2025
@yaylim yaylim reopened this Dec 1, 2025
Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me!

Can you add a doc/changes/dev/13520.bugfix.rst using :newcontrib:? And also add some test that fails on main but passes on this PR? I'd expect something like

assert "kit_system_id" in fwd["info"]

would do it.

Comment on lines 499 to 500
info = Info(
chs=info["chs"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To minimize diff and preserve blame how about

kwargs_fwd_info = dict(
...
)

then only a few lines change

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for your comments, can you tell me where I should add the test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in this test somewhere?

def test_make_forward_solution_kit(tmp_path, fname_src_small):

- Created .rst file
- Added test in test_make_forward.py
- Updated the changes made in _make_forward.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants