Skip to content

Commit

Permalink
remove hand raise
Browse files Browse the repository at this point in the history
  • Loading branch information
suhlrich committed May 30, 2024
1 parent eb59c19 commit e813f17
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions treadmill_gait_analysis/function/gait_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, session_dir, trial_name, leg='auto',
self.markerDict['markers'][marker] = self.markerDict['markers'][marker][:self.idx_trim_end,:]
self.coordinateValues = self.coordinateValues.iloc[:self.idx_trim_end]

# Rotate marker data so x is forward
# Rotate marker data so x is forward (not using for now, but could be useful for some analyses).
self.rotation_about_y, self.markerDictRotated = self.rotate_x_forward()

# Segment gait cycles.
Expand Down Expand Up @@ -812,7 +812,7 @@ def get_coordinates_normalized_time(self):

return coordinateValuesTimeNormalized

def segment_walking(self, n_gait_cycles=-1, leg='auto', visualize=False):
def segment_walking(self, n_gait_cycles=-1, leg='auto', delete_hand_sync_stride=True, visualize=False):

# n_gait_cycles = -1 finds all accessible gait cycles. Otherwise, it
# finds that many gait cycles, working backwards from end of trial.
Expand Down Expand Up @@ -989,6 +989,10 @@ def detect_correct_order(rHS, rTO, lHS, lTO):
gaitEvents_cont = np.zeros((n_gait_cycles, 2),dtype=int)
if n_gait_cycles <1:
raise Exception('Not enough gait cycles found.')

if delete_hand_sync_stride:
r_wrist_rel_y = self.markerDict['markers']['r_mwrist_study'][:,1] - self.markerDict['markers']['r_shoulder_study'][:,1]
l_wrist_rel_y = self.markerDict['markers']['L_mwrist_study'][:,1] - self.markerDict['markers']['L_shoulder_study'][:,1]

for i in range(n_gait_cycles):
# Ipsilateral HS, TO, HS.
Expand Down Expand Up @@ -1026,6 +1030,12 @@ def detect_correct_order(rHS, rTO, lHS, lTO):
' steps until the end. Skipping this step.')
gaitEvents_cont[i,:] = -1
gaitEvents_ips[i,:] = -1

elif delete_hand_sync_stride:
if (np.any(r_wrist_rel_y[gaitEvents_ips[i,0]:gaitEvents_ips[i,2]] > 0.1) or
np.any(l_wrist_rel_y[gaitEvents_ips[i,0]:gaitEvents_ips[i,2]] > 0.1)):
gaitEvents_cont[i,:] = -1
gaitEvents_ips[i,:] = -1

# Remove any nan rows
mask_ips = (gaitEvents_ips == -1).any(axis=1)
Expand Down

0 comments on commit e813f17

Please sign in to comment.