Skip to content

BUG: Fix dev_head_t for EEG data #13112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/devel/13112.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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`_.
8 changes: 6 additions & 2 deletions mne/_fiff/meas_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mne/io/egi/egimff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
1 change: 1 addition & 0 deletions mne/io/egi/tests/test_egi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down