Skip to content

Commit

Permalink
trying to fix big
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinefalisse committed Sep 5, 2023
1 parent 6c7e58b commit 9644e49
Showing 1 changed file with 31 additions and 32 deletions.
63 changes: 31 additions & 32 deletions gait_analysis/function/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import numpy as np

from gait_analysis import gait_analysis
from utils import download_kinematics
from utils import get_trial_id, download_trial


def handler(event, context):
Expand Down Expand Up @@ -52,10 +52,11 @@ def handler(event, context):
specific_trial_names = kwargs['specific_trial_names']

# Specify where to download the data.
data_folder = os.path.join("/tmp/Data", session_id)
sessionDir = os.path.join("/tmp/Data", session_id)

# %% Download data.
trial_names, _ = download_kinematics(session_id, folder=data_folder, trialNames=specific_trial_names)
trial_id = get_trial_id(session_id,specific_trial_names[0])
trial_name = download_trial(trial_id,sessionDir,session_id=session_id)

# Select how many gait cycles you'd like to analyze. Select -1 for all gait
# cycles detected in the trial.
Expand All @@ -69,36 +70,34 @@ def handler(event, context):
'single_support_time','double_support_time'}

# %% Process data.
gait_r = gait_analysis(
sessionDir, trial_name, leg='r',
lowpass_cutoff_frequency_for_coordinate_values=filter_frequency,
n_gait_cycles=n_gait_cycles)
gait_l = gait_analysis(
sessionDir, trial_name, leg='l',
lowpass_cutoff_frequency_for_coordinate_values=filter_frequency,
n_gait_cycles=n_gait_cycles)

gaitResults = {}
for trial_name in trial_names:
gait_r = gait_analysis(
data_folder, trial_name, leg='r',
lowpass_cutoff_frequency_for_coordinate_values=filter_frequency,
n_gait_cycles=n_gait_cycles)
gait_l = gait_analysis(
data_folder, trial_name, leg='l',
lowpass_cutoff_frequency_for_coordinate_values=filter_frequency,
n_gait_cycles=n_gait_cycles)

gaitResults[trial_name] = {}
gaitResults[trial_name]['scalars_r'] = gait_r.compute_scalars(scalar_names)
# gaitResults[trial_name]['curves_r'] = gait_r.get_coordinates_normalized_time()
gaitResults[trial_name]['scalars_l'] = gait_l.compute_scalars(scalar_names)
# gaitResults[trial_name]['curves_l'] = gait_l.get_coordinates_normalized_time()

right_gait_speed = np.round(gaitResults[trial_name]['scalars_r']['gait_speed'], 2)
right_stride_length = np.round(gaitResults[trial_name]['scalars_r']['stride_length'], 2)
right_step_width = np.round(gaitResults[trial_name]['scalars_r']['step_width'], 2)
right_cadence = np.round(gaitResults[trial_name]['scalars_r']['cadence'], 2)
right_single_support_time = np.round(gaitResults[trial_name]['scalars_r']['single_support_time'], 2)
right_double_support_time = np.round(gaitResults[trial_name]['scalars_r']['double_support_time'], 2)

left_gait_speed = np.round(gaitResults[trial_name]['scalars_l']['gait_speed'], 2)
left_stride_length = np.round(gaitResults[trial_name]['scalars_l']['stride_length'], 2)
left_step_width = np.round(gaitResults[trial_name]['scalars_l']['step_width'], 2)
left_cadence = np.round(gaitResults[trial_name]['scalars_l']['cadence'], 2)
left_single_support_time = np.round(gaitResults[trial_name]['scalars_l']['single_support_time'], 2)
left_double_support_time = np.round(gaitResults[trial_name]['scalars_l']['double_support_time'], 2)
gaitResults['scalars_r'] = gait_r.compute_scalars(scalar_names)
# gaitResults['curves_r'] = gait_r.get_coordinates_normalized_time()
gaitResults['scalars_l'] = gait_l.compute_scalars(scalar_names)
# gaitResults['curves_l'] = gait_l.get_coordinates_normalized_time()

right_gait_speed = np.round(gaitResults['scalars_r']['gait_speed'], 2)
right_stride_length = np.round(gaitResults['scalars_r']['stride_length'], 2)
right_step_width = np.round(gaitResults['scalars_r']['step_width'], 2)
right_cadence = np.round(gaitResults['scalars_r']['cadence'], 2)
right_single_support_time = np.round(gaitResults['scalars_r']['single_support_time'], 2)
right_double_support_time = np.round(gaitResults['scalars_r']['double_support_time'], 2)

left_gait_speed = np.round(gaitResults['scalars_l']['gait_speed'], 2)
left_stride_length = np.round(gaitResults['scalars_l']['stride_length'], 2)
left_step_width = np.round(gaitResults['scalars_l']['step_width'], 2)
left_cadence = np.round(gaitResults['scalars_l']['cadence'], 2)
left_single_support_time = np.round(gaitResults['scalars_l']['single_support_time'], 2)
left_double_support_time = np.round(gaitResults['scalars_l']['double_support_time'], 2)

return {
'statusCode': 200,
Expand Down

0 comments on commit 9644e49

Please sign in to comment.