classifiers/gait_classifier.py
def extract_gait_classification_features(window_data_df, channels, fs):
    '''
    Extract signal features applicable for gait classification for a given 3 second window of raw accelerometer data.

    :param window_data_df: Pandas DataFrame with columns ['ts','x','y','z']
    :param channels: Desired channels to run features on (Ex: ['x','y','z'])
    :param fs: Sampling rate of raw accelerometer data (Float)
    :return: DataFrame of calculated features on 3 second windows for given raw data
    '''
    features = pd.DataFrame()

    # Compute signal entropy
    feat_df_signal_entropy = sf.signal_entropy(window_data_df, channels)

    # Compute correlation coefficient
    feat_df_corr_coef = sf.correlation_coefficient(window_data_df, [['x_bp_filt_[0.25, 3.0]', 'y_bp_filt_[0.25, 3.0]'],
                                                                    ['x_bp_filt_[0.25, 3.0]', 'z_bp_filt_[0.25, 3.0]'],
                                                                    ['y_bp_filt_[0.25, 3.0]', 'z_bp_filt_[0.25, 3.0]']])

    # Compute RMS
    feat_df_signal_rms = sf.signal_rms(window_data_df, channels)

    # Compute range
    feat_df_signal_range = sf.signal_range(window_data_df, channels)

    # Compute IQR of Autocovariance
    feat_df_iqr_auto = sf.iqr_of_autocovariance(window_data_df, channels)

    # Compute Dominant Frequency
    sampling_rate = fs
    frequncy_cutoff = 12.0
    feat_df_dom_freq = sf.dominant_frequency(window_data_df, sampling_rate, frequncy_cutoff, channels)

    # Compute mean cross rate
    feat_df_mean_cross_rate = sf.mean_cross_rate(window_data_df, channels)

    # Compute range count percentage
    feat_df_range_count_percentage = sf.range_count_percentage(window_data_df, channels, min_value=-0.1, max_value=0.1)

    features = features.join(feat_df_signal_entropy, how='outer')
    features = features.join(feat_df_corr_coef, how='outer')
    features = features.join(feat_df_signal_rms, how='outer')
    features = features.join(feat_df_signal_range, how='outer')
    features = features.join(feat_df_iqr_auto, how='outer')
    features = features.join(feat_df_dom_freq, how='outer')
    features = features.join(feat_df_mean_cross_rate, how='outer')
    features = features.join(feat_df_range_count_percentage, how='outer')

    return features

    Extract signal features applicable for gait classification for a given 3 second window of raw accelerometer data.

    :param window_data_df: Pandas DataFrame with columns ['ts','x','y','z']
    :param channels: Desired channels to run features on (Ex: ['x','y','z'])
    :param fs: Sampling rate of raw accelerometer data (Float)
    :return: DataFrame of calculated features on 3 second windows for given raw data
    
Extract signal features applicable for gait classification for a given 3 second window of raw accelerometer data.
Extract signal features applicable for gait classification for a given 3 second window of raw accelerometer data .
def extract_gait_classification_features(window_data_df, channels, fs):
    features = pd.DataFrame()
    feat_df_signal_entropy = sf.signal_entropy(window_data_df, channels)
    feat_df_corr_coef = sf.correlation_coefficient(window_data_df, [['x_bp_filt_[0.25, 3.0]', 'y_bp_filt_[0.25, 3.0]'],
                                                                    ['x_bp_filt_[0.25, 3.0]', 'z_bp_filt_[0.25, 3.0]'],
                                                                    ['y_bp_filt_[0.25, 3.0]', 'z_bp_filt_[0.25, 3.0]']])
    feat_df_signal_rms = sf.signal_rms(window_data_df, channels)
    feat_df_signal_range = sf.signal_range(window_data_df, channels)
    feat_df_iqr_auto = sf.iqr_of_autocovariance(window_data_df, channels)
    sampling_rate = fs
    frequncy_cutoff = 12.0
    feat_df_dom_freq = sf.dominant_frequency(window_data_df, sampling_rate, frequncy_cutoff, channels)
    feat_df_mean_cross_rate = sf.mean_cross_rate(window_data_df, channels)
     count percentage
    feat_df_range_count_percentage = sf.range_count_percentage(window_data_df, channels, min_value=-0.1, max_value=0.1)
    features = features.join(feat_df_signal_entropy, how='outer')
    features = features.join(feat_df_corr_coef, how='outer')
    features = features.join(feat_df_signal_rms, how='outer')
    features = features.join(feat_df_signal_range, how='outer')
    features = features.join(feat_df_iqr_auto, how='outer')
    features = features.join(feat_df_dom_freq, how='outer')
    features = features.join(feat_df_mean_cross_rate, how='outer')
    features = features.join(feat_df_range_count_percentage, how='outer')
    return features
def extract_gait_classification_features ( window_data_df , channels , fs ) : features = pd . DataFrame ( ) feat_df_signal_entropy = sf . signal_entropy ( window_data_df , channels ) feat_df_corr_coef = sf . correlation_coefficient ( window_data_df , [ [ 'x_bp_filt_[0.25, 3.0]' , 'y_bp_filt_[0.25, 3.0]' ] , [ 'x_bp_filt_[0.25, 3.0]' , 'z_bp_filt_[0.25, 3.0]' ] , [ 'y_bp_filt_[0.25, 3.0]' , 'z_bp_filt_[0.25, 3.0]' ] ] ) feat_df_signal_rms = sf . signal_rms ( window_data_df , channels ) feat_df_signal_range = sf . signal_range ( window_data_df , channels ) feat_df_iqr_auto = sf . iqr_of_autocovariance ( window_data_df , channels ) sampling_rate = fs frequncy_cutoff = 12.0 feat_df_dom_freq = sf . dominant_frequency ( window_data_df , sampling_rate , frequncy_cutoff , channels ) feat_df_mean_cross_rate = sf . mean_cross_rate ( window_data_df , channels ) feat_df_range_count_percentage = sf . range_count_percentage ( window_data_df , channels , min_value = - 0.1 , max_value = 0.1 ) features = features . join ( feat_df_signal_entropy , how = 'outer' ) features = features . join ( feat_df_corr_coef , how = 'outer' ) features = features . join ( feat_df_signal_rms , how = 'outer' ) features = features . join ( feat_df_signal_range , how = 'outer' ) features = features . join ( feat_df_iqr_auto , how = 'outer' ) features = features . join ( feat_df_dom_freq , how = 'outer' ) features = features . join ( feat_df_mean_cross_rate , how = 'outer' ) features = features . join ( feat_df_range_count_percentage , how = 'outer' ) return features
Extract signal features applicable for gait classification for a given 3 second window of raw accelerometer data.
Extract signal features applicable for gait classification for a given 3 second window of raw accelerometer data .
'''
    Extract signal features applicable for gait classification for a given 3 second window of raw accelerometer data.

    :param window_data_df: Pandas DataFrame with columns ['ts','x','y','z']
    :param channels: Desired channels to run features on (Ex: ['x','y','z'])
    :param fs: Sampling rate of raw accelerometer data (Float)
    :return: DataFrame of calculated features on 3 second windows for given raw data
    ''' # Compute signal entropy # Compute correlation coefficient # Compute RMS # Compute range # Compute IQR of Autocovariance # Compute Dominant Frequency # Compute mean cross rate # Compute range count percentage
DataFrame of calculated features on 3 second windows for given raw data
DataFrame of calculated features on 3 second windows for given raw data
window_data_df
Pandas DataFrame with columns ['ts','x','y','z']
Pandas DataFrame with columns [ ' ts ' ' x ' ' y ' ' z ' ]
channels
Desired channels to run features on (Ex: ['x','y','z'])
Desired channels to run features on ( Ex : [ ' x ' ' y ' ' z ' ] )
fs
Sampling rate of raw accelerometer data (Float)
Sampling rate of raw accelerometer data ( Float )