neurokin.utils.kinematics package#

Submodules#

neurokin.utils.kinematics.event_detection module#

neurokin.utils.kinematics.event_detection.get_peak_boundaries_scipy(y: numpy.ndarray, px: float, left_crop: int, relative_height: float) Tuple[int, int][source]#

Computes the boundaries of a step by getting the peaks boundaries

Parameters:
  • y – y values

  • px – peaks indexes

  • left_crop – how many samples to use to crop on the left side

  • relative_height – Chooses the relative height at which the peak width is measured as a percentage of its prominence. 1.0 calculates the width of the peak at its lowest contour line while 0.5 evaluates at half the prominence height. Must be at least 0.

Returns:

returns boundaries of steps

neurokin.utils.kinematics.event_detection.get_toe_lift_landing(y: numpy.typing.ArrayLike, recording_fs: float, step_filter_freq: int, prominence: float, relative_height: float)[source]#

Returns the left and right bounds of the gait cycle, corresponding to the toe lift off and the heel strike. As a first step it smooths the signal to increase robust peak detection.

Parameters:
  • y – trace of the toe in the z coordinate

  • recording_fs – sampling rate of the kinematics recording

  • step_filter_freq – used to filter out very jittery movement which should not represent steps

  • prominence – required minimal prominence of peaks

  • relative_height – Chooses the relative height at which the peak width is measured as a percentage of its prominence. 1.0 calculates the width of the peak at its lowest contour line while 0.5 evaluates at half the prominence height. Must be at least 0.

Returns:

left, right bounds and max value of each peak.

neurokin.utils.kinematics.event_detection.lowpass_array(array, critical_freq, fs)[source]#

Low passes the array for a given frequency using a 2nd order butterworth filter and filtfilt to avoid phase shift.

Parameters:
  • array – input array

  • critical_freq – critical filter frequency

  • fs – sampling frequency

Returns:

filtered array

neurokin.utils.kinematics.event_detection.median_distance(a: numpy.ndarray) numpy.ndarray[source]#

Gets median distance between peaks

Parameters:

a

Returns:

median

neurokin.utils.kinematics.import_export module#

neurokin.utils.kinematics.import_export.create_empty_df(scorer, bodyparts, frames_no)[source]#

Creates empty dataframe to receive 3d data frm c3d file

Parameters:
  • scorer – mock data scorer

  • bodyparts – list of bodyparts that will be in the dataframe

  • frames_no – number of frames

Returns:

empty dataframe with correct shape and columns

neurokin.utils.kinematics.import_export.get_c3d_labels(handle)[source]#

Reads in the labels from a .c3d handle

Parameters:

handle

Returns:

labels

neurokin.utils.kinematics.import_export.import_c3d(path)[source]#

Fills df from c3d file

Parameters:

path – path to .c3d

Returns:

first_frame, last_frame, sample_rate, df

neurokin.utils.kinematics.import_export.import_dlc_df(filename)[source]#

neurokin.utils.kinematics.kinematics_processing module#

neurokin.utils.kinematics.kinematics_processing.check_correct_columns_extraction(actual, expected, side)[source]#
neurokin.utils.kinematics.kinematics_processing.get_unilateral_df(df, side='', name_starts_with=False, name_ends_with=False, column_names=None, expected_columns_number=None)[source]#
neurokin.utils.kinematics.kinematics_processing.shift_correct(df, reference_marker, columns_to_correct)[source]#

If the origin is not set to the beginning of the runway (e.g. set to the center) one of the axis will have negative values. This functions shifts all the columns to be corrected by the minimum value of the reference marker. The reference marker should be the one farther in the back.

neurokin.utils.kinematics.kinematics_processing.tilt_correct(df, reference_marker, columns_to_correct)[source]#

If the runway is not perfectly aligned there can be a linear trend in one of the axis. This function computes the linear trend from a reference marker and applies it to all the columns passed. E.g. use left mtp z axis to compute the trend, then subtract the trend from all columns representing the z axis of a marker.

Module contents#