Skip to content

ENH: Add save() to ConductorModel and InverseOperator - #14612

Open
KrBeTect2025 wants to merge 3 commits into
mne-tools:mainfrom
KrBeTect2025:enh/14609-save-methods
Open

KrBeTect2025 wants to merge 3 commits into
mne-tools:mainfrom
KrBeTect2025:enh/14609-save-methods

Conversation

@KrBeTect2025

Copy link
Copy Markdown

Reference issue (if any)

Fixes #14609.

What does this implement/fix?

Adds ConductorModel.save() and InverseOperator.save(), so a BEM solution and an inverse operator can be saved the same way as Forward and most other MNE objects. Both take fname, *, overwrite=False, verbose=None, like Forward.save, and call the existing write_bem_solution / write_inverse_operator, so nothing about the file format changes.

The existing test_io_bem (fif and h5) and test_io_inverse_operator now also save with the new method and read the file back. Those checks fail on main and pass with this change. test_bem.py and minimum_norm/test_inverse.py pass locally (97 passed, 9 skipped), as do pre-commit and test_docstring_parameters.py.

Additional information

AI disclosure: I used Claude Code (Claude Opus 5.5). It wrote the two methods, the test additions, the changelog entry, and a first draft of this description. I chose the issue and reviewed the diff and this text before submitting.

@viranovskaya

Copy link
Copy Markdown
Contributor

temp_sol has already been written by write_bem_solution, so the test would pass even if sol.save() did nothing—it would just read the existing file. Could we use a separate path that does not exist yet, so the test verifies that sol.save() actually writes the file?

@KrBeTect2025

Copy link
Copy Markdown
Author

Yess good catch, Fixed both tests to save to a new file

@nordme nordme left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me! The Azure Pipeline failures look unrelated.

This branch has not been deployed

No deployments
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.

Add .save() to ConductorModel and InverseOperator

3 participants