Skip to content

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

Merged
larsoner merged 3 commits into
mne-tools:mainfrom
KrBeTect2025:enh/14609-save-methods
Dec 2, 2026
Merged

larsoner merged 3 commits into
mne-tools:mainfrom
KrBeTect2025:enh/14609-save-methods

Conversation

@KrBeTect2025

Copy link
Copy Markdown
Contributor

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
Contributor 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.

@larsoner
larsoner merged commit 2c0c834 into mne-tools:main Dec 2, 2026
25 of 26 checks passed
@welcome

welcome Bot commented Dec 2, 2026

Copy link
Copy Markdown

🎉 Congrats on merging your first pull request! 🥳 Looking forward to seeing more from you in the future! 💪

larsoner added a commit to larsoner/mne-python that referenced this pull request Dec 2, 2026
* upstream/main:
  FIX: Limit NaN propagation during overlap-add FIR filtering (mne-tools#14614)
  ENH: Add save() to ConductorModel and InverseOperator (mne-tools#14612)
  FIX: Make minimum-phase firwin2 high-pass filters work with even filter lengths (mne-tools#14627)
  DOC: Note that cap montages do not line up with fsaverage in template-MRI tutorial (mne-tools#14628)
  DOC: Say adjacency=None is rarely right for sensor or source data in cluster tests (mne-tools#14629)
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

4 participants