code: def walk_direction_preheel(self, data_frame):
          
  
          # Sum of absolute values across accelerometer axes:
          data = data_frame.x.abs() + data_frame.y.abs() + data_frame.z.abs()
  
          # Find maximum peaks of smoothed data:
          dummy, ipeaks_smooth = self.heel_strikes(data)
          data = data.values
  
          # Compute number of samples between peaks using the real part of the FFT:
          interpeak = compute_interpeak(data, self.sampling_frequency)
          decel = np.int(np.round(self.stride_fraction * interpeak))
  
          # Find maximum peaks close to maximum peaks of smoothed data:
          ipeaks = []
          for ipeak_smooth in ipeaks_smooth:
              ipeak = np.argmax(data[ipeak_smooth - decel:ipeak_smooth + decel])
              ipeak += ipeak_smooth - decel
              ipeaks.append(ipeak)
  
          # Compute the average vector for each deceleration phase:
          vectors = []
          for ipeak in ipeaks:
              decel_vectors = np.asarray([[data_frame.x[i], data_frame.y[i], data_frame.z[i]]
                                          for i in range(ipeak - decel, ipeak)])
              vectors.append(np.mean(decel_vectors, axis=0))
  
          # Compute the average deceleration vector and take the opposite direction:
          direction = -1 * np.mean(vectors, axis=0)
  
          # Return the unit vector in this direction:
          direction /= np.sqrt(direction.dot(direction))
  
          return direction
docs: Estimate local walk (not cardinal) direction with pre-heel strike phase.
  
              Inspired by Nirupam Roy's B.E. thesis: "WalkCompass: Finding Walking Direction Leveraging Smartphone's Inertial Sensors"
  
              :param data_frame: The data frame. It should have x, y, and z columns.
              :type data_frame: pandas.DataFrame
              :return: Unit vector of local walk (not cardinal) direction.
              :rtype: numpy.ndarray