Skip to content
Merged
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.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Bugs
- Fix bug with :func:`~mne.viz.plot_raw` where changing ``MNE_BROWSER_BACKEND`` via :func:`~mne.set_config` would have no effect within a Python session (:gh:`12078` by `Santeri Ruuskanen`_)
- Improve handling of ``method`` argument in the channel interpolation function to support :class:`str` and raise helpful error messages (:gh:`12113` by `Mathieu Scheltienne`_)
- Fix combination of ``DIN`` event channels into a single synthetic trigger channel ``STI 014`` by the MFF reader of :func:`mne.io.read_raw_egi` (:gh:`12122` by `Mathieu Scheltienne`_)
- Fix bug with :func:`mne.io.read_raw_eeglab` and :func:`mne.read_epochs_eeglab` where automatic fiducial detection would fail for certain files (:gh:`12165` by `Clemens Brunner`_)

API changes
~~~~~~~~~~~
Expand Down
26 changes: 16 additions & 10 deletions mne/io/eeglab/eeglab.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,23 @@ def _get_montage_information(eeg, get_pos, *, montage_units):
)

lpa, rpa, nasion = None, None, None
if hasattr(eeg, "chaninfo") and len(eeg.chaninfo.get("nodatchans", [])):
for item in list(zip(*eeg.chaninfo["nodatchans"].values())):
d = dict(zip(eeg.chaninfo["nodatchans"].keys(), item))
if d.get("type", None) != "FID":
if hasattr(eeg, "chaninfo") and isinstance(eeg.chaninfo["nodatchans"], dict):
nodatchans = eeg.chaninfo["nodatchans"]
types = nodatchans.get("type", [])
descriptions = nodatchans.get("description", [])
xs = nodatchans.get("X", [])
ys = nodatchans.get("Y", [])
zs = nodatchans.get("Z", [])

for type_, description, x, y, z in zip(types, descriptions, xs, ys, zs):
if type_ != "FID":
continue
elif d.get("description", None) == "Nasion":
nasion = np.array([d["X"], d["Y"], d["Z"]])
elif d.get("description", None) == "Right periauricular point":
rpa = np.array([d["X"], d["Y"], d["Z"]])
elif d.get("description", None) == "Left periauricular point":
lpa = np.array([d["X"], d["Y"], d["Z"]])
if description == "Nasion":
nasion = np.array([x, y, z])
elif description == "Right periauricular point":
rpa = np.array([x, y, z])
elif description == "Left periauricular point":
lpa = np.array([x, y, z])

# Always check this even if it's not used
_check_option("montage_units", montage_units, ("m", "dm", "cm", "mm", "auto"))
Expand Down