Skip to content

Commit e5a9db2

Browse files
FIX: allow user to pick "eyegaze" or "pupil" (fix in triage_eyetrack_picks) (mne-tools#12019)
1 parent 2138c17 commit e5a9db2

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

doc/changes/devel.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Bugs
5656
- Fix handling of channel information in annotations when loading data from and exporting to EDF file (:gh:`11960` :gh:`12017` by `Paul Roujansky`_)
5757
- Add missing ``overwrite`` and ``verbose`` parameters to :meth:`Transform.save() <mne.transforms.Transform.save>` (:gh:`12004` by `Marijn van Vliet`_)
5858
- Correctly prune channel-specific :class:`~mne.Annotations` when creating :class:`~mne.Epochs` without the channel(s) included in the channel specific annotations (:gh:`12010` by `Mathieu Scheltienne`_)
59+
- Correctly handle passing ``"eyegaze"`` or ``"pupil"`` to :meth:`mne.io.Raw.pick` (:gh:`12019` by `Scott Huberty`_)
5960

6061
API changes
6162
~~~~~~~~~~~

mne/_fiff/pick.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,21 +1362,23 @@ def _picks_str_to_idx(
13621362
bad_type = None
13631363
picks_type = list()
13641364
kwargs = dict(meg=False)
1365-
meg, fnirs = set(), set()
1365+
meg, fnirs, eyetrack = set(), set(), set()
13661366
for pick in picks:
13671367
if pick in _PICK_TYPES_KEYS:
13681368
kwargs[pick] = True
13691369
elif pick in _MEG_CH_TYPES_SPLIT:
13701370
meg |= {pick}
13711371
elif pick in _FNIRS_CH_TYPES_SPLIT:
13721372
fnirs |= {pick}
1373+
elif pick in _EYETRACK_CH_TYPES_SPLIT:
1374+
eyetrack |= {pick}
13731375
else:
13741376
bad_type = pick
13751377
break
13761378
else:
13771379
# bad_type is None but this could still be empty
13781380
bad_type = list(picks)
1379-
# triage MEG and FNIRS, which are complicated due to non-bool entries
1381+
# triage MEG, FNIRS, and eyetrack, which are complicated due to non-bool entries
13801382
extra_picks = set()
13811383
if "ref_meg" not in picks and not with_ref_meg:
13821384
kwargs["ref_meg"] = False
@@ -1386,11 +1388,12 @@ def _picks_str_to_idx(
13861388
extra_picks |= set(
13871389
pick_types(info, meg=use_meg, ref_meg=False, exclude=exclude)
13881390
)
1389-
if len(fnirs) > 0 and not kwargs.get("fnirs", False):
1390-
if len(fnirs) == 1:
1391-
kwargs["fnirs"] = list(fnirs)[0]
1392-
else:
1393-
kwargs["fnirs"] = list(fnirs)
1391+
if len(fnirs) and not kwargs.get("fnirs", False):
1392+
idx = 0 if len(fnirs) == 1 else slice(None)
1393+
kwargs["fnirs"] = list(fnirs)[idx]
1394+
if len(eyetrack) and not kwargs.get("eyetrack", False):
1395+
idx = 0 if len(eyetrack) == 1 else slice(None)
1396+
kwargs["eyetrack"] = list(eyetrack)[idx] # slice(None) is equivalent to all
13941397
picks_type = pick_types(info, exclude=exclude, **kwargs)
13951398
if len(extra_picks) > 0:
13961399
picks_type = sorted(set(picks_type) | set(extra_picks))

mne/_fiff/tests/test_pick.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,11 @@ def test_picks_to_idx():
658658
picks_ref, _picks_to_idx(info_ref, "ref_meg", with_ref_meg=False)
659659
)
660660
assert_array_equal(picks_meg_ref, _picks_to_idx(info_ref, "meg", with_ref_meg=True))
661+
# Eyetrack
662+
info = create_info(["a", "b"], 1000.0, ["eyegaze", "pupil"])
663+
assert_array_equal(np.arange(2), _picks_to_idx(info, "eyetrack"))
664+
assert_array_equal([0], _picks_to_idx(info, "eyegaze"))
665+
assert_array_equal([1], _picks_to_idx(info, "pupil"))
661666

662667

663668
def test_pick_channels_cov():

0 commit comments

Comments
 (0)