code: def binarize_signal(signal, treshold="auto", cut="higher"):
      
      if treshold == "auto":
          treshold = (np.max(np.array(signal)) - np.min(np.array(signal)))/2
      signal = list(signal)
      binary_signal = []
      for i in range(len(signal)):
          if cut == "higher":
              if signal[i] > treshold:
                  binary_signal.append(1)
              else:
                  binary_signal.append(0)
          else:
              if signal[i] < treshold:
                  binary_signal.append(1)
              else:
                  binary_signal.append(0)
      return(binary_signal)
docs: Binarize a channel based on a continuous channel.
  
      Parameters
      ----------
      signal = array or list
          The signal channel.
      treshold = float
          The treshold value by which to select the events. If "auto", takes the value between the max and the min.
      cut = str
          "higher" or "lower", define the events as above or under the treshold. For photosensors, a white screen corresponds usually to higher values. Therefore, if your events were signalled by a black colour, events values would be the lower ones, and you should set the cut to "lower".
  
      Returns
      ----------
      list
          binary_signal
  
      Example
      ----------
      >>> import neurokit as nk
      >>> binary_signal = nk.binarize_signal(signal, treshold=4)
  
      Authors
      ----------
      - `Dominique Makowski <https://dominiquemakowski.github.io/>`_
  
      Dependencies
      ----------
      None