Skip to content

Commit

Permalink
Add requirements
Browse files Browse the repository at this point in the history
Add examples
  • Loading branch information
André Böni committed Feb 13, 2024
1 parent af09f6f commit ef6af5d
Show file tree
Hide file tree
Showing 11 changed files with 218 additions and 164 deletions.
25 changes: 25 additions & 0 deletions examples/pipeline_hbm_analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os

from gaitalytics import api
from gaitalytics import utils


def main():
settings_file = "settings/hbm_pig.yaml"
buffered_path = "./raw"
out_path = "./spatio_temp"

configs = utils.ConfigProvider(settings_file)

loaded_cycles = api.extract_cycles_buffered(buffered_path, configs)
cycle_data = loaded_cycles.get_raw_cycle_points()

results = api.analyse_data(cycle_data, configs)

if not os.path.exists(out_path):
os.mkdir(out_path)
results.to_csv(f"{out_path}/spatio_temp.csv")


if __name__ == "__main__":
main()
17 changes: 17 additions & 0 deletions examples/pipeline_hbm_events.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from gaitalytics import api
from gaitalytics import utils


def main():
settings_file = "settings/hbm_pig.yaml"
file_path = "./test/data/Baseline.3.c3d"
out_path = "./test/data/"

# load configs
configs = utils.ConfigProvider(settings_file)

api.detect_gait_events(file_path, out_path, configs, show_plot=False)


if __name__ == "__main__":
main()
27 changes: 27 additions & 0 deletions examples/pipeline_hbm_extraction_normalisation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os

from gaitalytics import api
from gaitalytics import utils


def main():
settings_file = "settings/hbm_pig.yaml"
file_path = "./test/data/Baseline.5.c3d"
buffered_path_raw = "./raw"
buffered_path_norm = "./norm"

configs = utils.ConfigProvider(settings_file)
if not os.path.exists(buffered_path_raw):
os.mkdir(buffered_path_raw)
cycle_data = api.extract_cycles(file_path, configs, buffer_output_path=buffered_path_raw)
else:
cycle_data = api.extract_cycles_buffered(buffered_path_raw, configs).get_raw_cycle_points()

if not os.path.exists(buffered_path_norm):
os.mkdir(buffered_path_norm)
api.normalise_cycles(file_path, cycle_data, buffer_output_path=buffered_path_norm)


# __name__
if __name__ == "__main__":
main()
16 changes: 16 additions & 0 deletions examples/pipeline_hbm_modelling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from gaitalytics import utils, api


def main():
settings_file = "settings/hbm_pig.yaml"
file_path = "./tests/data/Baseline.4.c3d"
out_path = "./tests/data/"

# load configs
configs = utils.ConfigProvider(settings_file)

api.model_data(file_path, out_path, configs, methode=api.MODELLING_CMOS, belt_speed=0.8, dominant_leg_length=998)


if __name__ == "__main__":
main()
28 changes: 28 additions & 0 deletions examples/pipline_coherence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from gaitalytics import emg, files

# This is an example pipeline #
###############################

# Define paths
DATA_PATH = "test/data/"
TEST_ORIGIN_FILE_NAME = "1min_emg_walk.c3d"
SETTINGS_PATH = "settings/"
SETTINGS_FILE = "CGM2_5-pyCGM2.settings"


def main():
acq_trial = c3d.read_btk(f"{DATA_PATH}{TEST_ORIGIN_FILE_NAME}")

# Instanciate EMGCoherenceAnalysis objects
coh_left = emg.EMGCoherenceAnalysis(1, 2, "Left") # Verify if good channel indexs
coh_right = emg.EMGCoherenceAnalysis(3, 4, "Right") # Verify if good channel indexs

# Results stored in a tuple of frequencies and coherences
coherence_result_left = coh_left.calculate_coherence(acq_trial)
coherence_result_right = coh_right.calculate_coherence(acq_trial)


# Using the special variable
# __name__
if __name__ == "__main__":
main()
99 changes: 99 additions & 0 deletions settings/hbm_pig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Environment: Motek Caren
# Marker set: HBM2 Lower Body Trunk
# Modelling: PIG
environment_setting:
progression_axes: y
progression_values: negativ

marker_set_mapping:
left_back_hip: LASIS
right_back_hip: RASIS
left_front_hip: LPSIS
right_front_hip: RPSIS

left_lat_upper_leg: LLTHI
right_lat_upper_leg: RLTHI

left_lat_knee: LLEK
right_lat_knee: RLEK
left_med_knee: LMEK
right_med_knee: RMEK

left_lat_lower_leg: LLSHA
right_lat_lower_leg: RLSHA

left_lat_malleoli: LLM
right_lat_malleoli: RLM
left_med_malleoli: LMM
right_med_malleoli: RMM

right_heel: RHEE
left_heel: LHEE
right_meta_2: RMT2
left_meta_2: LMT2
right_meta_5: RMT5
left_meta_5: LMT5

neck: C7
back: T10
jugularis: JN
xyphoideus: XIPH

# Additional markers which will be modelled in modelling.py
com: COM
xcom: XCOM
cmos: CMOS

model_mapping:
#Angles
left_thorax_angles: LThoraxAngles
right_thorax_angles: RThoraxAngles
left_spine_angles: LSpineAngles
right_spine_angles: RSpineAngles
left_pelvis_angles: LPelvisAngles
right_pelvis_angles: RPelvisAngles
left_foot_progression_angles: LFootProgressAngles
right_foot_progression_angles: RFootProgressAngles
left_hip_angles: LHipAngles
right_hip_angles: RHipAngles
left_knee_angles: LKneeAngles
right_knee_angles: RKneeAngles
left_ankle_angles: LAnkleAngles
right_ankle_angles: RAnkleAngles

#Forces
left_GRF: LGroundReactionForce
right_GRF: RGroundReactionForce
left_nGRF: LNormalisedGRF
right_nGRF: RNormalisedGRF
left_waist_force: LWaistForce
right_waist_force: RWaistForce
left_hip_force: LHipForce
right_hip_force: RHipForce
left_knee_force: LKneeForce
right_knee_force: RKneeForce
left_ankle_force: LAnkleForce
right_ankle_force: RAnkleForce

#Moments
left_GRM: LGroundReactionMoment
right_GRM: RGroundReactionMoment
left_waist_moment: LWaistMoment
right_waist_moment: RWaistMoment
left_hip_moment: LHipMoment
right_hip_moment: RHipMoment
left_knee_moment: LKneeMoment
right_knee_moment: RKneeMoment
left_ankle_moment: LAnkleMoment
right_ankle_moment: RAnkleMoment

#Powers
left_waist_power: LWaistPower
right_waist_power: RWaistPower
left_hip_power: LHipPower
right_hip_power: RHipPower
left_knee_power: LKneePower
right_knee_power: RKneePower
left_ankle_power: LAnklePower
right_ankle_power: RAnklePower

7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def read(*names, **kwargs):
with Path(__file__).parent.joinpath(*names).open(encoding=kwargs.get("encoding", "utf8")) as fh:
return fh.read()


setup(
name="gaitalytics",
version="0.0.0",
Expand Down Expand Up @@ -63,6 +62,11 @@ def read(*names, **kwargs):
python_requires=">=3.8",
install_requires=[
"click",
"pandas==2.1.4",
"numpy==1.26.4",
"scipy==1.11.3",
"pyyaml==6.0.1",
"matplotlib==3.8.0",
# eg: "aspectlib==1.1.1", "six>=1.7",
],
extras_require={
Expand All @@ -76,3 +80,4 @@ def read(*names, **kwargs):
]
},
)

Loading

0 comments on commit ef6af5d

Please sign in to comment.