Skip to content

Conversation

wmvanvliet
Copy link
Contributor

@wmvanvliet wmvanvliet commented Jan 21, 2025

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:

  • Unit tests
  • Proper documentation page
  • Towncrier

@wmvanvliet
Copy link
Contributor Author

For some reason, on some of the versions in the CI, the fitted dipole is in a slightly different location. I have no idea how to debug this.

@larsoner
Copy link
Member

Usually it suggests that numerical issues are cropping up... a bad/incorrect rank is one common culprit that could be an issue

@larsoner
Copy link
Member

@wmvanvliet I've been meaning to set this up for a while... you could set up a remote SSH to the GHA runners following "ssh" here from Spyder

https://github.com/spyder-ide/spyder/blob/595113cf37b4c6d07a60e1b7a78bb5ae37ec03cd/.github/workflows/test-linux.yml#L40

That way you can at least test what's going on remotely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants