class_docstr: Mixin class for Annotations in Epochs.
class_docstr_tok: ["Mixin","class","for","Annotations","in","Epochs","."]
docstr: Setter for Epoch annotations from Raw.
  
  This method does not handle offsetting the times based
  on first_samp or measurement dates, since that is expected
  to occur in Raw.set_annotations().
  
  Parameters
  ----------
  annotations : instance of mne.Annotations | None
      Annotations to set.
  %(on_missing_ch_names)s
  %(verbose)s
  
  Returns
  -------
  self : instance of Epochs
      The epochs object with annotations.
  
  Notes
  -----
  Annotation onsets and offsets are stored as time in seconds (not as
  sample numbers).
  
  If you have an ``-epo.fif`` file saved to disk created before 1.0,
  annotations can be added correctly only if no decimation or
  resampling was performed. We thus suggest to regenerate your
  :class:`mne.Epochs` from raw and re-save to disk with 1.0+ if you
  want to safely work with :class:`~mne.Annotations` in epochs.
  
  Since this method does not handle offsetting the times based
  on first_samp or measurement dates, the recommended way to add
  Annotations is::
  
      raw.set_annotations(annotations)
      annotations = raw.annotations
      epochs.set_annotations(annotations)
  
  .. versionadded:: 1.0
docstr_tok: ["Setter","for","Epoch","annotations","from","Raw",".","This","method","does","not","handle","offsetting","the","times","based","on","first_samp","or","measurement","dates",",","since","that","is","expected","to","occur","in","Raw.set_annotations","(",")",".","Parameters","--","--","--","--","--","annotations",":","instance","of","mne.Annotations","|","None","Annotations","to","set",".","%","(","on_missing_ch_names",")","s","%","(","verbose",")","s","Returns","--","--","--","-","self",":","instance","of","Epochs","The","epochs","object","with","annotations",".","Notes","--","--","-","Annotation","onsets","and","offsets","are","stored","as","time","in","seconds","(","not","as","sample","numbers",")",".","If","you","have","an","``","-epo.fif","``","file","saved","to","disk","created","before","1.0",",","annotations","can","be","added","correctly","only","if","no","decimation","or","resampling","was","performed",".","We","thus","suggest","to","regenerate","your",":","class",":","`","mne.Epochs","`","from","raw","and","re-save","to","disk","with","1.0+","if","you","want","to","safely","work","with",":","class",":","`","~mne.Annotations","`","in","epochs",".","Since","this","method","does","not","handle","offsetting","the","times","based","on","first_samp","or","measurement","dates",",","the","recommended","way","to","add","Annotations","is",":",":","raw.set_annotations","(","annotations",")","annotations","=","raw.annotations","epochs.set_annotations","(","annotations",")","..","versionadded",":",":","1.0"]
code: def set_annotations(
      self, annotations, on_missing="raise", *, verbose=None
  ):
      """Setter for Epoch annotations from Raw.
  
      This method does not handle offsetting the times based
      on first_samp or measurement dates, since that is expected
      to occur in Raw.set_annotations().
  
      Parameters
      ----------
      annotations : instance of mne.Annotations | None
          Annotations to set.
      %(on_missing_ch_names)s
      %(verbose)s
  
      Returns
      -------
      self : instance of Epochs
          The epochs object with annotations.
  
      Notes
      -----
      Annotation onsets and offsets are stored as time in seconds (not as
      sample numbers).
  
      If you have an ``-epo.fif`` file saved to disk created before 1.0,
      annotations can be added correctly only if no decimation or
      resampling was performed. We thus suggest to regenerate your
      :class:`mne.Epochs` from raw and re-save to disk with 1.0+ if you
      want to safely work with :class:`~mne.Annotations` in epochs.
  
      Since this method does not handle offsetting the times based
      on first_samp or measurement dates, the recommended way to add
      Annotations is::
  
          raw.set_annotations(annotations)
          annotations = raw.annotations
          epochs.set_annotations(annotations)
  
      .. versionadded:: 1.0
      """
      _validate_type(annotations, (Annotations, None), "annotations")
      if annotations is None:
          self._annotations = None
      else:
          if getattr(self, "_unsafe_annot_add", False):
              warn(
                  "Adding annotations to Epochs created (and saved to "
                  "disk) before 1.0 will yield incorrect results if "
                  "decimation or resampling was performed on the instance, "
                  "we recommend regenerating the Epochs and re-saving them "
                  "to disk."
              )
          new_annotations = annotations.copy()
          new_annotations._prune_ch_names(self.info, on_missing)
          self._annotations = new_annotations
      return self
  
imports: import json
  import os.path
  import re
  import warnings
  from collections import Counter, OrderedDict
  from collections.abc import Iterable
  from copy import deepcopy
  from datetime import datetime, timedelta, timezone
  from itertools import takewhile
  from textwrap import shorten
  import numpy
  from scipy.io import loadmat
  from ._fiff.constants import FIFF
  from ._fiff.open import fiff_open
  from ._fiff.tag import read_tag
  from ._fiff.tree import dir_tree_find
  from ._fiff.write import _safe_name_list, end_block, start_and_end_file, start_block, write_double, write_float, write_name_list_sanitized, write_string
  from .utils import _check_dict_keys, _check_dt, _check_fname, _check_option, _check_pandas_installed, _check_time_format, _convert_times, _DefaultEventParser, _dt_to_stamp, _is_numeric, _mask_to_onsets_offsets, _on_missing, _pl, _stamp_to_dt, _validate_type, check_fname, fill_doc, int_like, logger, verbose, warn
label_desc: Use image node_id 2 for calling the EpochAnnotationsMixin obj's underlying member method code with example usage: obj.set_annotations(annotations, on_missing) and returns: self