def project_walk_direction_attitude(ax, ay, az, uw, ux, uy, uz):
    """
    Project accelerometer data on local walk direction by attitude rotation.

    Parameters
    ----------
    ax : list or numpy array
        x-axis accelerometer data
    ay : list or numpy array
        y-axis accelerometer data
    az : list or numpy array
        z-axis accelerometer data
    uw : list or numpy array
        w of attitude quaternion
    ux : list or numpy array
        x of attitude quaternion
    uy : list or numpy array
        y of attitude quaternion
    uz : list or numpy array
        z of attitude quaternion

    Returns
    -------
    px : numpy array
        accelerometer data along x axis projected on unit vector
    py : numpy array
        accelerometer data along y axis projected on unit vector
    pz : numpy array
        accelerometer data along z axis projected on unit vector

    Examples
    --------
    >>> from mhealthx.xio import read_accel_json
    >>> from mhealthx.signals import compute_sample_rate
    >>> input_file = '/Users/arno/DriveWork/mhealthx/mpower_sample_data/deviceMotion_walking_outbound.json.items-a2ab9333-6d63-4676-977a-08591a5d837f5221783798792869048.tmp'
    >>> device_motion = True
    >>> start = 0
    >>> t, axyz, gxyz, wxyz, rxyz, sample_rate, duration = read_accel_json(input_file, start, device_motion)
    >>> ax, ay, az = axyz
    >>> uw, ux, uy, uz = wxyz
    >>> from mhealthx.extractors.pyGait import project_walk_direction_attitude
    >>> px, py, pz = project_walk_direction_attitude(ax, ay, az, uw, ux, uy, uz)

    """
    from mhealthx.extractors.pyGait import walk_direction_attitude, \
        project_axes

    directions = walk_direction_attitude(ax, ay, az, uw, ux, uy, uz)

    vectors = project_axes(zip(ax, ay, az), directions)

    px = [x[0] for x in vectors]
    py = [x[1] for x in vectors]
    pz = [x[2] for x in vectors]

    return px, py, pz
def project_walk_direction_preheel(ax, ay, az, t, sample_rate,
                                   stride_fraction, threshold, order, cutoff):
    """
    Project accelerometer data on local walk (not cardinal) direction.

    NOTE::
        This calls walk_direction_preheel(), which computes a single walk
        direction. It does NOT estimate walking direction for every time
        point, like walk_direction_attitude().

    Parameters
    ----------
    ax : numpy array
        accelerometer data along x axis
    ay : numpy array
        accelerometer data along y axis
    az : numpy array
        accelerometer data along z axis
    t : list or numpy array
        accelerometer time points
    sample_rate : float
        sample rate of accelerometer reading (Hz)
    stride_fraction : float
        fraction of stride assumed to be deceleration phase of primary leg
    threshold : float
        ratio to the maximum summed acceleration to extract peaks
    order : integer
        order of the Butterworth filter
    cutoff : integer
        cutoff frequency of the Butterworth filter (Hz)

    Returns
    -------
    px : numpy array
        accelerometer data along x axis projected on unit vector
    py : numpy array
        accelerometer data along y axis projected on unit vector
    pz : numpy array
        accelerometer data along z axis projected on unit vector

    Examples
    --------
    >>> from mhealthx.xio import read_accel_json
    >>> from mhealthx.extractors.pyGait import project_walk_direction_preheel
    >>> input_file = '/Users/arno/DriveWork/mhealthx/mpower_sample_data/deviceMotion_walking_outbound.json.items-a2ab9333-6d63-4676-977a-08591a5d837f5221783798792869048.tmp'
    >>> device_motion = True
    >>> start = 150
    >>> t, axyz, gxyz, uxyz, rxyz, sample_rate, duration = read_accel_json(input_file, start, device_motion)
    >>> ax, ay, az = axyz
    >>> stride_fraction = 1.0/8.0
    >>> threshold = 0.5
    >>> order = 4
    >>> cutoff = max([1, sample_rate/10])
    >>> px, py, pz = project_walk_direction_preheel(ax, ay, az, t, sample_rate, stride_fraction, threshold, order, cutoff)

    """
    from mhealthx.extractors.pyGait import walk_direction_preheel, \
        project_axes

    directions = walk_direction_preheel(ax, ay, az, t, sample_rate,
                                       stride_fraction, threshold, order,
                                       cutoff, False)

    vectors = project_axes(zip(ax, ay, az), directions)

    px = [x[0] for x in vectors]
    py = [x[1] for x in vectors]
    pz = [x[2] for x in vectors]

    return px, py, pz