forked from Prattbuw/Treadmill_Paper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind_stance.py
More file actions
37 lines (32 loc) · 1.17 KB
/
find_stance.py
File metadata and controls
37 lines (32 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import h5py
import os
import math
#matplotlib inline
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import pandas as pd
import seaborn as sea
import scipy.signal
import read_data as rd
import organize_data as od
import fill_nans as fill
import velocity as vel
import swing_stance as s_s
from scipy import signal
def find_stance(stance_start, stance_end, swing_stance_mat):
for leg in range(0,len(stance_start)):
# use each stance start as a point of reference and find the next stance end point
for stance in range(0,len(stance_start[leg])):
itr=0
# go until the next stance is found
end_idx=0
while stance_end[leg][itr] < stance_start [leg][stance]:
itr=itr+1 # iterate through to find next end
if itr > len(stance_end[leg])-1: # deals with boundary condition
break
if itr > len(stance_end[leg])-1:
swing_stance_mat[leg][stance_start [leg][stance]::]=1
else:
swing_stance_mat[leg][stance_start [leg][stance]:stance_end[leg][itr]]=1
return(swing_stance_mat)