Event annotations not recognized

  • MNE version: MNE 1.3.1 with Python 3.10.8
  • operating system: macOS-13.3.1-arm64-i386-64bit

I am trying to run the MNE-Nirs tutorial pipelines but I am running into an issue with annotations. My snirf file is annotated with 5 different conditions but any time I try to reference any of the five, I get a value error for Invalid Annotation Description.

fnirs_data_folder = '/Users/in65/Desktop/Sample';
fnirs_raw_dir = os.path.join(fnirs_data_folder, '0F19372E_2021-12-09');
raw_intensity = mne.io.read_raw_nirx(fnirs_raw_dir).load_data()
raw_intensity.resample(0.7)
#rename conditions
raw_intensity.annotations.rename({'2.0': 'Resting',
                                  '3.0': 'English',
                                  '4.0': 'Spanish',
                                  '5.0': 'Distorted'})
raw_intensity.annotations.delete(raw_intensity.annotations.description == '15.0')
raw_intensity.annotations.set_durations(5)

I get this error:

Cell In[2], line 8
    raw_intensity.annotations.rename({'2.0': 'Resting',

  File <decorator-gen-133>:12 in rename

  File /Applications/MNE-Python/.mne-python/lib/python3.10/site-packages/mne/annotations.py:670 in rename
    _check_dict_keys(mapping, self.description, valid_key_source="data",

  File /Applications/MNE-Python/.mne-python/lib/python3.10/site-packages/mne/utils/check.py:723 in _check_dict_keys
    raise ValueError(msg)

ValueError: Invalid Annotation description(s) {'4.0', '5.0', '2.0', '3.0'} are not present in data

My data is linked here:

Has anyone encountered this error? Thank you!

It seems like your annotations are not named 2.0, 3.0, etc. Before renaming, take a look with raw.annotations.description.

Thank you so much! It seems like my start/stop annotations are there but my condition triggers are missing. Does anyone know an easy way to add annotations every thirty seconds to a specified interval, given start and end times? This is my first time using the MNE software. Thank you!