class_docstr: Class to add epoch selection and metadata to certain classes.
class_docstr_tok: ["Class","to","add","epoch","selection","and","metadata","to","certain","classes","."]
docstr: Select epochs from current object.
  
  Parameters
  ----------
  item: slice, array-like, str, or list
      see `__getitem__` for details.
  reason: str
      entry in `drop_log` for unselected epochs
  copy: bool
      return a copy of the current object
  drop_event_id: bool
      remove non-existing event-ids after selection
  select_data: bool
      apply selection to data
      (use `select_data=False` if subclasses do not have a
       valid `_data` field, or data has already been subselected)
  return_indices: bool
      return the indices of selected epochs from the original object
      in addition to the new `Epochs` objects
  
  Returns
  -------
  `Epochs` or tuple(Epochs, np.ndarray) if `return_indices` is True
      subset of epochs (and optionally array with kept epoch indices)
docstr_tok: ["Select","epochs","from","current","object",".","Parameters","--","--","--","--","--","item",":","slice",",","array-like",",","str",",","or","list","see","`","__getitem__","`","for","details",".","reason",":","str","entry","in","`","drop_log","`","for","unselected","epochs","copy",":","bool","return","a","copy","of","the","current","object","drop_event_id",":","bool","remove","non-existing","event-ids","after","selection","select_data",":","bool","apply","selection","to","data","(","use","`","select_data=False","`","if","subclasses","do","not","have","a","valid","`","_data","`","field",",","or","data","has","already","been","subselected",")","return_indices",":","bool","return","the","indices","of","selected","epochs","from","the","original","object","in","addition","to","the","new","`","Epochs","`","objects","Returns","--","--","--","-","`","Epochs","`","or","tuple","(","Epochs",",","np.ndarray",")","if","`","return_indices","`","is","True","subset","of","epochs","(","and","optionally","array","with","kept","epoch","indices",")"]
code: def _getitem(
      self,
      item,
      reason="IGNORED",
      copy=True,
      drop_event_id=True,
      select_data=True,
      return_indices=False,
  ):
      """
      Select epochs from current object.
  
      Parameters
      ----------
      item: slice, array-like, str, or list
          see `__getitem__` for details.
      reason: str
          entry in `drop_log` for unselected epochs
      copy: bool
          return a copy of the current object
      drop_event_id: bool
          remove non-existing event-ids after selection
      select_data: bool
          apply selection to data
          (use `select_data=False` if subclasses do not have a
           valid `_data` field, or data has already been subselected)
      return_indices: bool
          return the indices of selected epochs from the original object
          in addition to the new `Epochs` objects
  
      Returns
      -------
      `Epochs` or tuple(Epochs, np.ndarray) if `return_indices` is True
          subset of epochs (and optionally array with kept epoch indices)
      """
      data = self._data
      self._data = None
      inst = self.copy() if copy else self
      self._data = inst._data = data
      del self
  
      select = inst._item_to_select(item)
      has_selection = hasattr(inst, "selection")
      if has_selection:
          key_selection = inst.selection[select]
          drop_log = list(inst.drop_log)
          if reason is not None:
              for k in np.setdiff1d(inst.selection, key_selection):
                  drop_log[k] = (reason,)
          inst.drop_log = tuple(drop_log)
          inst.selection = key_selection
          del drop_log
  
      inst.events = np.atleast_2d(inst.events[select])
      if inst.metadata is not None:
          pd = _check_pandas_installed(strict=False)
          if pd:
              metadata = inst.metadata.iloc[select]
              if has_selection:
                  metadata.index = inst.selection
          else:
              metadata = np.array(inst.metadata, "object")[
                  select
              ].tolist()
  
          # will reset the index for us
          GetEpochsMixin.metadata.fset(inst, metadata, verbose=False)
      if inst.preload and select_data:
          # ensure that each Epochs instance owns its own data so we can
          # resize later if necessary
          inst._data = np.require(
              inst._data[select], requirements=["O"]
          )
      if drop_event_id:
          # update event id to reflect new content of inst
          inst.event_id = {
              k: v
              for k, v in inst.event_id.items()
              if v in inst.events[:, 2]
          }
  
      if return_indices:
          return inst, select
      else:
          return inst
  
imports: import json
  import logging
  from collections import OrderedDict
  from copy import deepcopy
  import numpy
  from ._logging import verbose, warn
  from .check import _check_pandas_installed, _check_preload, _validate_type
  from .numerics import _time_mask, object_hash, object_size
label_desc: Use image node_id 3 for calling the GetEpochsMixin obj's underlying member method code with example usage: obj._getitem(item, reason, copy, drop_event_id, select_data, return_indices) and returns: inst,  select, inst