code: def online_detect(t):
      global time, sig, labels, covs_t, covs_z, covs_p
  
      # Online artifact detection
      rp_label = rp.predict(rp_covs[np.newaxis, t])[0]
      rp_zscore = rp.transform(rp_covs[np.newaxis, t])
      rpf_label = rpf.predict([c[np.newaxis, t] for c in rpf_covs])[0]
      rpf_zscores = rpf.transform([c[np.newaxis, t] for c in rpf_covs])
      rpf_proba = rpf.predict_proba(
          [c[np.newaxis, t] for c in rpf_covs]
      )
      if rp_label == 1:
          rp.partial_fit(rp_covs[np.newaxis, t], alpha=1 / t)
      if rpf_label == 1:
          rpf.partial_fit(
              [c[np.newaxis, t] for c in rpf_covs], 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_t = np.r_[covs_t, time_start]
      covs_z = np.hstack(
          (covs_z, np.vstack((rp_zscore[np.newaxis], rpf_zscores.T)))
      )
      covs_p = np.r_[covs_p, rpf_proba]
      if len(covs_p) > test_covs_visu:
          covs_t, covs_z, covs_p = covs_t[1:], covs_z[:, 1:], covs_p[1:]
  
      # Update plot
      for c in range(ch_count):
          pl[c].set_data(time, sig[c] + eeg_offset[c])
          pl[c].axes.set_xlim(time[0], time[-1])
      for lbl in labels:
          lbl.remove()
      for txt in ax[0].texts:
          txt.set_visible(False)
      labels = plot_detection(ax[0], rp_label, rpf_label)
      for c in range(len(pl2)):
          pl2[c].set_data(covs_t, covs_z[c])
          pl2[c].axes.set_xlim(covs_t[0] - 0.1, covs_t[-1])
      pl3[0].set_data(covs_t, covs_p)
      return pl, pl2, pl3
  
file_path: pyRiemann/examples/artifacts/plot_detect_riemannian_potato_field_EEG.py
imports: import numpy
  from matplotlib import pyplot
  from matplotlib.animation import FuncAnimation
  from mne.datasets import eegbci
  from mne.io import read_raw_edf
  from mne.channels import make_standard_montage
  from mne import make_fixed_length_epochs
  from pyriemann.estimation import Covariances
  from pyriemann.utils.covariance import normalize
  from pyriemann.clustering import Potato, PotatoField
label_desc: Use image node_id 3 for calling a global function with example usage: online_detect(t) and returns: pl,  pl2,  pl3