Skip to content

XFit-style dipole fitting GUI - #13074

Merged
larsoner merged 227 commits into
mne-tools:mainfrom
wmvanvliet:xfit
Aug 26, 2026
Merged

XFit-style dipole fitting GUI#13074
larsoner merged 227 commits into
mne-tools:mainfrom
wmvanvliet:xfit

Conversation

@wmvanvliet

@wmvanvliet wmvanvliet commented Jan 21, 2025

Copy link
Copy Markdown
Contributor

This adds a GUI to perform guided dipole modeling in the spirit of MEGIN's XFit program. This PR contains the base functionality needed to make the GUI useful. Useful enough to include in the next release of MNE-Python. The plan is to keep adding features in future PRs as well as some sorely needed speed improvements.

See here for a list of currently supported features: #11977
This PR depends on: #12071

Screenshot 2025-01-21 183100

Minimal example:

import mne

data_path = mne.datasets.sample.data_path()
evoked = mne.read_evokeds(
    f"{data_path}/MEG/sample/sample_audvis-ave.fif", condition="Left Auditory"
)
evoked.apply_baseline((-0.2, 0))
trans = mne.read_trans(f"{data_path}/MEG/sample/sample_audvis_raw-trans.fif")
cov = mne.read_cov(f"{data_path}/MEG/sample/sample_audvis-cov.fif")
bem = mne.read_bem_solution(f"{data_path}/subjects/sample/bem/sample-5120-5120-5120-bem-sol.fif")
subject = "sample"
subjects_dir = data_path / "subjects"

evoked.pick("grad")

# Quick and dirty. No MRI whatsoever.
g = mne.gui.DipoleFitUI(evoked)

# Slow and proper. With proper BEM model.
# g = mne.gui.DipoleFitUI(evoked, trans=trans, cov=cov, bem=bem, subject=subject, subjects_dir=subjects_dir)

Todo:

  • Basic unit tests
  • In-depth unit tests
  • Proper documentation page
  • Towncrier

@larsoner

Copy link
Copy Markdown
Member

@wmvanvliet I pushed some tests and some minor fixes. Good to go from your end? If so I say let's merge and keep iterating in follow-up PRs! Updated example here.

@larsoner larsoner moved this from Claimed to In Progress in 2026 MNE-Python Maintainers Sprint Aug 25, 2026
@wmvanvliet
wmvanvliet marked this pull request as ready for review August 26, 2026 14:42
@larsoner
larsoner enabled auto-merge (squash) August 26, 2026 15:00
@larsoner
larsoner merged commit b530f62 into mne-tools:main Aug 26, 2026
31 checks passed
natinew77-creator added a commit to natinew77-creator/mne-python that referenced this pull request Aug 26, 2026
mne-toolsgh-13074 made mne/viz/_3d.py write channel names onto the second value
instanced_mesh returns, which broke plot_alignment here three ways: a
pyvista-js PolyData has no field_data, several colours came back as a
list, and empty positions came back as None. Return the per-instance
point cloud instead, always one object with the mapping attached, which
is what _PyVistaRenderer returns.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

4 participants