import mne
from mne.datasets.eyelink import data_path
from mne.preprocessing.eyetracking import read_eyelink_calibration
from mne.viz.eyetracking import plot_gaze
import mne.preprocessing.eyetracking as et
et_fpath = data_path() / "eeg-et" / "sub-01_task-plr_eyetrack.asc"
eeg_fpath = data_path() / "eeg-et" / "sub-01_task-plr_eeg.mff"
raw_et = mne.io.read_raw_eyelink(et_fpath, create_annotations=["blinks"])
raw_eeg = mne.io.read_raw_egi(eeg_fpath, events_as_annotations=True).load_data()
raw_eeg.filter(1, 30)
print(raw_et.info["chs"])
for ci, ch_info in enumerate(raw_et.info["chs"]):
print(ci, ch_info["ch_name"])
cals = read_eyelink_calibration(et_fpath)
print(f"number of calibrations: {len(cals)}")
first_cal = cals[0] # let's access the first (and only in this case) calibration
print(first_cal)
print(f"offset for each calibration point: {first_cal['offsets']}")
print(f"x-coordinate for each calibration point: {first_cal['positions'].T[0]}")
first_cal.plot()
first_cal["screen_resolution"] = (1920, 1080)
first_cal["screen_size"] = (0.53, 0.3)
first_cal["screen_distance"] = 0.9
mne.preprocessing.eyetracking.convert_units(raw_et, calibration=first_cal, to="radians")
ps_scalings = dict(pupil=1e3)
print("these are the channels names ----------------------------", raw_et.ch_names)
raw_et.plot(scalings=ps_scalings, block=True)
raw_et = et.interpolate_blinks(raw_et, interpolate_gaze=False)
raw_et.plot(scalings=ps_scalings, block=True)
print("These are the annotations", raw_et.annotations)
my_annot = mne.Annotations(
onset=[*raw_et.annotations.onset, 3],
duration=[*raw_et.annotations.duration, 1],
description=[*raw_et.annotations.description, "BAD_foo"],
)
print(my_annot)
raw_et.set_annotations(my_annot)
raw_et.plot(scalings=ps_scalings, block=True)
raw_et = et.interpolate_blinks(raw_et, interpolate_gaze=False, match="BAD_foo")
raw_et.plot(scalings=ps_scalings, block=True)
How can I remove the existing annotations description and ārenameā them? Right now it looks something like this:
As we can clearly see, thereās a āBAD_blinkā but what if I want to rename it as āBAD_somethingā?
