Skip to content

Commit c437d20

Browse files
larsonersnwnde
authored andcommitted
MAINT: Warn when fitting cHPI amplitudes on Maxwell filtered data (mne-tools#12038)
1 parent 784d381 commit c437d20

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

mne/chpi.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,16 @@ def _setup_hpi_amplitude_fitting(
624624
on_missing = "raise" if not allow_empty else "ignore"
625625
hpi_freqs, hpi_pick, hpi_ons = get_chpi_info(info, on_missing=on_missing)
626626

627+
# check for maxwell filtering
628+
for ent in info["proc_history"]:
629+
for key in ("sss_info", "max_st"):
630+
if len(ent["max_info"]["sss_info"]) > 0:
631+
warn(
632+
"Fitting cHPI amplutudes after Maxwell filtering may not to work, "
633+
"consider fitting on the original data"
634+
)
635+
break
636+
627637
_validate_type(t_window, (str, "numeric"), "t_window")
628638
if info["line_freq"] is not None:
629639
line_freqs = np.arange(

mne/tests/test_chpi.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,15 @@ def test_calculate_chpi_positions_artemis():
422422
)
423423

424424

425+
@testing.requires_testing_data
426+
def test_warn_maxwell_filtered():
427+
"""Test that trying to compute locations on Maxwell filtered data warns."""
428+
raw = read_raw_fif(sss_fif_fname).crop(0, 1)
429+
with pytest.warns(RuntimeWarning, match="Maxwell filter"):
430+
amps = compute_chpi_amplitudes(raw)
431+
assert len(amps["times"]) > 0 # but for this file, it does work!
432+
433+
425434
@testing.requires_testing_data
426435
def test_initial_fit_redo():
427436
"""Test that initial fits can be redone based on moments."""

0 commit comments

Comments
 (0)