Open scott-huberty opened 2 months ago
Thanks Scott, this perfectly summarizes the issues I was facing.
Maybe we can start with fixing issue Number 1, i.e. make sure that set_channel_types properly sets the coil_type for eyetracking channels
Sounds good, you up for a PR at some point @scott-huberty ?
Maybe we can start with fixing issue Number 1, i.e. make sure that set_channel_types properly sets the coil_type for eyetracking channels
Sounds good, you up for a PR at some point @scott-huberty ?
Yes, I have a backlog of eye-tracking related issues I need to get to 😅 Feel free to assign this to me. I'll have time in August to submit some PR's.
Issue 1 (Originally posted in https://github.com/mne-tools/mne-python/pull/12744#issue-2425236972 ):
MWE
The code below fails because our use of
set_channel_types
does not set thecoil_type
for eyetracking channels:Stack Trace
``` --------------------------------------------------------------------------- KeyError Traceback (most recent call last) Cell In[1], line 14 12 raw = mne.io.RawArray(data, info) 13 raw.set_channel_types(dict(xpos="eyegaze", ypos="eyegaze", pupil="pupil")) ---> 14 epochs = mne.make_fixed_length_epochs(raw) FileHowever the code below does work because
mne.create_info
properly sets thecoil_type
for all channels:code
``` # Note that I do not use set_channel_types here import numpy as np import mne shape = (1, 100) data = np.vstack([np.full(shape, 960), np.full(shape, 540), np.full(shape, 0)]) info = mne.create_info( ch_names=["xpos", "ypos", "pupil"], sfreq=100, ch_types=["eyegaze", "eyegaze", "pupil"] ) raw = mne.io.RawArray(data, info) epochs = mne.make_fixed_length_epochs(raw) ```Issue 2
One work around to the issue above is to use set_channel_types_eyetrack, like so:
Code
``` import numpy as np import mne shape = (1, 100) data = np.vstack([np.full(shape, 960), np.full(shape, 540), np.full(shape, 0)]) info = mne.create_info( ch_names=["xpos", "ypos", "pupil"], sfreq=100, ch_types=["eyegaze", "eyegaze", "pupil"] ) more_info = dict( xpos=("eyegaze", "px", "right", "x"), ypos=("eyegaze", "px", "right", "y"), pupil=("pupil", "au", "right"), ) raw = mne.io.RawArray(data, info) # This sets the coil types, loc array, etc. mne.preprocessing.eyetracking.set_channel_types_eyetrack(raw, more_info) epochs = mne.make_fixed_length_epochs(raw) ```However I personally think that This function has drawbacks:
mne.create_info
, now I need to specify them again?)set_channel_types
properly sets thecoil_type
for eyetrack channels, then the only extra infoset_channel_types_eyetrack
adds is theloc
array. Now I have to pass a complicateddict
and re-set information that might already be correctly set (channel type, coil, unit) just to set the loc array.Proposal
Maybe we can start with fixing issue Number 1, i.e. make sure that
set_channel_types
properly sets thecoil_type
for eyetracking channels. And then loop back to see if we can improve the API for setting other info for eyetracking channels, like the loc array, etc.