deeprehab-diagnostics
Diagnostics functions for DeepRehab movement analysis results.
Installation
pip install deeprehab-diagnostics
Usage
Basic Example
from deeprehab_diagnostics import diagnose_movement
# Example angle data from deeprehab-angles package
left_angles = {
"knee": 95.5,
"shoulder": 165.2
}
right_angles = {
"knee": 92.3,
"shoulder": 162.1
}
# Angle series data for stability analysis
angle_series = [
{"knee": 95.5, "shoulder": 165.2},
{"knee": 94.8, "shoulder": 164.7},
{"knee": 95.2, "shoulder": 165.0},
{"knee": 94.9, "shoulder": 164.8}
]
# Perform comprehensive movement diagnostics
result = diagnose_movement("Deep Squat", left_angles, right_angles, angle_series)
print(f"Movement Type: {result.movement_type}")
print(f"Asymmetry Score: {result.asymmetry_score:.2f}")
print(f"Stability Score: {result.stability_score:.2f}")
print(f"Range of Motion: {result.range_of_motion}")
print(f"Recommendations: {result.recommendations}")
print(f"Risk Factors: {result.risk_factors}")
Squat Error Analysis
from deeprehab_diagnostics import analyze_squat_errors, generate_feedback
# Example angle data
angles = {
"left_knee": 115,
"right_knee": 135,
"trunk_tilt": 25
}
# Analyze squat errors
errors = analyze_squat_errors(angles)
print(f"Detected errors: {errors}")
# Generate professional feedback
feedback = generate_feedback(errors)
print(f"Feedback: {feedback}")
Functions
diagnose_movement(movement_type, left_angles, right_angles, angle_series)
Perform comprehensive movement diagnostics.
Parameters:
movement_type: Type of movement being analyzedleft_angles: Dictionary of joint angles for left sideright_angles: Dictionary of joint angles for right sideangle_series: List of dictionaries containing angles for each frame
Returns:
DiagnosticResultwith comprehensive analysis
analyze_movement_symmetry(left_angles, right_angles)
Analyze symmetry between left and right side movements.
Parameters:
left_angles: Dictionary of joint angles for left sideright_angles: Dictionary of joint angles for right side
Returns:
- Asymmetry score (0-1, where 0 is perfectly symmetric)
analyze_movement_stability(angle_series)
Analyze stability of movement across frames.
Parameters:
angle_series: List of dictionaries containing angles for each frame
Returns:
- Stability score (0-1, where 1 is perfectly stable)
generate_recommendations(asymmetry_score, stability_score, range_of_motion)
Generate recommendations based on diagnostic results.
Parameters:
asymmetry_score: Movement asymmetry scorestability_score: Movement stability scorerange_of_motion: Dictionary of joint ranges of motion
Returns:
- List of recommendations
identify_risk_factors(asymmetry_score, stability_score, range_of_motion)
Identify potential risk factors based on diagnostic results.
Parameters:
asymmetry_score: Movement asymmetry scorestability_score: Movement stability scorerange_of_motion: Dictionary of joint ranges of motion
Returns:
- List of identified risk factors
analyze_squat_errors(angles)
Analyze common errors in deep squat movement.
Parameters:
angles: Dictionary containing joint angles and other measurements
Returns:
- Dictionary of detected errors
generate_feedback(errors)
Generate professional rehabilitation feedback based on detected errors.
Parameters:
errors: Dictionary of detected errors from analyze_squat_errors
Returns:
- Professional, concise, and actionable feedback string
Integration with Other DeepRehab Packages
from deeprehab_pose import extract_landmarks
from deeprehab_angles import knee_angle, shoulder_angle
from deeprehab_diagnostics import diagnose_movement, analyze_squat_errors, generate_feedback
# Extract pose landmarks
landmarks_list = extract_landmarks("squat_video.mp4")
# Calculate angles for each frame
angle_series = []
left_angles_first_frame = {}
right_angles_first_frame = {}
for i, landmarks in enumerate(landmarks_list):
left_knee = knee_angle(landmarks, "left")
right_knee = knee_angle(landmarks, "right")
left_shoulder = shoulder_angle(landmarks, "left")
right_shoulder = shoulder_angle(landmarks, "right")
frame_angles = {
"knee": (left_knee + right_knee) / 2,
"shoulder": (left_shoulder + right_shoulder) / 2
}
angle_series.append(frame_angles)
# Save first frame angles for asymmetry analysis
if i == 0:
left_angles_first_frame = {
"knee": left_knee,
"shoulder": left_shoulder
}
right_angles_first_frame = {
"knee": right_knee,
"shoulder": right_shoulder
}
# Perform comprehensive movement diagnostics
result = diagnose_movement(
"Deep Squat",
left_angles_first_frame,
right_angles_first_frame,
angle_series
)
print(f"Movement Analysis Results:")
print(f"- Asymmetry Score: {result.asymmetry_score:.2f}")
print(f"- Stability Score: {result.stability_score:.2f}")
print(f"- Recommendations: {result.recommendations}")
# Analyze squat errors specifically
angles = {
"left_knee": left_angles_first_frame["knee"],
"right_knee": right_angles_first_frame["knee"]
}
errors = analyze_squat_errors(angles)
feedback = generate_feedback(errors)
print(f"Squat Error Feedback: {feedback}")
License
MIT
Metadata
Release files for deeprehab-diagnostics 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| deeprehab_diagnostics-0.1.0.tar.gz | 8.1 kB | Without provenance | Details for deeprehab_diagnostics-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| deeprehab_diagnostics-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for deeprehab_diagnostics-0.1.0-py3-none-any.whl |
Total release size: 15.7 kB
Release files / deeprehab_diagnostics-0.1.0.tar.gz
| Download URL | deeprehab_diagnostics-0.1.0.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3acc8a8803ac68310653632a2d3427ec48f596bec85ca8b7e4f7e1124999c186
|
|
BLAKE2b-256 checksum How to use checksums |
b708785e93bc4e57f2d6d588c6ea80785e919bab7e92ccbc0a3ea7e678b9bdf3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Release files / deeprehab_diagnostics-0.1.0-py3-none-any.whl
| Download URL | deeprehab_diagnostics-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0a3310f1c3b91ed40f28070be633b902830163e858b59a528f352dd9c41445ed
|
|
BLAKE2b-256 checksum How to use checksums |
2e8af1049d391275d47d8942904608bc0635c90208b66e8a2b7ffe89d7bd7bc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Security for deeprehab-diagnostics 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.