classifiers/gait_classifier.py
def build_gait_classification_feature_set(raw_accelerometer_data_df, fs):
    '''
    Pre-process raw accelerometer data and compute signal based features on data.

    :param raw_accelerometer_data_df: Raw accelerometer data in a Pandas DataFrame wth columns = ['ts','x','y','z']
    :param fs: Sampling rate of raw accelerometer data (Float)
    :return: Pandas DataFrame of calculated features for given raw accelerometer data
    '''
    # Initialize final DataFrame
    final_feature_cache = pd.DataFrame()

    # Pre-process data
    # Bandpass filter between 0.25-3hz
    filtered_data_df = preprocess.band_pass_filter(raw_accelerometer_data_df, fs, [0.25, 3.0], 1,
                                                             channels=['x', 'y', 'z'])
    bp_headers = ['x_bp_filt_[0.25, 3.0]', 'y_bp_filt_[0.25, 3.0]', 'z_bp_filt_[0.25, 3.0]']

    # Perform PCA get 1st principal component for [0.25 - 3] bandpass filtered data
    filtered_data_df = preprocess.get_principal_component(filtered_data_df, channels=bp_headers)
    filtered_data_df.rename(columns={'PC1': 'PC1_[0.25, 3.0]'}, inplace=True)
    pca_headers = ['PC1_[0.25, 3.0]']

    total_data_channels = bp_headers + pca_headers

    # Segment into 3 second windows
    total_samples = filtered_data_df.shape[0]
    window_samples = fs * 3.0
    total_windows = round(total_samples / float(window_samples))

    for win in range(int(total_windows)):
        # Isolate data into windows
        current_win_start = int(window_samples * win + 1)
        current_win_end = int(current_win_start + window_samples - 1)
        if current_win_end > filtered_data_df.shape[0]:
            window_data_df = filtered_data_df.loc[current_win_start:, :]
        else:
            window_data_df = filtered_data_df.loc[current_win_start:current_win_end, :]
        window_data_df.reset_index(drop=True, inplace=True)

        # Extract Bradykinesia Features
        features_df = extract_gait_classification_features(window_data_df, total_data_channels, fs)

        # Discard window if NaN's in feature matrix
        if features_df.isnull().values.any():
            continue

        # Aggregate features for each window
        final_feature_cache = final_feature_cache.append(features_df, ignore_index=True)

    return final_feature_cache

    Pre-process raw accelerometer data and compute signal based features on data.

    :param raw_accelerometer_data_df: Raw accelerometer data in a Pandas DataFrame wth columns = ['ts','x','y','z']
    :param fs: Sampling rate of raw accelerometer data (Float)
    :return: Pandas DataFrame of calculated features for given raw accelerometer data
    
Pre-process raw accelerometer data and compute signal based features on data.
Pre - process raw accelerometer data and compute signal based features on data .
def build_gait_classification_feature_set(raw_accelerometer_data_df, fs):
    final_feature_cache = pd.DataFrame()
    filtered_data_df = preprocess.band_pass_filter(raw_accelerometer_data_df, fs, [0.25, 3.0], 1,
                                                             channels=['x', 'y', 'z'])
    bp_headers = ['x_bp_filt_[0.25, 3.0]', 'y_bp_filt_[0.25, 3.0]', 'z_bp_filt_[0.25, 3.0]']
    filtered_data_df = preprocess.get_principal_component(filtered_data_df, channels=bp_headers)
    filtered_data_df.rename(columns={'PC1': 'PC1_[0.25, 3.0]'}, inplace=True)
    pca_headers = ['PC1_[0.25, 3.0]']
    total_data_channels = bp_headers + pca_headers
    total_samples = filtered_data_df.shape[0]
    window_samples = fs * 3.0
    total_windows = round(total_samples / float(window_samples))
    for win in range(int(total_windows)):
        current_win_start = int(window_samples * win + 1)
        current_win_end = int(current_win_start + window_samples - 1)
        if current_win_end > filtered_data_df.shape[0]:
            window_data_df = filtered_data_df.loc[current_win_start:, :]
        else:
            window_data_df = filtered_data_df.loc[current_win_start:current_win_end, :]
        window_data_df.reset_index(drop=True, inplace=True)
        features_df = extract_gait_classification_features(window_data_df, total_data_channels, fs)
        if features_df.isnull().values.any():
            continue
        final_feature_cache = final_feature_cache.append(features_df, ignore_index=True)
    return final_feature_cache
def build_gait_classification_feature_set ( raw_accelerometer_data_df , fs ) : final_feature_cache = pd . DataFrame ( ) filtered_data_df = preprocess . band_pass_filter ( raw_accelerometer_data_df , fs , [ 0.25 , 3.0 ] , 1 , channels = [ 'x' , 'y' , 'z' ] ) bp_headers = [ 'x_bp_filt_[0.25, 3.0]' , 'y_bp_filt_[0.25, 3.0]' , 'z_bp_filt_[0.25, 3.0]' ] filtered_data_df = preprocess . get_principal_component ( filtered_data_df , channels = bp_headers ) filtered_data_df . rename ( columns = { 'PC1' : 'PC1_[0.25, 3.0]' } , inplace = True ) pca_headers = [ 'PC1_[0.25, 3.0]' ] total_data_channels = bp_headers + pca_headers total_samples = filtered_data_df . shape [ 0 ] window_samples = fs * 3.0 total_windows = round ( total_samples / float ( window_samples ) ) for win in range ( int ( total_windows ) ) : current_win_start = int ( window_samples * win + 1 ) current_win_end = int ( current_win_start + window_samples - 1 ) if current_win_end > filtered_data_df . shape [ 0 ] : window_data_df = filtered_data_df . loc [ current_win_start : , : ] else : window_data_df = filtered_data_df . loc [ current_win_start : current_win_end , : ] window_data_df . reset_index ( drop = True , inplace = True ) features_df = extract_gait_classification_features ( window_data_df , total_data_channels , fs ) if features_df . isnull ( ) . values . any ( ) : continue final_feature_cache = final_feature_cache . append ( features_df , ignore_index = True ) return final_feature_cache
Pre-process raw accelerometer data and compute signal based features on data.
Pre - process raw accelerometer data and compute signal based features on data .
'''
    Pre-process raw accelerometer data and compute signal based features on data.

    :param raw_accelerometer_data_df: Raw accelerometer data in a Pandas DataFrame wth columns = ['ts','x','y','z']
    :param fs: Sampling rate of raw accelerometer data (Float)
    :return: Pandas DataFrame of calculated features for given raw accelerometer data
    ''' # Initialize final DataFrame # Pre-process data # Bandpass filter between 0.25-3hz # Perform PCA get 1st principal component for [0.25 - 3] bandpass filtered data # Segment into 3 second windows # Isolate data into windows # Extract Bradykinesia Features # Discard window if NaN's in feature matrix # Aggregate features for each window
Pandas DataFrame of calculated features for given raw accelerometer data
Pandas DataFrame of calculated features for given raw accelerometer data
raw_accelerometer_data_df
Raw accelerometer data in a Pandas DataFrame wth columns = ['ts','x','y','z']
Raw accelerometer data in a Pandas DataFrame wth columns = [ ' ts ' ' x ' ' y ' ' z ' ]
fs
Sampling rate of raw accelerometer data (Float)
Sampling rate of raw accelerometer data ( Float )