From e813f173aaab5b4e04709153f1d4901de7e927df Mon Sep 17 00:00:00 2001 From: suhlrich <43877159+suhlrich@users.noreply.github.com> Date: Wed, 29 May 2024 23:54:59 -0600 Subject: [PATCH] remove hand raise --- treadmill_gait_analysis/function/gait_analysis.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/treadmill_gait_analysis/function/gait_analysis.py b/treadmill_gait_analysis/function/gait_analysis.py index 6f5f1d4..aceb9ed 100644 --- a/treadmill_gait_analysis/function/gait_analysis.py +++ b/treadmill_gait_analysis/function/gait_analysis.py @@ -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. @@ -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. @@ -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. @@ -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)