#!/usr/bin/env python # coding: utf-8 # This notebook is used to interactively choose the best parameters for identifying the gait landmarks in each trial. # In[1]: from IPython.html.widgets import interactive from IPython.display import display from IPython.core.pylabtools import figsize import matplotlib.pyplot as plt from gaitanalysis.gait import plot_gait_cycles # In[2]: import sys sys.path.append('../src') # In[3]: import utils # In[4]: get_ipython().run_line_magic('matplotlib', 'inline') # In[5]: trial_number = '016' event = 'Longitudinal Perturbation' # In[6]: trial = utils.Trial(trial_number) # trial.remove_precomputed_data() trial._write_event_data_frame_to_disk(event) trial._write_inverse_dynamics_to_disk(event) # In[7]: gait_data = trial.gait_data_objs[event] # In[8]: window = 1000 last_index = len(gait_data.data) - window # In[9]: from gait_landmark_settings import settings p = settings[trial_number] p # In[10]: def plot_landmarks(filter_frequency=p[0], threshold=p[1], index=0): gait_data.grf_landmarks('FP2.ForY', 'FP1.ForY', filter_frequency=filter_frequency, threshold=threshold) axes = gait_data.plot_landmarks(['FP2.ForY'], 'right', index=index, window=window) # In[11]: figsize(14, 6) # In[12]: w = interactive(plot_landmarks, filter_frequency=(0.0, 50.0, 1.0), threshold=(0.0, 70.0, 1.0), index=(0, last_index, window)) w.msg_throttle = 0 display(w) # In[13]: w.kwargs # In[14]: _ = gait_data.grf_landmarks('FP2.ForY', 'FP1.ForY', filter_frequency=w.kwargs['filter_frequency'], threshold=w.kwargs['threshold']) # In[15]: _ = gait_data.split_at('right', num_samples=20, belt_speed_column='RightBeltSpeed') # In[16]: cols = ['FP2.ForY', 'FP2.MomZ', 'Right.Ankle.PlantarFlexion.Angle', 'Right.Ankle.PlantarFlexion.Rate', 'Right.Ankle.PlantarFlexion.Moment'] # In[17]: figsize(14, len(cols) * 3) # In[18]: axes = gait_data.plot_gait_cycles(*cols) # In[19]: figsize(14, 6) axes = gait_data.gait_cycle_stats['Number of Samples'].hist(bins=50) # In[20]: culled_gait_cycles, culled_gait_cycle_stats = trial._remove_bad_gait_cycles(event) # In[21]: figsize(14, 6) axes = culled_gait_cycle_stats['Number of Samples'].hist(bins=50) # In[22]: figsize(14, len(cols) * 3) # In[23]: axes = plot_gait_cycles(culled_gait_cycles, *cols) # # Footer # In[24]: get_ipython().system('git rev-parse HEAD') # In[25]: get_ipython().system('git --git-dir=/home/moorepants/src/GaitAnalysisToolKit/.git --work-tree=/home/moorepants/src/GaitAnalysisToolKit rev-parse HEAD') # In[26]: get_ipython().run_line_magic('install_ext', 'http://raw.github.com/jrjohansson/version_information/master/version_information.py') # In[27]: get_ipython().run_line_magic('load_ext', 'version_information') # In[28]: get_ipython().run_line_magic('version_information', 'numpy, scipy, pandas, matplotlib, tables, oct2py, dtk, gaitanalysis')