Skip to content

MRG, ENH: Add forward sensitivity maps to reports - #14107

Open
mariam-hedgie wants to merge 11 commits into
mne-tools:mainfrom
mariam-hedgie:enh-report-forward-sensitivity
Open

MRG, ENH: Add forward sensitivity maps to reports#14107
mariam-hedgie wants to merge 11 commits into
mne-tools:mainfrom
mariam-hedgie:enh-report-forward-sensitivity

Conversation

@mariam-hedgie

@mariam-hedgie mariam-hedgie commented Jul 27, 2026

Copy link
Copy Markdown

Closes #2828

the missing feature:

MNE can already calculate sensitivity maps from a forward model to get information on how strongly each possible brain source would be measured by EEG/MEG sensors. however, the function Report.add_forward() did not have an easy way for users to choose to include the sensitivity maps in an HTML report. This PR aims to fix users having to make maps manually and add them separately.

new behavior:

  • added an optional boolean sensitivity parameter to the Report.add_forward()
  • default is False so the behavior is the same as earlier
  • if sensitivity=True then MNE finds the sensor types available in the forward model
  • it generates sensitivity maps and embeds them in the forward-solution section of the report
  • this also handles report rendering for surface and volume source estimates
  • rendering sensitivity maps/source estimates requires a 3D backend and raises a clear error if none is available
  • removed matplotlib fallback

testing:

  • a public API test confirms that sensitivity parameter exists in the Report.add_forward() function
  • a data test loads MNE's testing forward solution, computes the maps, and renders them in a report
  • test that checks that an absent 3d backend raises a clear error
  • regression test for in-memory volume source estimates through the 3d path
  • these focused tests passed locally

AI disclosure:

Codex was used to help inspect the code and issue, implement changes, and run local checks. I reviewed the final diff, understand the changes and behavior, and reviewed the test results

@welcome

welcome Bot commented Jul 27, 2026

Copy link
Copy Markdown

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

@mariam-hedgie

Copy link
Copy Markdown
Author
  • CircleCI docs and linkcheck were blocked with block-unregistered-user
  • i logged in to CircleCI afterward
  • the rerun buttons were disabled for me
  • azure and codecov checks passed
  • would a maintainer be able to rerun or authorize the CircleCI docs checks?
    thank you

@larsoner

Copy link
Copy Markdown
Member

Done!

@mariam-hedgie

Copy link
Copy Markdown
Author
  • the latest commit has passed CircleCI and azure checks
  • the needed github workflows still show action required/waiting for status
  • would a maintainer be able to approve those workflows?
    thanks!

@larsoner

Copy link
Copy Markdown
Member
FAILED mne/report/tests/test_report.py::test_add_forward_sensitivity_matplotlib - ModuleNotFoundError: No module named 'nibabel'

We plan to get rid of the matplotlib backend actually, so let's just remove code related to that and raise an error if 3D plotting can't be used

@mariam-hedgie

Copy link
Copy Markdown
Author

I have removed the matplotlib fallback, the CircleCI and Codecov checks pass, would a maintainer be able to approve the github workflow tests? thanks.

@larsoner

Copy link
Copy Markdown
Member

Done

@mariam-hedgie mariam-hedgie changed the title WIP, ENH: Add forward sensitivity maps to reports MRG, ENH: Add forward sensitivity maps to reports Jul 28, 2026
@mariam-hedgie
mariam-hedgie marked this pull request as ready for review July 28, 2026 07:30
@mariam-hedgie

Copy link
Copy Markdown
Author

I addressed the recent request to remove the Matplotlib fallback, and the checks are green. Would a maintainer please review this PR? Thanks!

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 option in "mne report" to get sensitivity maps of forward models

2 participants