code: def online_detect(t):
      global time, sig, covs_visu
  
      # Online artifact detection
      rp_label = rpotato.predict(covs[np.newaxis, t])[0]
      ep_label = epotato.predict(covs[np.newaxis, t])[0]
      if not is_static:
          if rp_label == 1:
              rpotato.partial_fit(covs[np.newaxis, t], alpha=1 / t)
          if ep_label == 1:
              epotato.partial_fit(covs[np.newaxis, t], alpha=1 / t)
  
      # Update data
      time_start = t * interval + test_time_end
      time_end = (t + 1) * interval + test_time_end
      time_ = np.linspace(
          time_start, time_end, int(interval * sfreq), endpoint=False
      )
      time = np.r_[time[int(interval * sfreq) :], time_]
      sig = np.hstack(
          (
              sig[:, int(interval * sfreq) :],
              eeg_data[
                  :, int(time_start * sfreq) : int(time_end * sfreq)
              ],
          )
      )
      covs_visu = np.vstack((covs_visu, covs[np.newaxis, t]))
      rp_colors.append("b" if rp_label == 1 else "r")
      ep_colors.append("b" if ep_label == 1 else "r")
      if len(covs_visu) > test_covs_visu:
          covs_visu = covs_visu[1:]
          rp_colors.pop(0)
          ep_colors.pop(0)
      rp_colors_ = _add_alpha(rp_colors, alphas)
      ep_colors_ = _add_alpha(ep_colors, alphas)
  
      # Update plot
      pl_sig0.set_data(time, sig[0])
      pl_sig0.axes.set_xlim(time[0], time[-1])
      pl_sig1.set_data(time, sig[1])
      pl_sig1.axes.set_xlim(time[0], time[-1])
      p_rp.set_offsets(np.c_[covs_visu[:, 0, 0], covs_visu[:, 1, 1]])
      p_rp.set_color(rp_colors_)
      p_ep.set_offsets(np.c_[covs_visu[:, 0, 0], covs_visu[:, 1, 1]])
      p_ep.set_color(ep_colors_)
      return pl_sig0, pl_sig1, p_rp, p_ep
  
file_path: pyRiemann/examples/artifacts/plot_detect_riemannian_potato_EEG.py
imports: from functools import partial
  import os
  import numpy
  from matplotlib import pyplot
  from matplotlib.animation import FuncAnimation
  from mne.datasets import sample
  from mne.io import read_raw_fif
  from mne import make_fixed_length_epochs
  from pyriemann.estimation import Covariances
  from pyriemann.clustering import Potato
  from pyriemann.utils.viz import _add_alpha
label_desc: Use image node_id 4 for calling a global function with example usage: online_detect(t) and returns: pl_sig0,  pl_sig1,  p_rp,  p_ep