code: def freq_selection_class_dis(
      raw,
      freq_band=(5.0, 35.0),
      sub_band_width=4,
      sub_band_step=2,
      alpha=0.4,
      tmin=0.5,
      tmax=2.5,
      picks=None,
      event_id=None,
      cv=None,
      return_class_dis=False,
      verbose=None,
  ):
      r"""Select optimal frequency band based on class distinctiveness measure.
  
      Optimal frequency band is selected by combining a filter bank with
      a heuristic based on class distinctiveness on the manifold [1]_:
  
      1. Filter training raw EEG data for each sub-band of a filter bank.
      2. Estimate covariance matrices of filtered EEG for each sub-band.
      3. Measure the class distinctiveness of each sub-band using the
        classDis metric.
      4. Find the optimal frequency band by starting from the sub-band
        with the largest classDis and expanding the selected frequency band
        as long as the classDis exceeds the threshold :math:`th`:
  
      .. math::
        th = max(classDis) - (max(classDis)−min(classDis)) × alpha
  
  
      Parameters
      ----------
      raw : Raw object
          An instance of Raw from MNE.
      freq_band : list, default=(5., 35.)
          Frequency band for band-pass filtering.
      sub_band_width : float, default=4.
          Frequency bandwidth of filter bank.
      sub_band_step : float, default=2.
          Step length of each filter bank.
      alpha : float, default=0.4
          Parameter to define an appropriate threshold for each individual.
      tmin, tmax : float, default=0.5, 2.5
          Start and end time of the epochs in seconds, relative to
          the time-locked event.
      picks : str | array_like | slice,  default=None
          Channels to include. Slices and lists of integers will be
          interpreted as channel indices.
          If None (default), all channels will pick.
      event_id : int | list of int | dict, default=None
          Id of the events to consider.
  
          - If dict, the keys can later be used to access associated
            events.
          - If int, a dict will be created with the id as string.
          - If a list, all events with the IDs specified in the list
            are used.
          - If None, all events will be used and a dict is created
            with string integer names corresponding to the event id integers.
      cv : cross-validation generator, default=None
          An instance of a cross validation iterator from sklearn.
      return_class_dis : bool, default=False
          Whether to return all_cv_class_dis value.
      verbose : bool, str, int, default=None
          Control verbosity of the logging output of filtering and .
          If None, use the default verbosity level.
  
      Returns
      -------
      all_cv_best_freq : list
          List of the selected frequency band for each hold of
          cross validation.
      all_cv_class_dis : list, optional
          List of class_dis value of each hold of cross validation.
  
      Notes
      -----
      .. versionadded:: 0.3.1
  
      References
      ----------
      .. [1] `Class-distinctiveness-based frequency band selection on the
         Riemannian manifold for oscillatory activity-based BCIs: preliminary
         results
         <https://hal.archives-ouvertes.fr/hal-03641137/>`_
         M. S. Yamamoto, F. Lotte, F. Yger, and S. Chevallier.
         44th Annual International Conference of the IEEE Engineering
         in Medicine & Biology Society (EMBC2022), 2022.
      """
  
      subband_fmin = list(
          np.arange(
              freq_band[0],
              freq_band[1] - sub_band_width + 1.0,
              sub_band_step,
          )
      )
      subband_fmax = list(
          np.arange(
              freq_band[0] + sub_band_width,
              freq_band[1] + 1.0,
              sub_band_step,
          )
      )
      n_subband = len(subband_fmin)
  
      all_sub_band_cov = []
  
      for fmin, fmax in zip(subband_fmin, subband_fmax):
          cov_data, labels = _get_filtered_cov(
              raw, picks, event_id, fmin, fmax, tmin, tmax, verbose
          )
          all_sub_band_cov.append(cov_data)
  
      all_cv_best_freq = []
      all_cv_class_dis = []
      for i, (train_ind, test_ind) in enumerate(
          cv.split(all_sub_band_cov[0], labels)
      ):
          all_class_dis = []
          for ii in range(n_subband):
              class_dis = class_distinctiveness(
                  all_sub_band_cov[ii][train_ind],
                  labels[train_ind],
                  exponent=1,
                  metric="riemann",
                  return_num_denom=False,
              )
              all_class_dis.append(class_dis)
          all_cv_class_dis.append(all_class_dis)
  
          best_freq = _get_best_freq_band(
              all_class_dis,
              n_subband,
              subband_fmin,
              subband_fmax,
              alpha,
          )
  
          all_cv_best_freq.append(best_freq)
  
      if return_class_dis:
          return all_cv_best_freq, all_cv_class_dis
      else:
          return all_cv_best_freq
  
imports: import numpy
  from mne import Epochs, events_from_annotations
  from pyriemann.estimation import Covariances
  from pyriemann.classification import class_distinctiveness
label_desc: Use image node_id 1 for calling a global function with example usage: freq_selection_class_dis(raw, freq_band, sub_band_width, sub_band_step, alpha, tmin, tmax, picks, event_id, cv, return_class_dis, verbose) and returns: all_cv_best_freq,  all_cv_class_dis, all_cv_best_freq