From 4a88d1b823c66a9a83da10ed9163df2a1b8bfb4a Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Tue, 11 Feb 2025 13:48:28 -0500 Subject: [PATCH 1/3] BUG: Fix dev_head_t for EEG data --- mne/_fiff/meas_info.py | 8 ++++++-- mne/io/egi/egimff.py | 2 +- mne/io/egi/tests/test_egi.py | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mne/_fiff/meas_info.py b/mne/_fiff/meas_info.py index 28f0629c323..8eac4b2bf1e 100644 --- a/mne/_fiff/meas_info.py +++ b/mne/_fiff/meas_info.py @@ -3315,7 +3315,7 @@ def create_info(ch_names, sfreq, ch_types="misc", verbose=None): ) -def _empty_info(sfreq): +def _empty_info(sfreq, *, dev_head_t=True): """Create an empty info dictionary.""" from ..transforms import Transform @@ -3364,7 +3364,11 @@ def _empty_info(sfreq): info["highpass"] = 0.0 info["sfreq"] = float(sfreq) info["lowpass"] = info["sfreq"] / 2.0 - info["dev_head_t"] = Transform("meg", "head") + if dev_head_t is True: + dev_head_t = Transform("meg", "head") + elif dev_head_t is False: + dev_head_t = None + info["dev_head_t"] = dev_head_t info._update_redundant() info._check_consistency() return info diff --git a/mne/io/egi/egimff.py b/mne/io/egi/egimff.py index c3a10fb72cd..c68723c23d5 100644 --- a/mne/io/egi/egimff.py +++ b/mne/io/egi/egimff.py @@ -440,7 +440,7 @@ def __init__( assert egi_events.shape[1] == egi_info["last_samps"][-1] meas_dt_utc = egi_info["meas_dt_local"].astimezone(datetime.timezone.utc) - info = _empty_info(egi_info["sfreq"]) + info = _empty_info(egi_info["sfreq"], dev_head_t=False) info["meas_date"] = _ensure_meas_date_none_or_dt(meas_dt_utc) info["utc_offset"] = egi_info["utc_offset"] info["device_info"] = dict(type=egi_info["device"]) diff --git a/mne/io/egi/tests/test_egi.py b/mne/io/egi/tests/test_egi.py index 584714d9c8a..08995fba6a0 100644 --- a/mne/io/egi/tests/test_egi.py +++ b/mne/io/egi/tests/test_egi.py @@ -83,6 +83,7 @@ def test_egi_mff_pause(fname, skip_times, event_times): events_as_annotations=False, ) assert raw.info["sfreq"] == 250.0 # true for all of these files + assert raw.info["dev_head_t"] is None # no MEG data assert len(raw.annotations) == len(skip_times) # assert event onsets match expected times From c8a0cb188d8160e14f85dc86e15b0333eca26bc4 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Tue, 11 Feb 2025 14:05:26 -0500 Subject: [PATCH 2/3] FIX: CL --- doc/changes/devel/bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/devel/bugfix.rst diff --git a/doc/changes/devel/bugfix.rst b/doc/changes/devel/bugfix.rst new file mode 100644 index 00000000000..1bffca6cdef --- /dev/null +++ b/doc/changes/devel/bugfix.rst @@ -0,0 +1 @@ +Fix bug with :func:`mne.io.read_raw_egi` where ``info["dev_head_t"]`` was an identity matrix instead of ``None``, by `Eric Larson`_. From b13f7c32808d448db48e5a51b8c4fed1a41c3ac1 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 11 Feb 2025 19:06:01 +0000 Subject: [PATCH 3/3] [autofix.ci] apply automated fixes --- doc/changes/devel/{bugfix.rst => 13112.bugfix.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/changes/devel/{bugfix.rst => 13112.bugfix.rst} (100%) diff --git a/doc/changes/devel/bugfix.rst b/doc/changes/devel/13112.bugfix.rst similarity index 100% rename from doc/changes/devel/bugfix.rst rename to doc/changes/devel/13112.bugfix.rst