docs: def extract_slices(z, freq, sample_freq, show_plot=False):
      """
      Iterates through z trace and pulls out slices of length period_samples
      and assigns them a phase from -180 to 180. Each slice then becomes a column
      in the 2d array that is returned. Such that the row (the first index) refers
      to phase (i.e. dat[0] are all the samples at phase = -180) and the column
      refers to the oscillation number (i.e. dat[:, 0] is the first oscillation).
  
      Parameters
      ----------
      z : ndarray
          trace of z motion
      freq : float
          frequency of motion
      sample_freq : float
          sample frequency of the z array
      show_plot : bool, optional (default=False)
          if true plots and shows the phase plotted against the positon
          for each oscillation built on top of each other.
  
      Returns
      -------
      phase : ndarray
          phase (in degrees) for each oscillation
      phase_slices : ndarray
          2d numpy array containing slices as detailed above.
  
      """
      dt = 1/sample_freq # dt between samples
      period = 1/freq # period of oscillation of motion
      period_samples = round(period/dt) # integer number of discrete samples in a period
      number_of_oscillations = int(_np.floor(len(z)/period_samples)) # number of oscillations in z trace
  
  
      phase_slices_untransposed = _np.zeros([number_of_oscillations-1, period_samples])
  
      phase = _np.linspace(-180, 180, period_samples) # phase assigned to samples
  
      if show_plot == True:
          fig, ax = _plt.subplots()
  
      for i in range(number_of_oscillations-1): 
          # loops through number of oscillations - 1 pulling out period_samples
          # slices and assigning them a phase from -180 to 180 degrees
          start = i*period_samples # start index of section
          end = (i+1)*period_samples # end index of section
          if show_plot == True:
              _plt.plot(phase, z[start:end]) 
          phase_slices_untransposed[i] = z[start:end] # enter z section as ith row
      
      phase_slices = phase_slices_untransposed.transpose() # swap rows and columns 
  
      if show_plot == True:
          _plt.show()
      return phase, phase_slices