You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am important eye tracking data from a tobii device (XDF format), and kept running into this issue when trying to set_channel_types:
KeyError: 0 (FIFFV_COIL_NONE)
After some digging, I found that there is a different function that I should call. With this PR I want to make this more obvious in the documentation. However, the above issue also points out that there is probably a bug when setting channel types for eye-tracking.
MWE
The code below fails because our use of set_channel_types does not set the coil_type for eyetracking channels:
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="eeg"
)
raw = mne.io.RawArray(data, info)
raw.set_channel_types(dict(xpos="eyegaze", ypos="eyegaze", pupil="pupil"))
epochs = mne.make_fixed_length_epochs(raw)
However the code below does work because mne.create_info properly sets the coil_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)
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:
It is harder to find for users
It is more complex (even I have to re-read the docstring each time that I need to use it)
It can be redundant (I already specified the channel types in mne.create_info, now I need to specify them again?)
If we make sure set_channel_types properly sets the coil_type for eyetrack channels, then the only extra info set_channel_types_eyetrack adds is the loc array. Now I have to pass a complicated dict 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 the coil_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.
The text was updated successfully, but these errors were encountered:
Issue 1 (Originally posted in #12744 (comment) ):
MWE
The code below fails because our use of
set_channel_types
does not set thecoil_type
for eyetracking channels:Stack Trace
However the code below does work because
mne.create_info
properly sets thecoil_type
for all channels:code
Issue 2
One work around to the issue above is to use set_channel_types_eyetrack, like so:
Code
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.The text was updated successfully, but these errors were encountered: