API Reference
This page provides the technical documentation for all ErgoMoCap modules, automatically extracted from the source code docstrings.
Check the Source Code on GitHub: Official Repo | Structural details are accessible at the GUI Architecture Documentation.
Core Calculators
These modules contain the mathematical logic for the ergonomic assessment standards.
REBA (Rapid Entire Body Assessment)
The REBA engine is divided into specific body part modules to calculate localized scores.
Main Calculator Engine
calculators.reba_calculator.REBA_calculator
ErgoMoCap: Biomechanical Scoring Engine (REBA)
Master orchestrator for the Rapid Entire Body Assessment (REBA) pipeline.
This module implements the full REBA calculation logic, transforming 3D skeletal angles into ergonomic risk scores. It organizes the assessment into: - Group A: Trunk, Neck, and Legs. - Group B: Upper Arm, Lower Arm, and Wrist.
The engine utilizes optimized lookup tables and support for Numba-accelerated numerical operations to ensure high-performance processing of MoCap data.
Classes
Functions
calculate_frame_reba_from_degs(degs)
Modular REBA Scoring Entry Point (Vectorized Input).
This function processes pre-calculated biomechanical angles directly, bypassing the kinematic transformation stage. It maps a flat 1D array of degrees to specific body districts, calculates individual penalty scores, and synthesizes the final REBA Risk Index using Numba-accelerated lookup tables (A, B, and C).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degs
|
NDArray[float64]
|
A 1D array containing exactly 22 kinematic values in the following sequence: - [0:2] Legs: [RIGHT_KNEE_EXTENSION_FLEXION, LEFT_KNEE_EXTENSION_FLEXION] - [2:5] Trunk: [SPINE_EXTENSION_FLEXION, SPINE_LATERAL_FLEXION, SPINE_ROTATION_TORSION] - [5:8] Neck: [NECK_EXTENSION_FLEXION, NECK_LATERAL_FLEXION, NECK_ROTATION] - [8:14] Upper Arm: [RIGHT_SHOULDER_EXTENSION_FLEXION, LEFT_SHOULDER_EXTENSION_FLEXION, RIGHT_SHOULDER_ABDUCTION_ADDUCTION, LEFT_SHOULDER_ABDUCTION_ADDUCTION, RIGHT_SHOULDER_RISE, LEFT_SHOULDER_RISE] - [14:16] Lower Arm: [RIGHT_ELBOW_EXTENSION_FLEXION, LEFT_ELBOW_EXTENSION_FLEXION] - [16:22] Wrist: [RIGHT_HAND_EXTENSION_FLEXION, LEFT_HAND_EXTENSION_FLEXION, RIGHT_HAND_LATERAL_SIDE, LEFT_HAND_LATERAL_SIDE, RIGHT_HAND_TWIST, LEFT_HAND_TWIST] |
required |
Returns:
| Type | Description |
|---|---|
tuple[dict[str, int], dict[str, Any]]
|
tuple[dict[str, int], dict[str, Any]]: - final_scores: dictionary containing integer penalty scores for each district plus the "Final_REBA_Score". - degrees_map: Empty dictionary (reserved for API consistency). |
Note
This method is preferred for processing high-frequency offline data where joint angles have already been solved (e.g., FreeMoCap post-processing).
Source code in calculators\reba_calculator\REBA_calculator.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
get_final_reba(score_a, score_b, load=0, activity=0)
Calculates the final REBA score by combining Score A and Score B via Table C.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
score_a
|
int
|
The total score from Group A (including load/force). |
required |
score_b
|
int
|
The total score from Group B (including coupling). |
required |
load
|
int
|
Penalty score for load/force (default: 0). |
0
|
activity
|
int
|
Penalty score for activity/postural instability (default: 0). |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The final REBA Risk Index. |
Source code in calculators\reba_calculator\REBA_calculator.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
get_score_a(trunk, neck, legs)
Performs Table A lookup for Group A (Trunk, Neck, Legs).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trunk
|
int
|
The calculated score for the trunk district. |
required |
neck
|
int
|
The calculated score for the neck district. |
required |
legs
|
int
|
The calculated score for the legs district. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The composite Score A from the REBA matrix. |
Source code in calculators\reba_calculator\REBA_calculator.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
get_score_b(upper_arm, lower_arm, wrist)
Performs Table B lookup for Group B (Arms, Wrists).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
upper_arm
|
int
|
The calculated score for the upper arm. |
required |
lower_arm
|
int
|
The calculated score for the lower arm. |
required |
wrist
|
int
|
The calculated score for the wrist. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The composite Score B from the REBA matrix. |
Source code in calculators\reba_calculator\REBA_calculator.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
options: heading_level: 4
Body Part Sub-modules
calculators.reba_calculator.body_parts.leg_reba
ErgoMoCap: REBA Leg Calculator
Lower limb stability and postural assessment for REBA.
This module provides the logic to evaluate leg support and knee flexion as part of the REBA scoring system. It assesses whether the weight is distributed evenly between both legs and if the degree of knee flexion indicates an unstable or high-strain posture.
The scores generated here contribute to the Group A postural score within the overall REBA methodology.
Functions
leg_reba_score(leg_degrees)
Calculates the REBA (Rapid Entire Body Assessment) score for legs.
The function selects the leg with the highest absolute flexion/degree and applies a score based on specific threshold ranges (30° and 60°).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
leg_degrees
|
NDArray[float64]
|
A 1D NumPy array containing [RIGHT_KNEE_EXTENSION_FLEXION, LEFT_KNEE_EXTENSION_FLEXION]. Expected unit: Degrees as float64. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[int16]
|
NDArray[np.int16]: A 1D NumPy array containing the final REBA leg score [score]. Values are typically 1 or 2. |
Source code in calculators\reba_calculator\body_parts\leg_reba.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
options: heading_level: 4
calculators.reba_calculator.body_parts.lower_arm_reba
ErgoMoCap: REBA Lower Arm Calculator
Lower arm postural assessment for the Rapid Entire Body Assessment (REBA).
This module calculates the scoring for the lower arm component of the REBA method. It evaluates elbow flexion and extension angles to determine the postural risk score for the upper limbs, specifically focusing on identifying the most strained arm to ensure a conservative (worst-case) ergonomic assessment.
The calculator utilizes numpy.ndarray for input/output to maintain compatibility
with the project's high-performance data processing pipelines and is designed
for future numba optimization.
Functions
lower_arm_reba_score(lower_arm_degrees)
Calculates the REBA (Rapid Entire Body Assessment) score for the lower arms.
The function evaluates both arms and selects the score based on the arm with the higher degree of flexion, following standard REBA threshold intervals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lower_arm_degrees
|
NDArray[float64]
|
A 1D NumPy array containing [RIGHT_ELBOW_EXTENSION_FLEXION, LEFT_ELBOW_EXTENSION_FLEXION]. Expected unit: Degrees. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[int16]
|
NDArray[np.int16]: A 1D NumPy array containing the final REBA lower arm score [score]. Values are typically 1 or 2. |
Source code in calculators\reba_calculator\body_parts\lower_arm_reba.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
options: heading_level: 4
calculators.reba_calculator.body_parts.neck_reba
ErgoMoCap: REBA Neck Calculator
Cervical spine postural assessment for the Rapid Entire Body Assessment (REBA).
This module implements the scoring logic for the neck region. It processes three-dimensional angular data including flexion, extension, lateral side-bending, and axial rotation. The final score is a composite value that penalizes non-neutral postures and excessive torsion or lateral deviation.
Key calculations: - Flexion/Extension: Base score determined by the sagittal angle. - Lateral Bending: Penalty score for side-leaning exceeding threshold. - Torsion: Penalty score for axial rotation exceeding threshold.
Functions
neck_reba_score(neck_degrees)
Calculates the REBA (Rapid Entire Body Assessment) score for the neck.
Evaluates flexion/extension, side bending, and twisting to provide a composite score and individual component scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
neck_degrees
|
NDArray[float64]
|
A 1D NumPy array containing [NECK_EXTENSION_FLEXION, NECK_LATERAL_FLEXION, NECK_ROTATION]. Note: Negative flexion values are treated as neck extension. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[int16]
|
NDArray[np.int16]: A 1D NumPy array containing: [total_neck_score, flex_score, side_score, torsion_score]. |
Source code in calculators\reba_calculator\body_parts\neck_reba.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
options: heading_level: 4
calculators.reba_calculator.body_parts.trunk_reba
ErgoMoCap: REBA Trunk Calculator
Thoracic and lumbar postural assessment for the Rapid Entire Body Assessment (REBA).
This module implements the scoring logic for the trunk/spine region. It processes multi-axial angular data including flexion, extension, lateral side-bending, and axial torsion. The final score is a composite value that identifies postural strain in the spine, which serves as a foundational component for the REBA Group A score.
Key calculations: - Flexion/Extension: Categorical scoring based on forward or backward deviation. - Lateral Bending: Binary penalty for any significant lateral deviation. - Torsion: Binary penalty for spinal twisting.
Functions
trunk_reba_score(trunk_degrees)
Calculates the REBA (Rapid Entire Body Assessment) score for the trunk.
Evaluates trunk flexion, extension, side bending, and torsion to provide a total trunk score and its individual components.
NOTE: trunk_degrees input MUST comply with degrees API from freemocap_adapter.py
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trunk_degrees
|
NDArray[float64]
|
A 1D NumPy array containing [SPINE_EXTENSION_FLEXION, SPINE_LATERAL_FLEXION, SPINE_ROTATION_TORSION]. Note: Positive flexion is forward bending; negative is extension. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[int16]
|
NDArray[np.int16]: A 1D NumPy array containing: [total_trunk_score, flex_score, side_score, torsion_score]. |
Source code in calculators\reba_calculator\body_parts\trunk_reba.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
options: heading_level: 4
calculators.reba_calculator.body_parts.upper_arm_reba
ErgoMoCap: REBA Upper Arm Calculator
Shoulder and upper arm postural assessment for the Rapid Entire Body Assessment (REBA).
This module evaluates the ergonomic risk of the upper limbs by analyzing shoulder flexion/extension, abduction/adduction, and shoulder girdle elevation (rise). It employs a "worst-case" selection logic, prioritizing the arm with the greatest deviation from the neutral position to ensure conservative risk estimation.
Calculations include: - Flexion/Extension: Range-based scoring for the humerus. - Abduction: Penalty for arms moving away from the midline of the body. - Shoulder Rise: Penalty for elevated shoulder postures. - Static Support: Adjustments for supported arm postures or leaning.
Functions
upper_arm_reba_score(upper_arm_degrees)
Calculates the REBA (Rapid Entire Body Assessment) score for the upper arms.
Evaluates flexion/extension for both arms (choosing the maximum), and checks for side abduction and shoulder elevation penalties.
NOTE: upper_arm_degrees input MUST comply with degrees API from freemocap_adapter.py
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
upper_arm_degrees
|
NDArray[float64]
|
A 1D NumPy array containing [RIGHT_SHOULDER_EXTENSION_FLEXION, LEFT_SHOULDER_EXTENSION_FLEXION, RIGHT_SHOULDER_ABDUCTION_ADDUCTION, LEFT_SHOULDER_ABDUCTION_ADDUCTION, RIGHT_SHOULDER_RISE, LEFT_SHOULDER_RISE]. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[int16]
|
NDArray[np.int16]: A 1D NumPy array containing: [total_score, flex_score, side_score, shoulder_rise_score]. |
Source code in calculators\reba_calculator\body_parts\upper_arm_reba.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
options: heading_level: 4
calculators.reba_calculator.body_parts.wrist_reba
ErgoMoCap: REBA Wrist Calculator
Distal upper limb postural assessment for the Rapid Entire Body Assessment (REBA).
This module calculates the scoring for the wrist joint, focusing on deviations from the neutral plane. It evaluates flexion, extension, radial/ulnar deviation (side bending), and forearm pronation/supination (torsion). This score is a critical component of the REBA Group B assessment for fine-motor or manual handling tasks.
Key features: - Flexion/Extension: Binary scoring threshold at 15 degrees. - Deviation/Torsion: Individual penalty increments for non-neutral alignments. - Input Compatibility: Processes data typically derived from high-fidelity motion capture or specialized hand-tracking sensors.
Functions
wrist_reba_score(wrist_degrees)
Calculates the REBA (Rapid Entire Body Assessment) score for the wrists.
Evaluates flexion/extension by selecting the wrist with the maximum deviation, and applies penalties for side bending (radial/ulnar deviation) or torsion.
NOTE: wrist_degrees input MUST comply with degrees API from freemocap_adapter.py
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wrist_degrees
|
NDArray[float64]
|
A 1D NumPy array containing [RIGHT_HAND_EXTENSION_FLEXION, LEFT_HAND_EXTENSION_FLEXION, RIGHT_HAND_LATERAL_SIDE, LEFT_HAND_LATERAL_SIDE, RIGHT_HAND_TWIST, LEFT_HAND_TWIST]. |
required |
Returns:
| Type | Description |
|---|---|
NDArray[int16]
|
NDArray[np.int16]: A 1D NumPy array containing: [total_wrist_score, flex_score, side_bend_score, torsion_score]. |
Source code in calculators\reba_calculator\body_parts\wrist_reba.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
options: heading_level: 4
Internal Tables
calculators.reba_calculator.reba_score_tables
ErgoMoCap - Biomechanical Scoring Tables
This module contains the matrix representations of the REBA (Rapid Entire Body Assessment) lookup tables. These tables are used to consolidate partial joint scores into composite risk indices (Score A and Score B), which finally determine the Grand Score (Score C).
The implementation uses NumPy arrays for O(1) lookups. Because the REBA standard uses 1-based indexing for scores, all retrieval functions in this project adjust these values to 0-based indexing for internal array access.
options: heading_level: 4
RULA (Rapid Upper Limb Assessment)
The RULA engine extracts scoring bounds from dedicated body layouts and internal mapping grids.
calculators.rula_calculator.RULA_calculator
ErgoMoCap: RULA Assessment Calculator
Implementation of the Rapid Upper Limb Assessment (RULA) ergonomic method.
This module provides the computational logic to determine postural risk scores based on the RULA standard. It uses a series of lookup tables (Table A, B, and C) to aggregate individual joint scores into a final ergonomic risk value.
The calculator processes 3D skeletal data (angles) to evaluate: - Group A: Upper arms, lower arms, wrists, and wrist twist. - Group B: Neck, trunk, and legs.
Final scores indicate the level of intervention required, ranging from 1 (negligible risk) to 7+ (immediate change required).
Classes
Functions
calculate_frame_rula_from_degs(degs, muscle_score=0, force_score=0, is_arm_supported=False, are_legs_unsupported=False)
Standardized RULA Entry Point using DegsIndexes Enum.
Calculates the complete RULA assessment for a single frame of data by performing lookups in Table A (Upper Limb), Table B (Neck/Trunk/Legs), and Table C (Grand Score).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degs
|
ndarray
|
A 1D |
required |
muscle_score
|
int
|
Static posture or repetition penalty (typically 0 or 1). |
0
|
force_score
|
int
|
Load or force penalty (0, 1, 2, or 3). |
0
|
is_arm_supported
|
bool
|
Whether the upper arm is supported. |
False
|
are_legs_unsupported
|
bool
|
Whether the legs and feet are poorly supported. |
False
|
Raises:
| Type | Description |
|---|---|
IndexError
|
If the |
Returns:
| Type | Description |
|---|---|
tuple[dict[str, int], dict[str, Any]]
|
tuple[dict[str, int], dict[str, Any]]: A tuple containing:
- |
Source code in calculators\rula_calculator\RULA_calculator.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
options: heading_level: 4
calculators.rula_calculator.rula_body_parts
Functions
lower_arm_rula_score(flexion)
Calculates the RULA score for the lower arm based on flexion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flexion
|
float
|
The elbow flexion/extension angle in degrees. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
A score of 1 (60-100°) or 2 (outside range). |
Source code in calculators\rula_calculator\rula_body_parts.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
neck_rula_score(flexion, side_bend, twist)
Calculates the RULA score for the neck.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flexion
|
float
|
The neck flexion/extension angle in degrees. |
required |
side_bend
|
float
|
The neck lateral flexion angle in degrees. |
required |
twist
|
float
|
The neck rotation angle in degrees. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
A score between 1 and 6. |
Source code in calculators\rula_calculator\rula_body_parts.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
trunk_rula_score(flexion, side_bending, torsion)
Calculates the RULA score for the trunk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flexion
|
float
|
The trunk flexion/extension angle in degrees. |
required |
side_bending
|
float
|
The trunk lateral flexion angle in degrees. |
required |
torsion
|
float
|
The trunk rotation/torsion angle in degrees. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
A score between 1 and 6. |
Source code in calculators\rula_calculator\rula_body_parts.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
upper_arm_rula_score(flexion, abduction, shoulder_rise, is_supported)
Calculates the RULA score for the upper arm based on flexion and posture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flexion
|
float
|
The flexion/extension angle in degrees. |
required |
abduction
|
float
|
The abduction/adduction angle in degrees. |
required |
shoulder_rise
|
float
|
The vertical shoulder elevation in degrees. |
required |
is_supported
|
bool
|
Whether the arm is supported or the person is leaning. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
A score between 1 and 6. |
Source code in calculators\rula_calculator\rula_body_parts.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
wrist_rula_score(flexion_extension, side_deviation)
Calculates the RULA score for the wrist based on flexion and deviation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flexion_extension
|
float
|
The wrist flexion/extension angle in degrees. |
required |
side_deviation
|
float
|
The wrist radial/ulnar deviation angle in degrees. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
A score between 1 and 4. |
Source code in calculators\rula_calculator\rula_body_parts.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
wrist_twist_rula_score(twist_degree)
Calculates the RULA score for the wrist based on flexion and deviation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
twist_degree
|
float
|
The wrist twist angle in degrees. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
A score of either 1 or 2. |
Source code in calculators\rula_calculator\rula_body_parts.py
96 97 98 99 100 101 102 103 104 105 106 | |
options: heading_level: 4
calculators.rula_calculator.rula_score_tables
options: heading_level: 4
NIOSH, OCRA, & Specialized Engines
calculators.niosh_calculator.NIOSH_calculator
Functions
calculate_frame_niosh_li(niosh_vars)
TODO: Calculate NIOSh Lifting Index.
Source code in calculators\niosh_calculator\NIOSH_calculator.py
25 26 27 28 29 | |
options: heading_level: 3
calculators.ocra_calculator.OCRA_calculator
Functions
calculate_frame_ocra_index(ocra_vars)
TODO: Calculate OCRA Index.
Source code in calculators\ocra_calculator\OCRA_calculator.py
25 26 27 | |
options: heading_level: 3
calculators.ewas_calculator.EWAS_calculator
Functions
calculate_frame_ewas_score(ewas_vars)
TODO: Calculate EWAS Score.
Source code in calculators\ewas_calculator\EWAS_calculator.py
28 29 30 | |
options: heading_level: 3
calculators.snook_calculator.SNOOK_calculator
Functions
calculate_frame_snook_index(snook_vars)
TODO: Calculate SNOOK Index.
Source code in calculators\snook_calculator\SNOOK_calculator.py
25 26 27 | |
options: heading_level: 3
Calculator Global Utilities
calculators.calculators
Functions
calculate_frame_ewas_score(ewas_vars)
TODO: Calculate EWAS Score.
Source code in calculators\ewas_calculator\EWAS_calculator.py
28 29 30 | |
calculate_frame_niosh_li(niosh_vars)
TODO: Calculate NIOSh Lifting Index.
Source code in calculators\niosh_calculator\NIOSH_calculator.py
25 26 27 28 29 | |
calculate_frame_ocra_index(ocra_vars)
TODO: Calculate OCRA Index.
Source code in calculators\ocra_calculator\OCRA_calculator.py
25 26 27 | |
calculate_frame_reba_from_degs(degs)
Modular REBA Scoring Entry Point (Vectorized Input).
This function processes pre-calculated biomechanical angles directly, bypassing the kinematic transformation stage. It maps a flat 1D array of degrees to specific body districts, calculates individual penalty scores, and synthesizes the final REBA Risk Index using Numba-accelerated lookup tables (A, B, and C).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degs
|
NDArray[float64]
|
A 1D array containing exactly 22 kinematic values in the following sequence: - [0:2] Legs: [RIGHT_KNEE_EXTENSION_FLEXION, LEFT_KNEE_EXTENSION_FLEXION] - [2:5] Trunk: [SPINE_EXTENSION_FLEXION, SPINE_LATERAL_FLEXION, SPINE_ROTATION_TORSION] - [5:8] Neck: [NECK_EXTENSION_FLEXION, NECK_LATERAL_FLEXION, NECK_ROTATION] - [8:14] Upper Arm: [RIGHT_SHOULDER_EXTENSION_FLEXION, LEFT_SHOULDER_EXTENSION_FLEXION, RIGHT_SHOULDER_ABDUCTION_ADDUCTION, LEFT_SHOULDER_ABDUCTION_ADDUCTION, RIGHT_SHOULDER_RISE, LEFT_SHOULDER_RISE] - [14:16] Lower Arm: [RIGHT_ELBOW_EXTENSION_FLEXION, LEFT_ELBOW_EXTENSION_FLEXION] - [16:22] Wrist: [RIGHT_HAND_EXTENSION_FLEXION, LEFT_HAND_EXTENSION_FLEXION, RIGHT_HAND_LATERAL_SIDE, LEFT_HAND_LATERAL_SIDE, RIGHT_HAND_TWIST, LEFT_HAND_TWIST] |
required |
Returns:
| Type | Description |
|---|---|
tuple[dict[str, int], dict[str, Any]]
|
tuple[dict[str, int], dict[str, Any]]: - final_scores: dictionary containing integer penalty scores for each district plus the "Final_REBA_Score". - degrees_map: Empty dictionary (reserved for API consistency). |
Note
This method is preferred for processing high-frequency offline data where joint angles have already been solved (e.g., FreeMoCap post-processing).
Source code in calculators\reba_calculator\REBA_calculator.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
calculate_frame_rula_from_degs(degs, muscle_score=0, force_score=0, is_arm_supported=False, are_legs_unsupported=False)
Standardized RULA Entry Point using DegsIndexes Enum.
Calculates the complete RULA assessment for a single frame of data by performing lookups in Table A (Upper Limb), Table B (Neck/Trunk/Legs), and Table C (Grand Score).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degs
|
ndarray
|
A 1D |
required |
muscle_score
|
int
|
Static posture or repetition penalty (typically 0 or 1). |
0
|
force_score
|
int
|
Load or force penalty (0, 1, 2, or 3). |
0
|
is_arm_supported
|
bool
|
Whether the upper arm is supported. |
False
|
are_legs_unsupported
|
bool
|
Whether the legs and feet are poorly supported. |
False
|
Raises:
| Type | Description |
|---|---|
IndexError
|
If the |
Returns:
| Type | Description |
|---|---|
tuple[dict[str, int], dict[str, Any]]
|
tuple[dict[str, int], dict[str, Any]]: A tuple containing:
- |
Source code in calculators\rula_calculator\RULA_calculator.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
calculate_frame_snook_index(snook_vars)
TODO: Calculate SNOOK Index.
Source code in calculators\snook_calculator\SNOOK_calculator.py
25 26 27 | |
map_fmc_joint_angles_to_ergo_degs(row)
Maps FreeMoCap CSV columns to the flat array expected by REBA_calculator.
This function extracts specific joint angles from a DataFrame row and
organizes them into a structured numpy.ndarray according to the
DegsIndexes schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
Series
|
A single row from a FreeMoCap joint angles DataFrame. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
degs |
ndarray
|
A 22-element |
Source code in calculators\adapters\freemocap_adapter.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
map_fmc_kinematics_to_ewas_vars(body_row)
Maps FreeMoCap joint angles to the variables required for EAWS Section 1.
This adapter extracts trunk and neck angles, ensuring they are narrowed to float types to satisfy static type checkers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body_row
|
Series
|
A single frame of joint angle data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
eaws_vars |
dict[str, float]
|
Cleaned kinematic variables for EAWS calculation. - 'trunk_flexion': Degrees of forward bend. - 'trunk_lateral': Degrees of side bending. - 'neck_flexion': Degrees of neck bend. |
Source code in calculators\adapters\freemocap_adapter.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
map_fmc_kinematics_to_niosh_vars(body_row, load_weight=5.0)
Maps FreeMoCap 3D trajectory data to NIOSH Lifting Equation variables.
This function extracts the geometric spatial relationships between the worker's ankles, hips, and wrists to compute the horizontal, vertical, and asymmetric components of a lift.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body_row
|
Series
|
A single frame from 'mediapipe_body_3d_xyz.csv'. |
required |
load_weight
|
float
|
The weight of the object in kg. Defaults to 5.0. |
5.0
|
Returns:
| Name | Type | Description |
|---|---|---|
niosh_vars |
dict[str, float]
|
dictionary containing: - 'load': Actual mass (kg) - 'H': Horizontal distance (cm/units) - 'V': Vertical height (cm/units) - 'A': Asymmetry angle (degrees) - 'D': Vertical travel (default 0.0 for frame-based) |
Source code in calculators\adapters\freemocap_adapter.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
map_fmc_kinematics_to_ocra_vars(degs)
Translates FreeMoCap kinematic slices into OCRA-specific risk variables.
This mapper isolates upper-limb kinematics and categorizes them into postural 'Technical Actions' based on ISO 11228-3 thresholds. It evaluates both limbs and returns the highest risk found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degs
|
NDArray[float64]
|
A 1D array containing 22 kinematic values. Expected slices: - [8:10] Upper Arm Flexion: [Right, Left] - [10:12] Upper Arm Abduction: [Right, Left] - [14:16] Lower Arm Flexion: [Right, Left] - [16:18] Wrist Flexion/Extension: [Right, Left] - [18:20] Wrist Deviation: [Right, Left] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ocra_flags |
dict[str, any]
|
Boolean risk flags for the scoring engine: - 'shoulder_extreme': True if Flex/Abd > 80°. - 'shoulder_heavy': True if Flex/Abd > 40°. - 'elbow_extreme': True if Flex < 40° or Flex > 150°. - 'wrist_extreme': True if Flex/Ext > 45° or Deviation > 15°. |
Source code in calculators\adapters\freemocap_adapter.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
map_fmc_kinematics_to_snook_vars(body_3d_xyz, event_frames)
Extracts Snook/Liberty Mutual spatial variables from an FMC event segment.
Processes a temporal slice of 3D data to determine vertical travel and average horizontal reach during a specific lifting or lowering event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body_3d_xyz
|
ndarray
|
A [Frames, Joints, 3] |
required |
event_frames
|
tuple[int, int]
|
A |
required |
Returns:
| Name | Type | Description |
|---|---|---|
snook_vars |
dict[str, float]
|
Dictionary with 'v_start_cm', 'v_end_cm', 'v_travel_cm', and 'h_dist_cm'. |
Source code in calculators\adapters\freemocap_adapter.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | |
options: show_root_heading: true heading_level: 3
calculators.calculators_utils.conversion_utils
ErgoMoCap: Measurement Conversion Utilities
Unit normalization and conversion engine for anthropometric and environmental data.
This module provides a robust set of utilities for converting measurements between metric and imperial systems. It uses a base-unit normalization strategy (cm for length, kg for mass, and L for volume) to ensure precision and simplify the internal conversion logic. These utilities are essential for processing user-provided physical attributes and environmental parameters within the ergonomic analysis pipeline.
Key conversion categories: - Length: Supports metric (m, cm, mm) and imperial (inch, foot, yard) units. - Mass: Supports metric (kg, g) and imperial (lb, oz) units. - Volume: Supports metric (L, ml) and imperial (gal, qt) units. - Temperature: Provides precision scaling between Celsius, Fahrenheit, and Kelvin.
Functions
convert_length(value, pre_unit, post_unit)
Converts a length value from one unit to another using a metric base-cm scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
The numeric value to be converted. |
required |
pre_unit
|
str
|
The current unit of the value (e.g., 'm', 'cm', 'inch', 'foot'). |
required |
post_unit
|
str
|
The target unit for the conversion (e.g., 'mm', 'yard', 'cm'). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The converted value, rounded to 4 decimal places. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If either pre_unit or post_unit is not found in the LENGTH_FACTORS registry. |
Source code in calculators\calculators_utils\conversion_utils.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
convert_mass(value, pre_unit, post_unit)
Converts a mass/weight value from one unit to another using a metric base-kg scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
The numeric value to be converted. |
required |
pre_unit
|
str
|
The current unit of the value (e.g., 'kg', 'lb', 'oz'). |
required |
post_unit
|
str
|
The target unit for the conversion (e.g., 'g', 'kg', 'lb'). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The converted value, rounded to 4 decimal places. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If either pre_unit or post_unit is not found in the MASS_FACTORS registry. |
Source code in calculators\calculators_utils\conversion_utils.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
convert_temp(value, pre_unit, post_unit)
Converts a temperature value between Celsius, Fahrenheit, and Kelvin scales.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
The numeric temperature to be converted. |
required |
pre_unit
|
Literal['c', 'f', 'k']
|
The source scale ('c' for Celsius, 'f' for Fahrenheit, 'k' for Kelvin). |
required |
post_unit
|
Literal['c', 'f', 'k']
|
The target scale for the conversion. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The converted temperature, rounded to 2 decimal places. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an unsupported scale is provided. |
Source code in calculators\calculators_utils\conversion_utils.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
convert_volume(value, pre_unit, post_unit)
Converts a volume value from one unit to another using a metric base-L scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
The numeric volume to be converted. |
required |
pre_unit
|
str
|
The current unit of the value (e.g., 'l', 'ml', 'gal'). |
required |
post_unit
|
str
|
The target unit for the conversion (e.g., 'qt', 'l', 'ml'). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The converted value, rounded to 4 decimal places. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If either pre_unit or post_unit is not found in the VOLUME_FACTORS registry. |
Source code in calculators\calculators_utils\conversion_utils.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
options: show_root_heading: true heading_level: 3
calculators.calculators_utils.constants
options: show_root_heading: true heading_level: 3
Data Adapters
Adapters responsible for converting raw sensor, computer vision tracking, or force metrics into calculator-ready formats.
calculators.adapters.freemocap_adapter
ErgoMoCap: FreeMoCap Adapter
Kinematic Mapping and Biomechanical Variable Extraction.
This module acts as the primary translation layer between raw FreeMoCap output formats and the specific input requirements of various ergonomic assessment engines (RULA, REBA, NIOSH, OCRA, EAWS, and Snook).
It provides:
- Index Mapping: A standardized enumeration (DegsIndexes) for internal
kinematic arrays.
- Coordinate Transformation: Calculation of spatial variables like
asymmetry angles relative to the mid-sagittal plane.
- Task Specific Extraction: Specialized mappers that isolate relevant
joint angles and 3D landmarks for different ergonomic standards.
All functions are optimized for use within pandas.DataFrame application
pipelines and maintain strict adherence to biomechanical coordinate
conventions.
Classes
DegsIndexes
Bases: IntEnum
Standardized indices using EXACT FreeMoCap column nomenclature in CAPSLOCK.
This enumeration provides a semantic mapping for the flat kinematic arrays used throughout the ErgoMoCap project. It ensures that indices for legs, trunk, neck, and upper/lower limbs are consistent across different ergonomic calculators (RULA, REBA, EAWS).
Attributes:
| Name | Type | Description |
|---|---|---|
RIGHT_KNEE_EXTENSION_FLEXION |
int
|
Index 0. |
LEFT_KNEE_EXTENSION_FLEXION |
int
|
Index 1. |
SPINE_EXTENSION_FLEXION |
int
|
Index 2. |
SPINE_LATERAL_FLEXION |
int
|
Index 3. |
SPINE_ROTATION_TORSION |
int
|
Index 4. |
NECK_EXTENSION_FLEXION |
int
|
Index 5. |
NECK_LATERAL_FLEXION |
int
|
Index 6. |
NECK_ROTATION |
int
|
Index 7. |
RIGHT_SHOULDER_EXTENSION_FLEXION |
int
|
Index 8. |
LEFT_SHOULDER_EXTENSION_FLEXION |
int
|
Index 9. |
RIGHT_SHOULDER_ABDUCTION_ADDUCTION |
int
|
Index 10. |
LEFT_SHOULDER_ABDUCTION_ADDUCTION |
int
|
Index 11. |
RIGHT_SHOULDER_RISE |
int
|
Index 12. |
LEFT_SHOULDER_RISE |
int
|
Index 13. |
RIGHT_ELBOW_EXTENSION_FLEXION |
int
|
Index 14. |
LEFT_ELBOW_EXTENSION_FLEXION |
int
|
Index 15. |
RIGHT_HAND_EXTENSION_FLEXION |
int
|
Index 16. |
LEFT_HAND_EXTENSION_FLEXION |
int
|
Index 17. |
RIGHT_HAND_LATERAL_SIDE |
int
|
Index 18. |
LEFT_HAND_LATERAL_SIDE |
int
|
Index 19. |
RIGHT_HAND_TWIST |
int
|
Index 20. |
LEFT_HAND_TWIST |
int
|
Index 21. |
Source code in calculators\adapters\freemocap_adapter.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
Functions
calculate_asymmetry_angle_from_sagittal_plane(body_kinematic_row)
Calculates the angular displacement of the load relative to the mid-sagittal plane.
The calculation projects the body's forward orientation and the load position onto the horizontal XZ floor plane. The angle is determined by the displacement of the mid-wrist point relative to the forward vector originating from the mid-ankle point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body_kinematic_row
|
Series
|
Frame data containing 'x' and 'z' 3D coordinates. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
asymmetry_angle_in_degrees |
float
|
The calculated angle in degrees (0 to 180). |
NOTE
USED for NIOSH (TODO maybe put it in the NIOSH folder)
Source code in calculators\adapters\freemocap_adapter.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
map_fmc_joint_angles_to_ergo_degs(row)
Maps FreeMoCap CSV columns to the flat array expected by REBA_calculator.
This function extracts specific joint angles from a DataFrame row and
organizes them into a structured numpy.ndarray according to the
DegsIndexes schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
Series
|
A single row from a FreeMoCap joint angles DataFrame. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
degs |
ndarray
|
A 22-element |
Source code in calculators\adapters\freemocap_adapter.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
map_fmc_kinematics_to_ewas_vars(body_row)
Maps FreeMoCap joint angles to the variables required for EAWS Section 1.
This adapter extracts trunk and neck angles, ensuring they are narrowed to float types to satisfy static type checkers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body_row
|
Series
|
A single frame of joint angle data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
eaws_vars |
dict[str, float]
|
Cleaned kinematic variables for EAWS calculation. - 'trunk_flexion': Degrees of forward bend. - 'trunk_lateral': Degrees of side bending. - 'neck_flexion': Degrees of neck bend. |
Source code in calculators\adapters\freemocap_adapter.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
map_fmc_kinematics_to_niosh_vars(body_row, load_weight=5.0)
Maps FreeMoCap 3D trajectory data to NIOSH Lifting Equation variables.
This function extracts the geometric spatial relationships between the worker's ankles, hips, and wrists to compute the horizontal, vertical, and asymmetric components of a lift.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body_row
|
Series
|
A single frame from 'mediapipe_body_3d_xyz.csv'. |
required |
load_weight
|
float
|
The weight of the object in kg. Defaults to 5.0. |
5.0
|
Returns:
| Name | Type | Description |
|---|---|---|
niosh_vars |
dict[str, float]
|
dictionary containing: - 'load': Actual mass (kg) - 'H': Horizontal distance (cm/units) - 'V': Vertical height (cm/units) - 'A': Asymmetry angle (degrees) - 'D': Vertical travel (default 0.0 for frame-based) |
Source code in calculators\adapters\freemocap_adapter.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
map_fmc_kinematics_to_ocra_vars(degs)
Translates FreeMoCap kinematic slices into OCRA-specific risk variables.
This mapper isolates upper-limb kinematics and categorizes them into postural 'Technical Actions' based on ISO 11228-3 thresholds. It evaluates both limbs and returns the highest risk found.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degs
|
NDArray[float64]
|
A 1D array containing 22 kinematic values. Expected slices: - [8:10] Upper Arm Flexion: [Right, Left] - [10:12] Upper Arm Abduction: [Right, Left] - [14:16] Lower Arm Flexion: [Right, Left] - [16:18] Wrist Flexion/Extension: [Right, Left] - [18:20] Wrist Deviation: [Right, Left] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ocra_flags |
dict[str, any]
|
Boolean risk flags for the scoring engine: - 'shoulder_extreme': True if Flex/Abd > 80°. - 'shoulder_heavy': True if Flex/Abd > 40°. - 'elbow_extreme': True if Flex < 40° or Flex > 150°. - 'wrist_extreme': True if Flex/Ext > 45° or Deviation > 15°. |
Source code in calculators\adapters\freemocap_adapter.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
map_fmc_kinematics_to_snook_vars(body_3d_xyz, event_frames)
Extracts Snook/Liberty Mutual spatial variables from an FMC event segment.
Processes a temporal slice of 3D data to determine vertical travel and average horizontal reach during a specific lifting or lowering event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body_3d_xyz
|
ndarray
|
A [Frames, Joints, 3] |
required |
event_frames
|
tuple[int, int]
|
A |
required |
Returns:
| Name | Type | Description |
|---|---|---|
snook_vars |
dict[str, float]
|
Dictionary with 'v_start_cm', 'v_end_cm', 'v_travel_cm', and 'h_dist_cm'. |
Source code in calculators\adapters\freemocap_adapter.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | |
options: show_root_heading: true heading_level: 3
calculators.adapters.force_adapter
TODO make docstring
Classes
ForceDataAdapter
Adapter to synchronize high-frequency force sensor data with MoCap frames.
This implementation resolves Pylance 'reportArgumentType' by enforcing explicit NumPy float64 casting for the interpolation engine. It ensures that disparate sampling rates between force sensors and motion capture systems are aligned onto a unified temporal grid.
Attributes:
| Name | Type | Description |
|---|---|---|
mocap_df |
DataFrame
|
The primary motion capture data container. |
force_raw |
DataFrame
|
Raw force data loaded from the provided CSV path. |
fps |
int
|
Frames per second of the motion capture data, used for timeline generation. |
Methods:
| Name | Description |
|---|---|
sync_and_tag |
Main entry point to align force data with MoCap timestamps. |
_interpolate_force |
Performs linear interpolation using explicitly casted NumPy arrays. |
_identify_pulses |
Groups continuous exertions into unique Action IDs. |
Source code in calculators\adapters\force_adapter.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
Functions
_identify_pulses(force_array, threshold=10.0)
Groups continuous exertions into unique Action IDs for Section 2.
Identifies segments where force exceeds a specific threshold and assigns a unique integer ID to each contiguous block (pulse). This allows for per-action ergonomic analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force_array
|
ndarray
|
Array of synchronized force values in Newtons. |
required |
threshold
|
float
|
Force value above which an action is considered "active". Defaults to 10.0. |
10.0
|
Returns:
| Name | Type | Description |
|---|---|---|
action_ids |
ndarray
|
An array of |
Source code in calculators\adapters\force_adapter.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
_interpolate_force()
Performs linear interpolation using explicitly casted NumPy arrays.
Resolves: reportArgumentType and reportCallIssue by ensuring all inputs
to numpy.interp are numpy.float64. It maps the high-frequency sensor
time series onto the MoCap timeline.
Returns:
| Name | Type | Description |
|---|---|---|
interp_values |
ndarray
|
The force values interpolated to match MoCap frame timestamps. |
Source code in calculators\adapters\force_adapter.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
sync_and_tag()
Main entry point to align force data with MoCap timestamps.
This method orchestrates the temporal interpolation of force values and the subsequent identification of discrete physical actions based on force thresholds.
Returns:
| Name | Type | Description |
|---|---|---|
mocap_df |
DataFrame
|
The modified DataFrame containing "force_n" and "action_id" columns. |
Source code in calculators\adapters\force_adapter.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
options: show_root_heading: true heading_level: 3
GUI & Layered Architecture System
Detailed component definitions across Presentation, Domain, and Asynchronous Worker execution paths.
Domain Core Logic
gui.core.analysis_engine
ErgoMoCap: Analysis Engine
Core Computational Logic for Ergonomic Assessments.
This module implements the AnalysisEngine class, which serves as the high-performance processing core of the ErgoMoCap project. It utilizes a "Relay" pattern to decouple data iteration from specific ergonomic assessment logic (e.g., RULA, REBA, NIOSH).
By accepting arbitrary mapping and calculation functions, the engine can process
both structured pandas.DataFrame objects from CSV files and raw numpy.ndarray
landmark data exported directly from FreeMoCap.
Key Features
- Agnostic data processing loop for multiple biomechanical standards.
- Real-time risk level categorization using standardized RiskLevel Enums.
- Support for multi-format input handling (Pandas and NumPy).
- Synchronized frame-by-frame metadata generation for analysis reporting.
Classes
AnalysisEngine
Core computational engine for ergonomic assessments.
This engine acts as a high-performance processor that executes mapping and calculation functions provided by external adapters. It handles data iteration across various formats (Pandas DataFrames or NumPy arrays) without internalizing the specific ergonomic logic.
Methods:
| Name | Description |
|---|---|
get_risk_level_enum |
Maps a numerical score to a standardized RiskLevel Enum. |
run_calculation |
Executes a frame-by-frame processing loop for postural analysis. |
Source code in gui\core\analysis_engine.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
Functions
get_risk_level_enum(score, thresholds)
staticmethod
Maps a numerical score to a standardized RiskLevel Enum.
This method performs a range-check against a list of thresholds. It returns an Enum rather than a string to ensure the UI can handle localization (translations) and styling (colors) consistently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
score
|
int
|
The calculated ergonomic value (e.g., REBA total index). |
required |
thresholds
|
list[tuple[int, RiskLevel]]
|
A list of (upper_limit, RiskLevel) tuples, sorted in ascending order. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RiskLevel |
RiskLevel
|
The corresponding standardized RiskLevel category. |
Source code in gui\core\analysis_engine.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
run_calculation(current_data, mapper_func, calculator_func)
Executes a frame-by-frame processing loop for postural analysis.
Handles the "Relay" pattern: 1. Iterates through the input source (DataFrame rows or Array elements). 2. Passes raw data to a 'mapper' to prepare assessment-specific joint data. 3. Passes the mapped data to a 'calculator' to compute ergonomic scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_data
|
DataFrame | ndarray
|
The input source (DataFrame for CSV, ndarray for NPY). |
required |
mapper_func
|
Callable[[Any], Any]
|
Function that transforms a row/frame into the calculator's expected input structure. |
required |
calculator_func
|
Callable[[Any], tuple[dict[str, Any], Any]]
|
Function that computes scores and returns a tuple of (results_dict, metadata). |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: A list of dictionaries, where each dict contains standardized keys for a single frame. |
Source code in gui\core\analysis_engine.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
options: show_root_heading: true
gui.core.session_manager
ErgoMoCap: Session Management
Filesystem Operations and Data Asset Resolution Module.
This module implements the SessionManager class, which provides a high-level API for interacting with the ErgoMoCap and FreeMoCap data structures. It handles the discovery of recording sessions, resolution of associated video and CSV assets, and provides standardized loading mechanisms for analysis data.
The manager integrates with ErgoPaths to ensure cross-platform path resolution and compatibility with frozen environments (e.g., PyInstaller).
Key Features
- Automatic discovery of session directories within defined root paths.
- Heuristic-based resolution of joint angle CSVs and annotated MP4 videos.
- Unified data loading interface for
numpy.ndarrayandpandas.DataFrameformats. - Support for arbitrary external path scanning for portable session review.
Classes
SessionManager
Handles filesystem operations related to ErgoMoCap recording sessions.
This manager abstracts the directory structure of the data storage, providing methods to scan for sessions, resolve specific assets (CSV/Video), and load data files into memory.
Attributes:
| Name | Type | Description |
|---|---|---|
sessions_dir |
Path
|
The base directory where session folders are stored. |
Methods:
| Name | Description |
|---|---|
get_initial_sessions |
Scans the sessions_dir for valid session directories. |
scan_custom_path |
Scans an arbitrary external path for session folders. |
resolve_session_assets |
Locates primary data and video assets within a specific session. |
load_file_data |
Loads session data from the disk based on file extension. |
Source code in gui\core\session_manager.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
Functions
get_initial_sessions()
Scans the sessions_dir for valid session directories.
Filters out hidden directories and non-directory files to identify potential FreeMoCap session folders.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: A list of session directory names found at the root. |
Source code in gui\core\session_manager.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
load_file_data(file_path)
Loads session data from the disk based on file extension.
Supports NumPy (.npy) for raw landmark data and Pandas (.csv) for
calculated angles or scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str | Path
|
The path to the file to load. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Any, Path]
|
tuple[Any, Path]: A tuple containing the loaded object ( |
Raises:
| Type | Description |
|---|---|
ValueError(ValueError)
|
If the file format is not supported ( |
FileNotFoundError(FileNotFoundError)
|
If the provided path does not exist. |
Source code in gui\core\session_manager.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
resolve_session_assets(session_name)
Locates primary data and video assets within a specific session.
This method follows the FreeMoCap output convention, searching for joint angle CSVs in the data folder and MP4s in the video folder as defined by ErgoPaths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_name
|
str
|
The name of the session folder to inspect. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Path | None, str | None, list[str]]
|
tuple[Path | None, str | None, list[str]]: A tuple containing (target_csv, target_video, video_files). |
Source code in gui\core\session_manager.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
scan_custom_path(path)
Scans an arbitrary external path for session folders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
The directory path to scan. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: A list of subdirectories found at the given path. |
Source code in gui\core\session_manager.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
options: show_root_heading: true
gui.core.calculators_adapter
ErgoMoCap: Calculators Adapter
Standardized Interface for Multi-Method Ergonomic Assessments.
This module implements the BaseErgoAdapter pattern, providing a unified pipeline for converting raw FreeMoCap motion data into standardized ergonomic scores. It acts as a structural bridge between disparate biomechanical calculation functions and the ErgoMoCap gui system.
The adapters handle the coordination between data mapping, frame-by-frame calculation, and statistical aggregation for several international standards including REBA, RULA, NIOSH, OCRA, EWAS, and Snook & Ciriello.
Key Features
- Abstract interface for unified execution across different assessment methods.
- Integration with freemocap_adapter for kinematics mapping.
- Automated frequency distribution (stats) calculation for risk level bucketing.
- Standardized output format using MetricType and RiskLevel.
Classes
BaseErgoAdapter
Bases: ABC
Abstract Base Class for ergonomic assessment adapters.
This class handles the standard pipeline of converting raw motion data (DataFrame rows) into ergonomic scores and statistical distributions.
Methods:
| Name | Description |
|---|---|
get_thresholds |
Returns a list of (upper_limit, RiskLevel) tuples for risk bucketing. |
get_relay_tools |
Returns the specific mapping and calculation functions for the method. |
run_on_dataframe |
Iterates through a DataFrame to calculate scores for every frame. |
process |
Converts raw score dictionaries into a processed pandas DataFrame. |
get_stats |
Calculates the frequency distribution of scores across risk levels. |
Source code in gui\core\calculators_adapter.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
Functions
get_relay_tools()
abstractmethod
staticmethod
Returns the specific mapping and calculation functions for the method.
Returns:
| Type | Description |
|---|---|
tuple[Callable, Callable]
|
tuple[Callable, Callable]: (mapping_function, calculation_function) |
Source code in gui\core\calculators_adapter.py
104 105 106 107 108 109 110 111 112 | |
get_stats(scores_list)
classmethod
Calculates the frequency distribution of scores across risk levels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scores_list
|
list[int]
|
A list of numerical scores. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, int]
|
dict[RiskLevel, int]: Mapping of RiskLevel members to frame counts. |
Source code in gui\core\calculators_adapter.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
get_thresholds()
abstractmethod
staticmethod
Returns a list of (upper_limit, RiskLevel) tuples for risk bucketing.
Returns:
| Type | Description |
|---|---|
list[tuple[int, RiskLevel]]
|
list[tuple[int, RiskLevel]]: Thresholds ordered by limit ascending. |
Source code in gui\core\calculators_adapter.py
94 95 96 97 98 99 100 101 102 | |
process(results_list, risk_callback)
classmethod
Converts raw score dictionaries into a processed pandas DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_list
|
list[dict[str, Any]]
|
The raw output from run_on_dataframe. |
required |
risk_callback
|
Callable[[int], RiskLevel]
|
A function to map numerical scores to RiskLevel Enums. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: A DataFrame with standardized score and risk columns. |
Source code in gui\core\calculators_adapter.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
run_on_dataframe(df)
classmethod
Iterates through a DataFrame to calculate scores for every frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input motion data where each row represents one time frame. |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: A list of score dictionaries (one per frame). |
Source code in gui\core\calculators_adapter.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
EWASAdapter
Bases: BaseErgoAdapter
Adapter for Ergo-Work Assessment System (EWAS).
Source code in gui\core\calculators_adapter.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
Functions
get_relay_tools()
staticmethod
Returns tools for EWAS mapping and calculation.
Returns:
| Type | Description |
|---|---|
tuple[Callable, Callable]
|
tuple[Callable, Callable]: (mapper, calculator) functions. |
Source code in gui\core\calculators_adapter.py
282 283 284 285 286 287 288 289 290 | |
get_thresholds()
staticmethod
Returns EWAS score risk thresholds mapped to RiskLevel Enums.
Returns:
| Type | Description |
|---|---|
list[tuple[int, RiskLevel]]
|
list[tuple[int, RiskLevel]]: Threshold limits and levels. |
Source code in gui\core\calculators_adapter.py
292 293 294 295 296 297 298 299 300 301 302 303 | |
NIOSHAdapter
Bases: BaseErgoAdapter
Adapter for NIOSH Lifting Equation.
Source code in gui\core\calculators_adapter.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
Functions
get_relay_tools()
staticmethod
Returns tools for NIOSH mapping and calculation.
Source code in gui\core\calculators_adapter.py
234 235 236 237 238 | |
get_thresholds()
staticmethod
Returns standardized NIOSH lifting index risk thresholds.
Source code in gui\core\calculators_adapter.py
240 241 242 243 244 245 246 247 | |
OCRAAdapter
Bases: BaseErgoAdapter
Adapter for Occupational Repetitive Actions (OCRA) Index.
Source code in gui\core\calculators_adapter.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
Functions
get_relay_tools()
staticmethod
Returns tools for OCRA mapping and calculation.
Returns:
| Type | Description |
|---|---|
tuple[Callable, Callable]
|
tuple[Callable, Callable]: (mapper, calculator) functions. |
Source code in gui\core\calculators_adapter.py
253 254 255 256 257 258 259 260 261 | |
get_thresholds()
staticmethod
Returns OCRA index risk thresholds mapped to RiskLevel Enums.
Returns:
| Type | Description |
|---|---|
list[tuple[int, RiskLevel]]
|
list[tuple[int, RiskLevel]]: Threshold limits and levels. |
Source code in gui\core\calculators_adapter.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
REBAAdapter
Bases: BaseErgoAdapter
Adapter for Rapid Entire Body Assessment (REBA).
Source code in gui\core\calculators_adapter.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
Functions
get_relay_tools()
staticmethod
Returns tools for REBA mapping and calculation.
Source code in gui\core\calculators_adapter.py
195 196 197 198 | |
get_thresholds()
staticmethod
Returns standardized REBA risk thresholds.
Source code in gui\core\calculators_adapter.py
200 201 202 203 204 205 206 207 208 209 | |
RULAAdapter
Bases: BaseErgoAdapter
Adapter for Rapid Upper Limb Assessment (RULA).
Source code in gui\core\calculators_adapter.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
Functions
get_relay_tools()
staticmethod
Returns tools for RULA mapping and calculation.
Source code in gui\core\calculators_adapter.py
215 216 217 218 | |
get_thresholds()
staticmethod
Returns standardized RULA risk thresholds.
Source code in gui\core\calculators_adapter.py
220 221 222 223 224 225 226 227 228 | |
SNOOKAdapter
Bases: BaseErgoAdapter
Adapter for Snook & Ciriello Tables (Lifting/Lowering/Pushing).
Source code in gui\core\calculators_adapter.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
Functions
get_relay_tools()
staticmethod
Returns tools for SNOOK mapping and calculation.
Returns:
| Type | Description |
|---|---|
tuple[Callable, Callable]
|
tuple[Callable, Callable]: (mapper, calculator) functions. |
Source code in gui\core\calculators_adapter.py
309 310 311 312 313 314 315 316 317 | |
get_thresholds()
staticmethod
Returns SNOOK ratio risk thresholds mapped to RiskLevel Enums.
Returns:
| Type | Description |
|---|---|
list[tuple[int, RiskLevel]]
|
list[tuple[int, RiskLevel]]: Threshold limits and levels. |
Source code in gui\core\calculators_adapter.py
319 320 321 322 323 324 325 326 327 328 329 | |
Functions
options: show_root_heading: true
gui.core.report_strategies
ErgoMoCap: Report Strategies
Strategy Pattern Implementation for Multi-Method Ergonomic Reporting.
This module defines the architectural contract and concrete implementations for transforming raw calculation data into display-ready structures. It utilizes the Strategy design pattern to decouple the TableReportWidget from specific assessment logic (RULA, REBA, etc.).
Each strategy is responsible for mapping internal dictionary keys to human-readable labels and defining the visual hierarchy of the generated report tables.
Key Components
ResultRow: The atomic data structure representing a table entry.ReportStrategy: TheProtocoldefining the required interface for all calculators.RulaStrategy: Formatting logic for Rapid Upper Limb Assessment.RebaStrategy: Formatting logic for Rapid Entire Body Assessment.
Classes
RebaStrategy
Transform raw ergonomic data into a list of formatted REBA report rows.
This strategy maps keys specific to the Rapid Entire Body Assessment (REBA) protocol into a structured visual format.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The identifier "REBA". |
Methods:
| Name | Description |
|---|---|
format |
Format RULA specific data into table rows. |
Source code in gui\core\report_strategies.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
Functions
format(data)
Format REBA specific data into table rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, str]
|
A dictionary containing REBA specific keys such as
|
required |
Returns:
| Type | Description |
|---|---|
list[ResultRow]
|
list[ResultRow] (list[ResultRow]): A |
Source code in gui\core\report_strategies.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
ReportStrategy
Bases: Protocol
Protocol defining how to transform raw data into report rows.
Any concrete strategy implemented in calculators must adhere to this interface to ensure compatibility with TableReportWidget.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The display name of the ergonomic assessment method (e.g., "RULA"). |
Methods:
| Name | Description |
|---|---|
format |
Transform raw data into a list of report rows. |
Source code in gui\core\report_strategies.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
Functions
format(data)
Transform raw data into a list of report rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Dictionary containing raw calculation results. |
required |
Returns:
| Type | Description |
|---|---|
list[ResultRow]
|
list[ResultRow] (list[ResultRow]): A list of formatted rows for table rendering. |
Source code in gui\core\report_strategies.py
88 89 90 91 92 93 94 95 96 97 98 | |
ResultRow
dataclass
Standardized data structure for a report row within the ErgoMoCap project.
This dataclass encapsulates the visual and structural properties of a single row in the analysis report tables located in the gui module.
Attributes:
| Name | Type | Description |
|---|---|---|
label |
str
|
The display name of the ergonomic metric. |
value |
Any
|
The actual measurement or score associated with the metric. |
is_header |
bool
|
Whether the row acts as a category separator. Defaults to |
is_critical |
bool
|
Whether the value represents a final risk score requiring highlighting. Defaults to |
is_angle |
bool
|
Whether the value should be formatted with a degree symbol. Defaults to |
Source code in gui\core\report_strategies.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
RulaStrategy
Transform raw ergonomic data into a list of formatted RULA report rows.
This strategy maps keys specific to the Rapid Upper Limb Assessment (RULA) protocol into a structured visual format.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The identifier "RULA". |
Methods:
| Name | Description |
|---|---|
format |
Format RULA specific data into table rows. |
Source code in gui\core\report_strategies.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
Functions
format(data)
Format RULA specific data into table rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, str]
|
A dictionary containing RULA specific keys such as
|
required |
Returns:
| Type | Description |
|---|---|
list[ResultRow]
|
list[ResultRow] (list[ResultRow]): A |
Source code in gui\core\report_strategies.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
options: show_root_heading: true
Presenters (MVP Coordination)
gui.backend.backend
ErgoMoCap: Backend Controller
Central Orchestration and Application Logic Module.
This module implements the ErgoBackend class, which serves as the primary
controller for the ErgoMoCap project. It coordinates asynchronous operations
between the SessionManager, the
AnalysisEngine, and the
VideoWorker.
The backend manages the lifecycle of ergonomic assessments, from launching external FreeMoCap processes to executing multi-method calculations and managing synchronized video playback.
Key Features
- Centralized registry for ergonomic assessment adapters (RULA, REBA, etc.).
- Subprocess management for external FreeMoCap integration.
- Automated session asset resolution and data importation.
- Signal-based communication for real-time GUI updates and error handling.
Classes
ErgoBackend
Bases: QObject
The central controller for the ErgoMoCap application.
Coordinates data loading via SessionManager, triggers ergonomic calculations via the AnalysisEngine using specialized adapters, and manages the VideoWorker.
Attributes:
| Name | Type | Description |
|---|---|---|
frame_ready |
Signal
|
Signal emitted with a FrameData object containing rendering matrices and calculations metadata. |
position_changed |
Signal
|
Signal emitted with a VideoPosition object tracking playback counters. |
session_loaded |
Signal
|
Signal emitted with a SessionData object providing resolved session context. |
error_occurred |
Signal
|
Signal emitted with an ErrorInfo object when processing crashes. |
status_updated |
Signal
|
Signal emitted with a |
playback_state_changed |
Signal
|
Signal emitted with a |
video_load_requested |
Signal
|
Signal emitted with a VideoLoadRequest to initialize a resource context. |
video_control_requested |
Signal
|
Signal emitted with a VideoControl object altering video worker tickers. |
analysis_finished |
Signal
|
Signal Emitted with an AnalysisResult object with ergonomic analysis results. |
freemocap_process |
QProcess | None
|
Running instance handler for the external subprocess, or |
engine |
AnalysisEngine
|
The core computation engine instance AnalysisEngine. |
session_manager |
SessionManager
|
The asset parsing and disk lookup entity SessionManager. |
video_thread |
QThread
|
Dedicated tracking execution runtime loop processing video file buffers. |
video_worker |
VideoWorker
|
Background operational worker parsing video stream indices. |
current_data |
DataFrame | None
|
The currently active dataset metrics container, or |
current_file_path |
Path | None
|
Absolute filesystem location reference path to the loaded matrix data asset. |
scores_list |
list[int]
|
Sequential array structure holding processed single frame evaluation integers. |
Methods:
| Name | Description |
|---|---|
_setup_video_engine |
Initialize or re-initialize the video worker thread infrastructure. |
_ensure_video_engine_ready |
Ensure the video thread is running; restart if needed. |
set_current_method |
Set the internal assessment protocol target selection configuration. |
launch_freemocap |
Launches the external FreeMoCap GUI as a subprocess. |
get_adapter |
Retrieves the adapter class for a specific ergonomic method. |
get_summary_statistics |
Calculates frequency distribution of risk levels for the current scores. |
run_analysis |
The main dispatching logic for ergonomic analysis. |
get_score_list_from_video_source |
Retrieves synchronized scores matching the specific video context. |
load_video_source |
Initializes a new video thread context for the given file path. |
import_joint_data |
Loads CSV or NPY joint data into the backend via the session manager. |
set_root_and_scan |
Scans a custom directory for session folders. |
get_initial_sessions |
Scan the default sessions directory for available session folders. |
load_session_automatically |
Locates and loads all assets for a session (Data + Video). |
export_headless_frames |
Triggers background worker execution frames assembly writing out files. |
Source code in gui\backend\backend.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 | |
Functions
_ensure_video_engine_ready()
Ensure the video thread is running; restart if needed.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Source code in gui\backend\backend.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
_setup_video_engine()
Initialize or re-initialize the video worker thread infrastructure.
Safely handles the lifecycle deletion of pre-existing execution context pipelines, creates isolated instances, links cross-thread execution hooks, and binds worker signals.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Reconstructs internal thread contexts. |
Source code in gui\backend\backend.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
export_headless_frames(video_name, session_name)
Triggers background worker execution frames assembly writing out files.
Kicks off an asynchronous background processing tracking routine extracting matrix overlays and saving raw frame images sequentially into standalone target directories without lockups.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video_name
|
str
|
String file name indicator targeting video selection asset files. |
required |
session_name
|
str
|
Recording grouping label index indicator parameter. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Thread kickoff invocation execution verification tracking parameter indicator status. |
Source code in gui\backend\backend.py
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 | |
get_adapter(method)
Retrieves the adapter class for a specific ergonomic method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
AssessmentMethod
|
The key string of the assessment method (e.g., 'REBA', 'RULA'). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
BaseErgoAdapter |
BaseErgoAdapter
|
The corresponding BaseErgoAdapter subclass. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the requested method key is not found in the registry. |
Source code in gui\backend\backend.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
get_initial_sessions()
Scan the default sessions directory for available session folders.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: A list of session directory names found via the session manager. |
Source code in gui\backend\backend.py
554 555 556 557 558 559 560 561 | |
get_score_list_from_video_source(video_path, method=AssessmentMethod.REBA)
Retrieves synchronized scores matching the specific video context.
Parses targeted source contexts dynamically to match parameters and builds safe fallbacks to universal processing summaries when file checks are missing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video_path
|
str
|
The local system filepath target locating visual recording footage streams. |
required |
method
|
AssessmentMethod
|
Structural targeting calculation metric layout definition. Defaults to AssessmentMethod.REBA. |
REBA
|
TODO change return type to custom model
| Type | Description |
|---|---|
tuple[list[int], list[tuple[int, RiskLevel]]]
|
tuple[list[int], list[tuple[int, RiskLevel]]] (tuple): Composed array elements holding:
* score_list ( |
Source code in gui\backend\backend.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | |
get_summary_statistics(method=AssessmentMethod.REBA)
Calculates frequency distribution of risk levels for the current scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
AssessmentMethod
|
Threshold protocol mapping definitions engine choice. Defaults to AssessmentMethod.REBA. |
REBA
|
Returns:
| Type | Description |
|---|---|
dict[str, int]
|
dict[str, int] (dict): A frequency counts dictionary lookup mapping text evaluation string tags to numerical frame integers. |
Source code in gui\backend\backend.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |
import_joint_data(file_path)
Loads CSV or NPY joint data into the backend via the session manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str | Path
|
Path targeting metric information structures asset data files. |
required |
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str] (tuple): A sequence collection tracking:
* success_status ( |
Source code in gui\backend\backend.py
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | |
launch_freemocap()
Launches the external FreeMoCap GUI as an isolated subprocess, by redispatching the execution path back to the primary compiled executable.
Returns:
| Type | Description |
|---|---|
tuple[bool, str]
|
tuple[bool, str]: A tuple containing (success_status, status_message). |
Source code in gui\backend\backend.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
load_session_automatically(session_name)
Locates and loads all assets for a session (Data + Video).
Automatically identifies joint movement metrics records sheets data sets and selects the core video capture file corresponding to the requested tracking string indicator key parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_name
|
str
|
Label identifier key targeting target recordings assets directory groupings. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
SessionData |
SessionData
|
Unified tracking model layout storing data configuration resolution success variables. |
Source code in gui\backend\backend.py
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | |
load_video_source(path, scores_list=None)
Initializes a new video thread context for the given file path.
Halts ongoing loop cycles safely, binds evaluation scores targets array inputs parameters, and triggers background tracking setup updates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Absolute systemic locator string indicating local video data targets. |
required |
scores_list
|
list[int] | None
|
Sequential score array updates parameter overlay data. Defaults to |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
VideoLoadResult |
VideoLoadResult
|
Structured model detailing file preparation success parameters. |
Source code in gui\backend\backend.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | |
run_analysis(method=AssessmentMethod.REBA)
Dispatches the ergonomic analysis process.
Selects the appropriate adapter, routes motion capture data through the calculation sequence, and delegates the heavy computation to a background worker thread to keep the UI responsive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
AssessmentMethod
|
The assessment method to execute. Defaults to
|
REBA
|
Source code in gui\backend\backend.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
set_current_method(new_method)
Set the internal assessment protocol target selection configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_method
|
AssessmentMethod
|
The targeting enumeration choice selection parameter. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the internal monitoring option property field. |
Source code in gui\backend\backend.py
242 243 244 245 246 247 248 249 250 251 252 | |
set_root_and_scan(path)
Scans a custom directory for session folders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
The directory path to scan. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: A list of session directory names found. |
Source code in gui\backend\backend.py
542 543 544 545 546 547 548 549 550 551 552 | |
options: show_root_heading: true
gui.backend.report_backend
ErgoMoCap: Report Backend
Logic and Data Processing for the ErgoMoCap Report System.
This module handles pure data manipulation (Pandas), metric calculations, and template generation (Jinja2/DocxTemplate). It strictly avoids PySide6 GUI components (like QTextDocument or QPrinter) to ensure it can be safely moved to a QThread for asynchronous execution without causing segfaults.
Key Features
- Asynchronous data parsing for CSV and Excel formats via
pandas.DataFrame. - Thread-safe HTML report rendering using
jinja2environments. - Synchronous DOCX generation with embedded Matplotlib visualizations.
- Heuristic and strict column targeting for RULA/REBA assessment methods.
Classes
ReportBackend
Bases: QObject
Data processing core for the Report module.
This class serves as the backend controller for ergonomic report generation. It
inherits from QObject to facilitate thread-safe communication via signals and
slots, allowing data-intensive operations (like pandas parsing and jinja2
rendering) to be offloaded to background threads. It handles file I/O,
metric aggregation, and template preparation for both PDF and DOCX exports.
Attributes:
| Name | Type | Description |
|---|---|---|
data_processed |
Signal
|
Signal emitted with a ReportData object when data is successfully loaded and processed. |
pdf_html_ready |
Signal
|
Signal emitted with a |
report_export_finished |
Signal
|
Signal emitted with a ReportExportResult instance upon completion of a document export. |
error_occurred |
Signal
|
Signal emitted with an ErrorInfo object when an exception is caught during processing. |
current_file |
Path | None
|
The absolute filesystem |
current_method |
AssessmentMethod
|
The active assessment protocol configuration, defaults to AssessmentMethod.REBA. |
template_dir |
Path
|
The file system path locating the directory containing the Jinja2 and Word templates. |
jinja_env |
Environment
|
The securely configured |
Methods:
| Name | Description |
|---|---|
load_data_and_run |
Asynchronously loads and parses ergonomic data from a given CSV/Excel file. |
prepare_pdf_export |
Compiles the HTML report context using Jinja2 and emits it. |
export_to_docx |
Generates and saves a Word document report synchronously. |
get_chart_distribution_data |
Calculates distributions using strict column targeting based on the active method. |
Source code in gui\backend\report_backend.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | |
Functions
export_to_docx(report_export_request)
Generates and saves a Word document report synchronously.
Utilizes docxtpl to inject calculated dynamic ergonomic metrics and an
inline matplotlib chart layout directly into a pre-defined .docx template.
This operation avoids direct GUI dependencies making it entirely safe for background
thread execution. Completion status is dispatched via the report_export_finished signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report_export_request
|
ReportExportRequest
|
A data model instance containing the target file save path and raw chart image bytes. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Operation results are outputted asynchronously via execution signals. |
Source code in gui\backend\report_backend.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
get_chart_distribution_data(df)
Calculates distributions using strict column targeting based on the active method.
Processes the provided structural dataset to generate frequency counts for nominal risk levels and binned continuous integer score groups matching the target assessment rules (e.g., 1-7 for RULA) for presentation inside frontend graphical visualizations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
The active runtime dataset containing calculated joint metrics and risk assignments. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Series]
|
dict[str, pandas.Series] (dict): A standard dictionary mapping containing two |
Source code in gui\backend\report_backend.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | |
load_data_and_run(file_path)
Asynchronously loads and parses ergonomic data from a given CSV/Excel file.
This method performs heuristic column detection to find risk and score columns
regardless of the assessment method. On success, it calculates primary metrics,
structures them into a data container, and emits the data_processed signal.
If the operation fails, an error_occurred signal containing structural error
details is dispatched.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Path
|
Absolute filesystem path to the source data file (supports |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Results or errors are transmitted asynchronously via Qt Signals. |
Raises:
| Type | Description |
|---|---|
ValueError(ValueError)
|
Raised if the chosen file contains an empty dataset. |
KeyError(KeyError)
|
Raised if critical score or risk tracking columns cannot be identified. |
Source code in gui\backend\report_backend.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
prepare_pdf_export(report_export_request)
Compiles the HTML report context using Jinja2 and emits the generated markup.
This method processes the active dataset file to map internal ergonomic metrics
to template variables. It encodes the binary chart image bytes into a base64
string representation suitable for direct HTML document embedding. The compiled
HTML is transmitted via the pdf_html_ready signal, freeing the background thread
from engaging in unsafe GUI-bound rendering calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report_export_request
|
ReportExportRequest
|
A structured data model instance containing the destination path and chart data. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
The structural HTML content string is emitted via signals. |
Source code in gui\backend\report_backend.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
update_method(method)
Update the active ergonomic assessment method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
AssessmentMethod
|
The name of the method to apply (e.g., AssessmentMethod.RULA, AssessmentMethod.REBA). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates internal state and clears previous strategy if necessary. |
Source code in gui\backend\report_backend.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
Functions
options: show_root_heading: true
Asynchronous Concurrency Workers
gui.workers.analysis_worker
ErgoMoCap: Analysis Engine Worker
Asynchronous Processing Core Wrapper for Ergonomic Calculations.
This module implements the AnalysisWorker, a specialized background execution
component designed to run within a dedicated worker thread. It decouples long-running
frame processing loops, adapter transformations, and system file I/O operations
from the primary user interface layer.
By encapsulating the synchronous AnalysisEngine, the worker handles dispatch requests gracefully using Qt's cross-thread signal slot matrix and dispatches typed structural analysis receipts upon operation boundaries.
Classes
AnalysisWorker
Bases: QObject
Stateful worker managing background ergonomic calculations and file serialization.
This component runs inside its own dedicated worker thread managed by the application backend.
It provisions an internal AnalysisEngine instance, extracts programmatic tools via
external methodology adapters, and updates application state domains via asynchronous signals.
Attributes:
| Name | Type | Description |
|---|---|---|
finished |
Signal
|
Signal emitted on calculation cycle completions tracking structural receipts (AnalysisResult). |
engine |
AnalysisEngine
|
Core non-blocking calculation engine execution instance. |
_pending_data |
DataFrame | ndarray | None
|
Temporary storage buffer for input metrics queued before thread execution. |
_pending_adapter |
BaseErgoAdapter | None
|
Temporary storage buffer for the methodology adapter queued before thread execution. |
_pending_method |
AssessmentMethod | None
|
Temporary storage buffer for the assessment protocol queued before thread execution. |
Methods:
| Name | Description |
|---|---|
run |
Parameterless entry point for queued execution on the worker thread. |
start_analysis |
Thread-safe public entry execution slot accepting runtime processing parameters. |
Source code in gui\workers\analysis_worker.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
Functions
run()
Parameterless entry point for queued execution on the worker thread.
Extracts runtime parameters from internal staging buffers, clears references to free memory, and delegates execution to the core analysis routine. This design bypasses Qt's meta-type serialization constraints for complex objects like pandas DataFrames.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Delegates to |
Source code in gui\workers\analysis_worker.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
start_analysis(current_data, adapter, method=AssessmentMethod.REBA)
Executes the main dispatching background routine for ergonomic processing.
Routes raw metrics through data mapping functions, loops frames asynchronously, compiles structured analysis tracking matrices, and posts unified diagnostic receipts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_data
|
DataFrame | ndarray
|
The raw matrix or sheet data tracking biomechanical data elements. |
required |
adapter
|
BaseErgoAdapter
|
The methodology adapter class mapping scoring routines and criteria. |
required |
method
|
AssessmentMethod
|
Structural framework metric enumeration settings tracking computation variants. Defaults to REBA. |
REBA
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Dispatches output results directly back upstream using the |
Source code in gui\workers\analysis_worker.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
options: show_root_heading: true
gui.workers.video_worker
ErgoMoCap: Video Engine Worker
Stateful Video I/O and Telemetry Synchronization Engine.
This module implements the VideoWorker, a specialized background execution component
designed to run within a dedicated worker thread. It isolates heavy file system operations,
frame decoding using OpenCV, and unthrottled media encoding workflows from the primary
user interface thread.
By utilizing a non-blocking QTimer lifecycle architecture rather than blocking loops,
the worker delivers fluid playback frame buffers synchronized frame-by-frame with
precalculated ergonomic risk metrics and categorical data payloads.
Classes
VideoWorker
Bases: QObject
Stateful worker managing video I/O, scoring overlays, and frame exporting.
This component runs inside its own dedicated worker thread managed by the application backend.
It uses a non-blocking QTimer lifecycle architecture to decode media frames sequentially,
synchronize them with risk metadata matrices, and emit rendering capsules to the GUI layer.
Attributes:
| Name | Type | Description |
|---|---|---|
frame_ready |
Signal
|
Signal emitted when a new frame is decoded and processed (FrameData). |
position_changed |
Signal
|
Signal emitted on playback updates containing timeline values (VideoPosition). |
export_progress |
Signal
|
Signal emitted to track frame write cycles (VideoPosition). |
frames_export_finished |
Signal
|
Signal emitted on export completion (FramesExportResult). |
cap |
VideoCapture | None
|
The open file stream capture decoder wrapper instance. |
video_path |
str
|
File system path pointing to the active media asset. |
scores_list |
list[int]
|
Array sequence tracking calculated analytical scores matching frame indices. |
thresholds |
list[tuple[int, Any]]
|
Boundary score structures used to determine qualitative classification steps. |
total_frames |
int
|
Total frame count value assigned by the video header stream analyzer. |
current_frame_idx |
int
|
Current frame playback pointer index counter. |
playback_timer |
QTimer | None
|
Internal non-blocking loop scheduler driving periodic frame steps. |
Methods:
| Name | Description |
|---|---|
init_timer |
Create and initialize the internal timer inside the worker thread space. |
initialize_video |
Configures the current video asset context safely. |
cleanup |
Shuts down any active playback intervals and releases open media stream file handles. |
handle_video_control |
Processes video commands safely inside the worker thread. |
toggle_playback |
Starts or stops the frame ticker timer. |
seek |
Public slot accepting external target navigation frames. |
step_frame |
Steps sequentially up or down one tick. |
_seek_to_index |
Updates internal stream pointers and reads video matrix segments. |
_process_playback_frame |
Handles cyclic timer ticks to read, increment, and emit media data frames. |
_emit_current_frame_payload |
Bundles spatial features and risk labels into metadata packets. |
execute_frames_export |
Runs an unthrottled loop to combine frame saving and rendering into a single worker script. |
Source code in gui\workers\video_worker.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
Functions
_emit_current_frame_payload(frame)
Bundles spatial features and risk labels into metadata packets.
Evaluates index points against calculated assessment tables, extracts structural enum items via AnalysisEngine.get_risk_level_enum, and emits telemetry packages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
ndarray
|
Multi-dimensional matrix array tracking pixel layouts. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Dispatches tracking telemetry signals out to attached subscribers. |
Source code in gui\workers\video_worker.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
_process_playback_frame()
Handles cyclic timer ticks to read, increment, and emit media data frames.
Monitors frame index bounds and terminates timer execution loops automatically if end-of-file flags or validation faults occur during extraction.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Advances timeline state metrics or halts active timers. |
Source code in gui\workers\video_worker.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
_seek_to_index(frame_idx)
Updates internal stream pointers and reads video matrix segments.
Handles hardware pointer relocations inside cv2.VideoCapture wrappers and invokes
the payload packager instantly to prevent rendering lag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame_idx
|
int
|
Clean target bounding parameter mapping specific file indexes. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Restores layout tracking bounds. |
Source code in gui\workers\video_worker.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
cleanup()
Shuts down any active playback intervals and releases open media stream file handles.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
In-place cleanup execution wrapper. |
Source code in gui\workers\video_worker.py
168 169 170 171 172 173 174 175 176 177 178 179 | |
execute_frames_export(output_path)
Runs an unthrottled loop to combine frame saving and rendering into a single worker script.
Freezes interactive timeline cycles, sets file structures up via cv2.VideoWriter, and loops
sequentially through every frames slice to serialize an overlay-ready raw output file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_path
|
str
|
Intended file system path string destination where the generated media output should reside. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Emits asynchronous progress telemetry bundles during processing. |
Source code in gui\workers\video_worker.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
handle_video_control(action)
Processes video commands safely inside the worker thread.
Parses incoming action commands to adjust playback states, perform hard index skips, or step through sequential frames frame-by-frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
VideoControl
|
Message bundle specifying state commands mapped by VideoControl. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Performs state routing and state updates. |
Source code in gui\workers\video_worker.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
init_timer()
Create and initialize the internal timer inside the worker thread space.
Instantiates the QTimer framework container directly inside the executing thread context
to maintain thread-safe affinity boundaries and hooks up the loop timeout callback.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Modifies the object state in-place. |
Source code in gui\workers\video_worker.py
109 110 111 112 113 114 115 116 117 118 119 120 121 | |
initialize_video(video_load_request)
Configures the current video asset context safely.
Resets ongoing playback loops, releases any pre-allocated system video capture handles, parses technical properties from the target file configuration payload, and renders the initial frame slice.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video_load_request
|
VideoLoadRequest
|
Configuration descriptor mapping paths, scores, and boundaries via VideoLoadRequest. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Dispatches a preview frame or reinitializes structural attributes. |
Source code in gui\workers\video_worker.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
seek(frame_idx)
Public slot accepting external target navigation frames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame_idx
|
int
|
Absolute destination index path targeting targeted index segments. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Dispatches internal seek handlers. |
Source code in gui\workers\video_worker.py
240 241 242 243 244 245 246 247 248 249 250 251 | |
step_frame(forward)
Steps sequentially up or down one tick.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
forward
|
bool
|
Set to True to increment the timeline frame index, False to decrement. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Dispatches updated coordinate mappings. |
Source code in gui\workers\video_worker.py
253 254 255 256 257 258 259 260 261 262 263 264 265 | |
toggle_playback()
Starts or stops the frame ticker timer.
Evaluates operational flags, state loops, and active timers to cleanly toggle periodic media processing routines.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
`bool`
|
True if a timer sequence successfully started, False if it was paused or failed. |
Source code in gui\workers\video_worker.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
options: show_root_heading: true
gui.workers.frames_export_worker
ErgoMoCap: Frames Export Worker
Headless frame serialization and data synchronization utilities.
This module provides multithreaded and headless components designed to extract individual frame buffers from video recording files, write them to disk, and synchronize them with calculated ergonomic metrics into manageable data frames.
Classes
FramesExportWorker
Bases: QObject
Asynchronous worker for executing frame extraction operations inside a background thread.
Manages the operational state lifecycle of a headless extraction run, providing cooperative cancellation hooks and proxying progress telemetry via Qt Signals to avoid blocking the primary user interface thread.
Attributes:
| Name | Type | Description |
|---|---|---|
finished |
Signal
|
Signal emitted when the frame extraction sequence completes. |
progress |
Signal
|
Signal emitted every 5 frames containing a VideoPosition state telemetry capsule. |
video_path |
Path | str
|
File system path referencing the source video capture file. |
frames_dir |
Path
|
Destination folder path where image frames will be written. |
scores_list |
list[int]
|
Ordered sequence of calculated ergonomic risk scores. |
_is_running |
bool
|
Internal control flag indicating active thread processing state. |
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the worker instance with data paths and scores. |
stop |
Request a cooperative cancellation of the running extraction routine. |
run |
Execute the headless frame extraction loop and serialize synchronized telemetry. |
Source code in gui\workers\frames_export_worker.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
Functions
run()
Execute the headless frame extraction loop and serialize synchronized telemetry.
Launches the core engine runner, tracks progress metrics via signal emitters, and upon valid completion writes out a structured mapping index file using pandas.DataFrame.to_csv.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Dispatches lifecycle termination signals to the main listener thread. |
Source code in gui\workers\frames_export_worker.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
stop()
Request a cooperative cancellation of the running extraction routine.
Sets the internal execution flags to false, prompting the underlying headless processor loop to break operations at the next evaluation interval.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the internal running state. |
Source code in gui\workers\frames_export_worker.py
87 88 89 90 91 92 93 94 95 96 97 | |
Functions
export_frames_headless(video_path, output_folder, scores_list=[], progress_callback=None, should_stop=None)
Headless pipeline to extract frames sequentially and compile an indexed telemetry dataset.
Parses raw video frames using cv2.VideoCapture, serializes compressed jpeg imagery
directly to disk, and returns a cumulative pandas.DataFrame correlating index positions
to associated risk profiles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video_path
|
Path | str
|
File system path referencing the source video capture file. |
required |
output_folder
|
Path | str
|
Target filesystem directory where frame slices should reside. |
required |
scores_list
|
list[int]
|
Optional ordered array containing specific ergonomic scores per frame index. Defaults to |
[]
|
progress_callback
|
Callable[[VideoPosition], None] | None
|
Callback function invoked with VideoPosition elements every 5 processed loops. Defaults to |
None
|
should_stop
|
Callable[[], bool] | None
|
Lambda function evaluated at loop cycle boundaries to handle execution abort requests. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pandas.DataFrame ( |
Source code in gui\workers\frames_export_worker.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
options: show_root_heading: true
Passive Views & Reusable UI Components
gui.frontend
ErgoMoCap Main Application Window
Primary user interface controller and orchestration layer for ErgoMoCap.
This module implements the MainWindow, which coordinates interactions between the
ergonomic configuration sidebar, the video rendering canvas, and the background execution
engine (ErgoBackend). It manages the top-level window lifecycle, application-wide themes,
asynchronous thread cleanup, and shortcuts.
Classes
MainWindow
Bases: QMainWindow
The primary application window for the ErgoMoCap GUI.
This class manages the user interface, handles interactions between the sidebar controls and the video canvas, and coordinates with the ErgoBackend for data processing and analysis.
Attributes:
| Name | Type | Description |
|---|---|---|
backend |
ErgoBackend
|
The core logic handler for data and video processing. |
current_theme |
ErgoTheme
|
Tracks the active UI theme ('dark' or 'light'). |
report_window |
ReportView
|
A persistent window instance for displaying results. |
canvas |
VideoCanvas
|
The central widget for video rendering. |
menu_actions |
MenuActions
|
Logic handler for menu bar commands. |
sidebar |
ErgoSidebar
|
The left-hand control panel for user input. |
_menu_bar |
MenuBar
|
The top-level application menu bar. |
Methods:
| Name | Description |
|---|---|
setup_ui |
Constructs the main layout and widget hierarchy. |
handle_reboot |
Restarts the application process. |
kill_running_threads |
Safely terminates active backend threads. |
safe_close |
Safely terminates running threads and closes the main window. |
handle_new_recording |
Placeholder for starting a new capture session. |
handle_load_recording |
Placeholder for loading existing recordings. |
open_settings |
Placeholder for the settings configuration window. |
open_docs |
Opens the locally shipped documentation homepage. |
open_tutorial |
Opens the locally shipped tutorial page. |
open_source |
Opens the live GitHub repository on the web. |
connect_signals |
Establishes connections between UI signals and handlers. |
toggle_theme |
Switches the UI between dark and light stylesheets. |
toggle_sidebar |
Shows or hides the ergonomic sidebar. |
init_root |
Sets up the initial data directory and scans for sessions. |
handle_select_root |
Slot to update the data root directory. |
handle_session_selected |
Slot to load data for a specific session. |
handle_video_selection_changed |
Slot to switch the active video source. |
handle_load_video |
Slot to manually browse for a video file. |
_reconnect_video_signals |
Internal helper to manage frame stream connections. |
step_video |
Sends a relative step request to the backend safely across threads. |
keyPressEvent |
Overrides keyboard interaction to trigger shortcuts. |
_handle_canvas_seek |
Handles the seek request from the video canvas overlay. |
handle_toggle_video |
Slot to play or pause video playback. |
handle_run_fmc |
Slot to trigger external FreeMoCap processing. |
handle_import |
Slot to manually import joint data files. |
show_report |
Displays the analysis reporting window. |
run_analysis |
Triggers the ergonomic calculation engine. |
_update_export_status |
Unified status formatter for background processing. |
handle_headless_export |
Delegates frame export processing to the backend. |
Source code in gui\frontend.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 | |
Functions
_handle_analysis_finished(result)
Handles the analysis_finished signal from the backend.
Processes the AnalysisResult emitted by the
backend after the asynchronous calculation completes. It updates the UI state,
triggers frame exports if requested, and displays the report window. This slot
always executes on the main UI thread via a queued connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
AnalysisResult
|
The analysis result containing the success status, message, output path, and optional scores or stats. |
required |
Source code in gui\frontend.py
753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 | |
_handle_canvas_seek(frame_idx)
Handles the seek request from the video canvas overlay.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame_idx
|
int
|
Target frame absolute indexing point. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Dispatches a structured |
Source code in gui\frontend.py
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | |
_reconnect_video_signals()
Helper to safely handle frame connections.
Ensures that the frame_ready signal from the backend is correctly
routed to the VideoCanvas.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Re-establishes signal connections. |
Source code in gui\frontend.py
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
_update_export_status(current, total)
Unified status formatter for processing progress indicators. (1/10 or 10%)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current
|
int
|
Current frame index processed. |
required |
total
|
int
|
Comprehensive index total. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Textually reformats the application sidebar status bar. |
Source code in gui\frontend.py
796 797 798 799 800 801 802 803 804 805 806 807 808 809 | |
connect_signals()
Wiring the Sidebar Public API to the existing MainWindow handlers.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Establishes Qt signal-slot connections. |
Source code in gui\frontend.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
handle_headless_export()
Gathers UI state parameters and delegates frame export processing to the backend.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Launches asynchronous background calculations. |
Source code in gui\frontend.py
811 812 813 814 815 816 817 818 819 820 821 822 823 824 | |
handle_import()
Opens a file dialog to manually import joint coordinate data.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the backend data buffer. |
Source code in gui\frontend.py
699 700 701 702 703 704 705 706 707 708 709 710 711 712 | |
handle_load_recording()
Placeholder for loading an existing historical recording session.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Not yet implemented. |
Source code in gui\frontend.py
255 256 257 258 259 260 261 262 | |
handle_load_video()
Opens a file dialog to manually browse and select a video file.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the backend video source and UI status. |
Source code in gui\frontend.py
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 | |
handle_new_recording()
Placeholder for starting a new motion capture recording session.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Not yet implemented. |
Source code in gui\frontend.py
246 247 248 249 250 251 252 253 | |
handle_reboot()
Restarts the application by executing a new Python process.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Terminates the current process. |
Source code in gui\frontend.py
182 183 184 185 186 187 188 189 190 | |
handle_run_fmc()
Triggers FreeMoCap processing with a forced 2-second visual delay.
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in gui\frontend.py
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 | |
handle_select_root()
Updates the backend root and refreshes the session list.
Opens a QFileDialog for the user to select a new directory.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the ErgoSidebar. |
Source code in gui\frontend.py
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | |
handle_session_selected()
Loads metadata and populates videos for the selected session.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates backend state and UI enabled/disabled statuses. |
Source code in gui\frontend.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | |
handle_toggle_video()
Toggles Play/Pause state of the video playback.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the UI status label and backend playback state. |
Source code in gui\frontend.py
652 653 654 655 656 657 658 659 660 661 662 663 664 | |
handle_video_selection_changed()
Loads a specific video file into the backend based on sidebar selection.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the video source in ErgoBackend. |
Source code in gui\frontend.py
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 | |
init_root()
Initializes the data root from the backend configuration on startup.
Scans the default directory for sessions and attempts to load assets (CSV data and video) for the first found session.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Populates UI widgets with initial data. |
Source code in gui\frontend.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | |
keyPressEvent(event)
Overrides standard key presses to handle shortcut bindings.
Maps arrow keys to frame stepping and spacebar to video toggle commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
QKeyEvent
|
The incoming key keyboard event configuration. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Accepts or passes the incoming key event structure. |
Source code in gui\frontend.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | |
kill_running_threads()
Safely terminates active backend threads to prevent memory leaks or crashes.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Stops background threads. |
Source code in gui\frontend.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
open_docs()
Opens the locally shipped documentation homepage.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Launches system default desktop browser. |
Source code in gui\frontend.py
274 275 276 277 278 279 280 281 282 | |
open_settings()
Placeholder for configuring application preferences and window paths.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Not yet implemented. |
Source code in gui\frontend.py
264 265 266 267 268 269 270 271 272 | |
open_source()
Opens the live GitHub repository on the web.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Launches system default desktop browser. |
Source code in gui\frontend.py
294 295 296 297 298 299 300 301 302 | |
open_tutorial()
Opens the locally shipped tutorial page.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Launches system default desktop browser. |
Source code in gui\frontend.py
284 285 286 287 288 289 290 291 292 | |
run_analysis(analysis_request)
Executes the ergonomic assessment and opens the results.
Calculates scores based on the selected method (RULA/REBA) and loads
the resulting data into the ReportView.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
analysis_request
|
AnalysisRequest
|
Parameters configuring the method and frame export triggers. |
required |
Source code in gui\frontend.py
733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 | |
safe_close()
Safely terminates running backend threads and closes the application window.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Closes the window hierarchy. |
Source code in gui\frontend.py
235 236 237 238 239 240 241 242 243 244 | |
setup_ui()
Constructs the main layout, widgets, and signal-slot connections.
This method initializes the central widget, the VideoCanvas, the
ErgoSidebar, and the application MenuBar.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Modifies the |
Source code in gui\frontend.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
show_report()
Displays the ReportView window and updates it with the current method.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Shows or raises the |
Source code in gui\frontend.py
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 | |
step_video(delta)
Sends a relative step request to the backend safely across threads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
delta
|
int
|
The number of frames to step (positive for forward, negative for backward). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Emits cross-thread signaling. |
Source code in gui\frontend.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | |
toggle_sidebar()
Toggle the visibility of the sidebar.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the visibility state of the |
Source code in gui\frontend.py
358 359 360 361 362 363 364 365 | |
toggle_theme()
Switches the application stylesheet between dark and light modes.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the |
Source code in gui\frontend.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
Functions
options: show_root_heading: true
gui.views.report_view
ErgoMoCap: Report View
Analytics Dashboard and Visualization Module for Ergonomic Assessment.
This module implements the ReportView class, the primary user interface for
post-analysis data review. It integrates Matplotlib for data visualization,
Pandas for dataset manipulation, and a Strategy-based reporting widget to
display multi-method results (RULA/REBA).
The view supports professional document generation (PDF/DOCX) by communicating with the ReportBackend.
Key Features
- Data visualization using Matplotlib pie charts.
- Dynamic metric calculation via Pandas.
- Professional reporting in PDF (via Jinja2/QtPrintSupport) and DOCX (via DocxTemplate).
Classes
ReportView
Bases: QMainWindow
The main dashboard window for ergonomic report generation and visualization.
This class provides a comprehensive interface to load analysis datasets, visualize risk distributions through interactive charts, and export data into medical-grade reports.
Attributes:
| Name | Type | Description |
|---|---|---|
current_theme |
ErgoTheme
|
The active UI theme configuration. |
current_method |
AssessmentMethod
|
The active assessment protocol (e.g., REBA, RULA). |
current_strategy |
RebaStrategy | RulaStrategy
|
The active evaluation strategy logic. |
backend |
ReportBackend
|
The processing engine for data and exports. |
current_file |
Path | None
|
File path to the active dataset. |
sidebar |
QFrame
|
The navigation and control sidebar widget. |
btn_import |
QPushButton
|
Button to trigger data loading. |
btn_pdf |
QPushButton
|
Button to trigger PDF report export. |
btn_docx |
QPushButton
|
Button to trigger Word document export. |
file_info |
QTextEdit
|
Text area displaying information about the loaded file. |
card_total |
QFrame
|
Dashboard card displaying total frames processed. |
card_avg |
QFrame
|
Dashboard card displaying average risk score. |
chart_risk |
ChartReportWidget
|
Matplotlib canvas for risk level distribution. |
chart_score |
ChartReportWidget
|
Matplotlib canvas for total score frequency. |
report_widget |
TableReportWidget
|
The dynamic table display for metrics. |
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the Report View dashboard. |
_setup_ui |
Initializes the graphical user interface layout and components. |
_create_stat_card |
Factory method to create a stylized 'Stat Card' for the dashboard. |
_connect_signals |
Connects UI signals to their respective backend slots and handlers. |
_handle_export_success |
Slot to handle the UI notification after a successful file export. |
_handle_error |
Slot to handle and display error messages from the backend. |
_on_data_ready |
Internal slot triggered when the backend finishes processing data. |
_handle_import_dialog |
Triggers a QFileDialog to allow users to select a new data source. |
_handle_pdf_request |
GUI-side handling of PDF printing requests. |
_print_pdf |
Renders the generated HTML report to a PDF file using Qt's print system. |
_handle_docx_request |
Trigger backend export with a screenshot of the current chart. |
_update_charts |
Logic outsourced to specialized chart widgets for Matplotlib rendering. |
set_method |
Update the active ergonomic assessment method. |
update_current_strategy |
Synchronize the UI strategy with the currently selected assessment method. |
Source code in gui\views\report_view.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | |
Functions
_connect_signals()
Connects UI signals to their respective backend slots and handlers.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Establishes signal-slot connections. |
Source code in gui\views\report_view.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |
_create_stat_card(title, value, internal_name)
Factory method to create a stylized 'Stat Card' for the dashboard.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
The label for the metric (e.g., "AVG REBA SCORE"). |
required |
value
|
str
|
The initial value to display. |
required |
internal_name
|
str
|
The unique ID used to update the label text later. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
QFrame |
QFrame
|
A stylized frame containing the metric labels. |
Source code in gui\views\report_view.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
_handle_docx_request()
Trigger backend export with a screenshot of the current chart.
Converts the chart_risk canvas into a bytes buffer for insertion into a
DOCX template via the ReportBackend.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Initiates the Word document generation. |
Source code in gui\views\report_view.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
_handle_error(error_info)
Slot to handle and display error messages from the backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error_info
|
ErrorInfo
|
Data class object containing the error title and descriptive message. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Triggers a critical |
Source code in gui\views\report_view.py
337 338 339 340 341 342 343 344 345 346 347 348 | |
_handle_export_success(report_export_result)
Slot to handle the UI notification after a successful file export.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report_export_result
|
ReportExportResult
|
Data class object containing details of the export result. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Triggers a |
Source code in gui\views\report_view.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | |
_handle_import_dialog()
Triggers a QFileDialog to allow users to select a new data source.
Supports .csv and .xlsx extensions. If a path is selected, it triggers
the load_data_and_run method in the ReportBackend.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the report backend with the new file path. |
Source code in gui\views\report_view.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
_handle_pdf_request()
GUI-side handling of PDF printing (requires access to Printer/Canvas).
Captures the current Matplotlib buffer as bytes and passes it to the
ReportBackend for template rendering.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Triggers the PDF generation sequence. |
Source code in gui\views\report_view.py
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
_on_data_ready(report_data)
Internal slot triggered when the backend finishes processing data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report_data
|
ReportData
|
ReportData from report backend |
required |
Returns: None (None): Populates the dashboard UI with live data.
Source code in gui\views\report_view.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |
_print_pdf(html)
Renders the generated HTML report to a PDF file using Qt's print system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
The rendered HTML content from the Jinja2 template. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Generates the physical PDF file. |
Raises:
| Type | Description |
|---|---|
Exception(Exception)
|
If the printer or document fails to write to the path. |
Source code in gui\views\report_view.py
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | |
_setup_ui()
Initializes the graphical user interface layout and components.
This method constructs a hierarchical nested layout consisting of: 1. A top-level vertical layout to host the global menu_bar. 2. A horizontal content area containing a Sidebar and a Dashboard. 3. Stylized stat cards, Matplotlib canvases, and a reporting table.
References internal components like TableReportWidget.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Modifies the window state in-place. |
Note
Requires the following instance attributes to be pre-initialized:
- THEMES: A dict containing color hex codes.
- current_theme: A str ("light" or "dark") for theme selection.
Source code in gui\views\report_view.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
_update_charts(df)
Logic outsourced to specialized chart widgets.
Updates both the risk distribution and score frequency visualizations using the provided dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
The dataset containing ergonomic metrics. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Redraws the Matplotlib canvases via the chart widgets. |
Source code in gui\views\report_view.py
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | |
set_method(method)
Update the active ergonomic assessment method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
AssessmentMethod
|
The name of the method to apply (e.g., AssessmentMethod.RULA, AssessmentMethod.REBA). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates internal state and clears previous strategy if necessary. |
Source code in gui\views\report_view.py
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | |
update_current_strategy()
Synchronize the UI strategy with the currently selected assessment method.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the |
Source code in gui\views\report_view.py
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | |
options: show_root_heading: true
gui.views.settings_view
options: show_root_heading: true
gui.widgets.sidebar
ErgoMoCap: Ergonomic Sidebar
Control Panel and Configuration Interface for the ErgoMoCap Application.
This module implements the ErgoSidebar, a specialized QDockWidget that serves
as the primary control hub for the user. It organizes recording source selection,
data management, analytics parameters, and video visualization controls into a
scrollable vertical interface.
The sidebar follows a "Deaf-Mute" component pattern, communicating exclusively through Qt Signals to maintain strict decoupling from the project's backend and processing logic.
Classes
ErgoSidebar
Bases: QDockWidget
A scrollable control panel for managing ergonomic analysis workflows.
The sidebar is divided into logical sections: - Capture Source: Execute external processing via FreeMoCap. - Data Management: File system navigation and session selection. - Analytics: Method selection (RULA/REBA) and analysis execution. - Reports: Navigation to the dashboard. - Video Visualizer: Media control and playback selection.
Attributes:
| Name | Type | Description |
|---|---|---|
session_changed |
Signal
|
Signal emitted when a new recording session is selected (str). |
video_changed |
Signal
|
Signal emitted when a new video file is selected (str). |
run_analysis_clicked |
Signal
|
Signal emitted with the formatted payload ( |
root_selection_requested |
Signal
|
Signal emitted when the user requests a directory change. |
main_container |
QWidget
|
Central container hosting the main vertical layout structure. |
scroll_area |
QScrollArea
|
Main viewport allowing scrolling layout behaviors for small screens. |
container |
QWidget
|
Child container acting as the canvas within the scroll area. |
btn_fmc |
QPushButton
|
Push button to execute the FreeMoCap runner application. |
btn_select_root |
QPushButton
|
File explorer launcher button for selecting a root folder. |
lbl_session |
QLabel
|
Label descriptive title for session combos. |
combo_sessions |
QComboBox
|
Dropdown selection menu displaying discovered local capture sessions. |
lbl_method |
QLabel
|
Label descriptive title for calculation method selection combo box. |
combo_method |
QComboBox
|
Dropdown selection layout offering supported framework algorithms. |
export_frames_checkbox |
QCheckBox
|
Checkbox indicating whether output frame buffers should persist. |
btn_analysis |
QPushButton
|
Trigger execution wrapper to launch backend processing logic. |
btn_report |
QPushButton
|
Navigation trigger shortcut to deploy dashboard analytics displays. |
lbl_video_select |
QLabel
|
Title layout text label header for picking file streams. |
combo_videos |
QComboBox
|
Dropdown selector populated with multi-camera recordings if existing. |
btn_load_video |
QPushButton
|
Fallback local file system dialog trigger for arbitrary videos. |
btn_play_video |
QPushButton
|
Playback action control toggle button interface. |
btn_prev_frame |
QPushButton
|
Manual single frame step backward hotkey layout link button. |
btn_next_frame |
QPushButton
|
Manual single frame step forward hotkey layout link button. |
status_label |
QLabel
|
Message terminal line positioned near footer boundary blocks. |
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the sidebar and its internal UI components. |
_setup_ui |
Construct the visual layout of the sidebar. |
_connect_internal_signals |
Establish signal-slot connections for internal child widgets. |
update_sessions |
Refresh the session selection list. |
update_videos |
Refresh the available video list and update playback controls. |
set_status |
Update the status label text in the UI. |
get_current_session |
Returns the currently selected session name. |
get_current_video |
Returns the currently selected video name. |
get_selected_method |
Returns the currently selected analysis method. |
handle_run_analysis |
Map selected GUI configurations to structured downstream events. |
Source code in gui\widgets\sidebar.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
Functions
_connect_internal_signals()
Establish signal-slot connections for internal child widgets.
Connects button clicks and combo box changes to the sidebar's public signals, effectively proxying widget interactions to the application controller.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Sets up signal connections. |
Source code in gui\widgets\sidebar.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
_setup_ui()
Construct the visual layout of the sidebar.
Creates the main container, scroll area, and group boxes for organized control placement. It also configures the widget as a non-closable, left-aligned dock.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Modifies the widget state in-place. |
Source code in gui\widgets\sidebar.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
get_current_session()
Returns the currently selected session name.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The text content of the active session combo box. |
Source code in gui\widgets\sidebar.py
369 370 371 372 373 374 375 376 | |
get_current_video()
Returns the currently selected video name.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The text content of the active video combo box. |
Source code in gui\widgets\sidebar.py
378 379 380 381 382 383 384 385 | |
get_selected_method()
Returns the currently selected analysis method.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The selected method name (e.g., "REBA", "RULA"). |
Source code in gui\widgets\sidebar.py
387 388 389 390 391 392 393 394 395 | |
handle_run_analysis()
Map selected GUI configurations to structured downstream events.
Constructs an instance of AnalysisRequest
and triggers the run_analysis_clicked signal if parsing matches known
AssessmentMethod mappings. This
signal proxies the configuration payload directly to the application's
frontend orchestrator slot run_analysis.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Emits Qt signals or writes parsing faults to the local terminal view. |
Source code in gui\widgets\sidebar.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |
set_status(text)
Update the status label text in the UI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The status message to display. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the |
Source code in gui\widgets\sidebar.py
357 358 359 360 361 362 363 364 365 366 367 | |
update_sessions(sessions)
Refresh the session selection list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sessions
|
list[str]
|
A |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the |
Source code in gui\widgets\sidebar.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | |
update_videos(videos)
Refresh the available video list and update playback controls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
videos
|
list[str]
|
A |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the |
Source code in gui\widgets\sidebar.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
options: show_root_heading: true
gui.widgets.video_canvas
ErgoMoCap: Video Canvas
Visual rendering components for motion capture and ergonomic feedback.
This module provides the VideoCanvas class, a specialized QLabel designed to
render synchronized video streams and skeletal overlays. It handles the
real-time conversion of OpenCV frames to PySide6 graphics, applies dynamic
scaling while maintaining aspect ratios, and overlays coordinate-based landmarks
color-coded by ergonomic risk levels.
TODO refractor this code, it's still trying to paint while the annotation is done with freemocap!
Classes
Landmark
Mock class defining the structure of a pose landmark.
This class serves as a lightweight data structure to represent spatial coordinates and detection confidence without requiring the full MediaPipe dependency.
Attributes:
| Name | Type | Description |
|---|---|---|
x |
float
|
Normalized horizontal coordinate (0.0 to 1.0). |
y |
float
|
Normalized vertical coordinate (0.0 to 1.0). |
z |
float
|
Normalized depth coordinate. |
visibility |
float
|
Confidence score of the landmark detection. |
Source code in gui\widgets\video_canvas.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
VideoCanvas
Bases: QLabel
A custom QLabel widget for rendering video frames and overlaying motion capture data.
This class handles the conversion of numpy.ndarray (OpenCV frames) to QPixmap,
calculates centered scaling for display, and paints skeletal landmarks with
dynamic color-coding based on RiskLevel.
Attributes:
| Name | Type | Description |
|---|---|---|
seek_requested |
Signal
|
Emits the target frame index ( |
toggle_requested |
Signal
|
Emits a request to play/pause. |
final_pixmap |
QPixmap | None
|
The processed and scaled image ready for painting. |
landmarks |
list[Any]
|
A |
frame_num |
int
|
Current frame index for the overlay display. |
total_frames |
int
|
Total frame count for scroller synchronization. |
risk_color |
QColor
|
The color assigned to landmarks based on the ergonomic risk level. |
risk_text |
str
|
String representation of the current risk level. |
show_frame_overlay |
bool
|
Toggle for displaying frame metadata on screen. |
color_map |
dict[RiskLevel, str]
|
Mapping of risk levels to hexadecimal color codes. |
Methods:
| Name | Description |
|---|---|
__init__ |
Initializes the VideoCanvas with default dimensions and styling. |
set_frame_overlay |
Toggle the visibility of the on-screen frame and risk metadata. |
update_position |
Update the internal frame counters for seeker rendering. |
mousePressEvent |
Handle mouse clicks for video seeking and playback toggling. |
update_frame |
Update the canvas with a new video frame and associated metadata. |
paintEvent |
Handles the rendering of the frame and the skeletal overlays. |
_draw_seeker |
Draw the interactive seeker bar at the bottom of the video. |
_draw_overlay |
Draw technical metadata onto the video surface. |
Source code in gui\widgets\video_canvas.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | |
Functions
_draw_overlay(painter, x, y)
Draw technical metadata onto the video surface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
painter
|
QPainter
|
The active painting object. |
required |
x
|
int
|
Horizontal offset of the scaled video. |
required |
y
|
int
|
Vertical offset of the scaled video. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Renders text using the active painter. |
Source code in gui\widgets\video_canvas.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | |
_draw_seeker(painter, x, y, w, h)
Draw the interactive seeker bar at the bottom of the video.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
painter
|
QPainter
|
The active painting object. |
required |
x
|
int
|
Video horizontal offset. |
required |
y
|
int
|
Video vertical offset. |
required |
w
|
int
|
Video width. |
required |
h
|
int
|
Video height. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Draws seeker bar. |
Source code in gui\widgets\video_canvas.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
mousePressEvent(event)
Handle mouse clicks for video seeking and playback toggling.
Detects if a click lands within the bottom seeker boundary to dispatch frame skips
via seek_requested, or hits the focal display canvas to toggle media playback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
QMouseEvent
|
Mouse event containing click coordinates. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Emits control signals. |
Source code in gui\widgets\video_canvas.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
paintEvent(event)
Handles the rendering of the frame and the skeletal overlays.
Calculates the centered position of the scaled pixmap within the widget's available space and draws landmarks as ellipses if they meet the visibility threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
QPaintEvent
|
The paint event triggered by the system or |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Draws directly to the widget's surface. |
Source code in gui\widgets\video_canvas.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
set_frame_overlay(show_frame_overlay)
Toggle the visibility of the on-screen frame and risk metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
show_frame_overlay
|
bool
|
Whether to render the metadata text. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the overlay state. |
Source code in gui\widgets\video_canvas.py
146 147 148 149 150 151 152 153 154 155 156 | |
update_frame(frame_data)
Update the canvas with a new video frame and associated metadata.
Converts the raw image data to a scaled QPixmap, determines the
visual color for landmarks based on the ergonomic risk level, and
triggers a repaint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame_data
|
FrameData
|
Frame data capsule defined by
FrameData, containing the underlying
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Emits an internal update request to trigger |
Source code in gui\widgets\video_canvas.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
update_position(video_position)
Update the internal frame counters for seeker rendering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
video_position
|
VideoPosition
|
Structured data model containing indices mapped via VideoPosition. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates internal state. |
Source code in gui\widgets\video_canvas.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
options: show_root_heading: true
gui.widgets.table_report_widget
ErgoMoCap: Table Report Widget
Standardized Tabular Visualization Component for Ergonomic Assessment Metrics.
This module provides the TableReportWidget, a high-level UI component used to display
complex calculation results in a clean, professional table format. It leverages a
Strategy-based architecture to handle different assessment protocols (RULA, REBA, etc.)
while maintaining a consistent look and feel.
The widget is designed to integrate with a custom CSS framework by utilizing specific
ObjectNames and UserRole data roles for dynamic styling.
Classes
TableReportWidget
Bases: QWidget
A professional UI component that renders data based on the provided strategy.
This widget provides a standardized interface for displaying ergonomic assessment
results (such as RULA or REBA) within the ErgoMoCap GUI. It utilizes a strategy
pattern to transform raw calculation data into formatted table rows and applies
styling via ObjectNames for integration with the 'VOLKS-TYPO' CSS framework.
Attributes:
| Name | Type | Description |
|---|---|---|
strategy |
ReportStrategy
|
The active reporting protocol implementation. |
title |
str
|
The title string used for the header label. |
main_layout |
QVBoxLayout
|
The primary layout container. |
title_lbl |
QLabel
|
The label displaying the assessment method name. |
table |
QTableWidget
|
The internal table used to render metrics and values. |
Methods:
| Name | Description |
|---|---|
update_results |
Execute the current strategy and update the UI table with new data. |
update_strategy |
Swap the current reporting strategy used by the widget. |
_insert_row |
Insert and format a new row in the internal QTableWidget based on ResultRow properties. |
Source code in gui\widgets\table_report_widget.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
Functions
_insert_row(row_data)
Insert and format a new row in the internal QTableWidget.
Handles logic for spans (headers), alignment, and conditional formatting based on the
properties of the provided ResultRow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row_data
|
ResultRow
|
The data object containing values and formatting flags. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Modifies the internal |
Source code in gui\widgets\table_report_widget.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
update_results(summary_data)
Execute the current strategy and update the UI table with new data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
summary_data
|
dict[str, str]
|
A |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Clears the existing rows and repopulates the table in-place. |
Source code in gui\widgets\table_report_widget.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
update_strategy(strategy)
Swap the current reporting strategy used by the widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strategy
|
ReportStrategy
|
The new strategy to apply for future updates. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Updates the internal reference and triggers a widget redraw. |
Source code in gui\widgets\table_report_widget.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
options: show_root_heading: true
gui.widgets.chart_report_widget
ErgoMoCap: Chart Report Widget
Specialized Visualization Component for Ergonomic Analytics.
This module provides the ChartReportWidget, which encapsulates Matplotlib
functionality within the PySide6 ecosystem. It is designed to handle the
automated preprocessing and rendering of ergonomic risk and score distributions.
The widget integrates with the THEMES configuration to ensure visual consistency across the ErgoMoCap dashboard.
Classes
ChartReportWidget
Bases: QWidget
Encapsulated Matplotlib widget for ErgoMoCap.
Handles rendering of ergonomic distributions and provides utility methods for capturing figure states as raw byte streams for document generation.
Attributes:
| Name | Type | Description |
|---|---|---|
current_theme |
ErgoTheme
|
The active UI theme name (e.g., "dark", "light"). |
canvas |
FigureCanvasQTAgg
|
The Qt-compatible drawing surface for Matplotlib figures. |
main_layout |
QVBoxLayout
|
The primary layout container. |
Methods:
| Name | Description |
|---|---|
update_chart |
Hyper-abstracted update method for data visualization (preprocesses and renders pie charts). |
get_image_bytes |
Captures the current figure as a PNG-formatted byte stream for PDF/DOCX export. |
Source code in gui\widgets\chart_report_widget.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
Functions
get_image_bytes()
Captures the current figure for PDF/DOCX export.
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
A PNG-formatted byte stream of the current Matplotlib figure. |
Source code in gui\widgets\chart_report_widget.py
163 164 165 166 167 168 169 170 171 172 173 174 | |
update_chart(data, metric)
Hyper-abstracted update method for data visualization.
This method handles DataFrame preprocessing, value counting, and binning automatically based on the provided MetricType. It renders the results as a pie chart styled according to the project's color maps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame | Series | dict
|
The source data to visualize.
Can be a full project |
required |
metric
|
MetricType
|
The type of ergonomic metric being plotted. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Clears and redraws the |
Source code in gui\widgets\chart_report_widget.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
options: show_root_heading: true
gui.widgets.menu_bar
ErgoMoCap: Menu Bar
Custom Navigation and Command Interface for the Main Application.
This module implements the MenuBar class, which extends the standard QMenuBar
to include specialized corner widgets for UI interaction. It integrates a
hamburger-style sidebar toggle and a theme switcher directly into the menu
bar real estate, providing a compact and modern navigation experience. The
menus are populated using centralized actions defined in
MenuActions.
Classes
MenuBar
Bases: QMenuBar
Custom menu bar implementation with integrated corner controls.
This class organizes the application's top-level navigation into logical
categories (File, Controller, Settings, Help) while providing immediate
access to global UI state toggles via QToolButton corner widgets.
Attributes:
| Name | Type | Description |
|---|---|---|
sidebar_btn |
QToolButton
|
A button positioned in the top-left corner used to toggle the navigation sidebar. |
theme_btn |
QToolButton
|
A button positioned in the top-right corner used to switch between light and dark visual themes. |
Source code in gui\widgets\menu_bar.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
options: show_root_heading: true
gui.widgets.menu_actions
ErgoMoCap: Menu Actions
Centralized Action Management for the ErgoMoCap Main Window.
This module defines the MenuActions class, which serves as a container for all
QAction objects used in the application's menu bar and toolbars. By decoupling
action definitions from the UI layout, it ensures that shortcuts, signals, and
translations are managed in a single, testable location. It performs strict
attribute validation to ensure the parent QMainWindow implements the necessary
handler methods.
Classes
MenuActions
Factory class for creating and connecting GUI actions.
This class encapsulates the initialization of all user-triggerable actions within the ErgoMoCap interface. It maps keyboard shortcuts to specific logic handlers defined in the main window.
Attributes:
| Name | Type | Description |
|---|---|---|
new_rec |
QAction
|
Action to initiate a new motion capture recording. |
load_rec |
QAction
|
Action to load an existing recording for analysis. |
run_fmc |
QAction
|
Action to execute the FreeMoCap processing pipeline. |
select_fmc_root |
QAction
|
Action to define the root directory for FreeMoCap data. |
exit_act |
QAction
|
Action to safely close the application. |
kill_threads |
QAction
|
Action to terminate all background processing threads. |
reboot_gui |
QAction
|
Action to refresh/restart the GUI state. |
settings |
QAction
|
Action to open the application configuration dialog. |
docs |
QAction
|
Action to open the external project documentation. |
tutorial |
QAction
|
Action to open the user tutorial. |
open_source |
QAction
|
Action to open the project's source code repository. |
Source code in gui\widgets\menu_actions.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
options: show_root_heading: true
Utilities & Internationalization
gui.theme.style
ErgoMoCap: Volks-Typo Design System
Centralized styling and theme management for the ErgoMoCap application.
This module implements the "Volks-Typo" system, a design-token-driven architecture that manages color palettes, typography, and spatial grids. It generates dynamic Qt Style Sheets (QSS) to maintain a consistent visual language across the GUI while supporting seamless switching between light and dark modes.
Key components:
- Design Tokens: Standardized GRID and THEMES dictionaries for layout and color.
- Typography: Specialized font mappings for headings (Oswald, Roboto Condensed),
body text (Work Sans), and technical data (JetBrains Mono).
- Dynamic Theming: The get_stylesheet function
injects theme tokens into a global QSS template.
Functions
get_stylesheet(mode=ErgoTheme.DARK)
Generates the Qt Style Sheet (QSS) based on the specified visual mode.
Maps the design tokens defined in THEMES and FONTS to a comprehensive QSS string. This includes base widget configuration, typography for custom label IDs (h1, h2, h3), and dynamic states for interactive components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
ErgoTheme
|
The visual theme to retrieve. Must be one of |
DARK
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A formatted QSS string ready to be applied via |
Raises:
| Type | Description |
|---|---|
KeyError
|
If an invalid |
Examples:
Applying the dark theme to a QApplication instance:
app = QApplication(sys.argv)
style_qss = get_stylesheet("dark")
app.setStyleSheet(style_qss)
Source code in gui\theme\style.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | |
options: show_root_heading: true
gui.utils.utils
ErgoMoCap: Utility Module
Helper functions for session data management and report generation. (as of now)
This module provides utility functions to support the ergonomic analysis workflow, specifically focusing on the transformation of raw session data into actionable insights. It includes logic for:
- Report Generation: Creating Markdown-formatted summaries of assessment sessions.
- Metric Aggregation: Calculating dynamic averages from
pandas.DataFrameobjects to identify postural trends. - Naming Standardization: Constructing consistent column identifiers based on anatomical parts, metric types, and assessment methods (RULA/REBA).
These utilities ensure a unified data schema between the backend processing logic and the frontend reporting interface.
Classes
Functions
generate_markdown_report(report_path, all_data_records)
Generates a Markdown report summarizing the assessment session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report_path
|
str | Path
|
Destination path for the |
required |
all_data_records
|
list[dict[str, Any]]
|
A |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Writes the report to the file system. |
Source code in gui\utils\utils.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
get_dynamic_metrics(df, metric_type, method)
Calculates session averages using standardized column naming.
Scans the pandas.DataFrame for columns ending in the standard score/method suffix
and calculates their mean values to provide an overview of postural trends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
The full session data loaded into a |
required |
metric_type
|
MetricType
|
The MetricType to filter by. |
required |
method
|
AssessmentMethod
|
The AssessmentMethod used (e.g., RULA/REBA). |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[str, str]]
|
list[tuple[str, str]]: A |
Source code in gui\utils\utils.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
resolve_column_name(part, metric, method)
Constructs a standardized database/CSV column name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
part
|
BodyPart
|
The anatomical BodyPart Enum. |
required |
metric
|
MetricType
|
The MetricType Enum (e.g., angle, score). |
required |
method
|
AssessmentMethod
|
The AssessmentMethod Enum (e.g., reba). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A |
Source code in gui\utils\utils.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
options: show_root_heading: true
gui.utils.app_paths
ErgoMoCap: Application Path Management
Centralized Path Resolution for Internal Assets and External Data.
This module provides the ErgoPaths class and supporting utility functions to
standardize how the application accesses the file system. It specifically
addresses the challenges of path resolution in "frozen" environments (e.g.,
executables bundled with PyInstaller) versus standard development environments.
By centralizing all "magic strings" related to directory names and file locations, this module ensures that changes to the project structure only need to be reflected in a single location.
Classes
ErgoPaths
Centralized registry for all folder names and file locations in ErgoMoCap.
This class serves as the single source of truth for the project's file system
hierarchy. It differentiates between internal read-only application layers (APP_CODE)
and external writeable structures (USER_DATA).
Attributes:
| Name | Type | Description |
|---|---|---|
USER_DATA |
Path
|
Root path for persistent user data and tracking sessions. |
SESSIONS |
Path
|
Directory containing recording session data folders. |
APP_CODE |
Path
|
Root path for the core application source and asset resources. |
ASSETS |
Path
|
Directory containing UI images, icons, and static graphics. |
TEMPLATES |
Path
|
Directory containing Jinja2/HTML visual report templates. |
OUTPUT_FOLDER |
Path
|
Standardized directory for generated ergonomic analysis results. |
DATA_FOLDER_NAME |
str
|
Static directory string identifying subfolders holding raw metric data. |
VIDEO_FOLDER_NAME |
str
|
Static directory string identifying subfolders holding annotated video streams. |
LOCAL_SITE |
str
|
Static directory string pointing to local web assets or report packages. |
LOGO |
Path
|
Absolute filesystem locator path to the primary application logo graphic. |
Methods:
| Name | Description |
|---|---|
update_user_root |
Updates the USER_DATA path and all constant paths at a class level. |
session_folder |
Constructs the absolute path to a specific recording session directory. |
data_folder |
Constructs the absolute path to the data subfolder of a session. |
video_folder |
Constructs the absolute path to the video subfolder of a session. |
frames_folder |
Constructs the absolute path to the video frames subfolder of a video, creating it if needed. |
output_folder |
Resolves the global output directory, ensuring its safe creation on disk. |
analysis_output |
Returns the standardized target path for the primary analysis CSV export sheet. |
get_local_site_url |
Converts an absolute systemic path string into a valid QUrl resource location. |
Source code in gui\utils\app_paths.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
Functions
analysis_output()
staticmethod
Returns the standardized path for the primary analysis CSV.
Ensures that analysis results are consistently stored in the recognized output directory.
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Absolute path to 'ergo_analysis.csv'. |
Source code in gui\utils\app_paths.py
232 233 234 235 236 237 238 239 240 241 242 243 244 | |
data_folder(session_name)
staticmethod
Constructs the absolute path to the data subfolder of a session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_name
|
str
|
The name of the target session. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Path to the session's 'output_data' directory. |
Source code in gui\utils\app_paths.py
179 180 181 182 183 184 185 186 187 188 189 190 | |
frames_folder(session_name, video_name)
staticmethod
Constructs the absolute path to the video frames subfolder of a video.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_name
|
str
|
The name of the target session. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Path to the video's 'frames' directory. |
Source code in gui\utils\app_paths.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
get_local_site_url(page_name)
staticmethod
Helper method to construct a safe local file URL.
Resolves internal application page assets into validated uniform resource locator structures compatible with PySide6 web engine components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_name
|
str
|
Relative filename string pointing to the targeted web asset or page. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
QUrl |
QUrl
|
A validated local file system pointer scheme ( |
Raises:
| Type | Description |
|---|---|
ValueError(ValueError)
|
If the target file resource does not exist at the resolved location path. |
Source code in gui\utils\app_paths.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
output_folder()
staticmethod
Resolves the global output folder, creating it if it does not exist.
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
The verified directory for ergonomic data output. |
Source code in gui\utils\app_paths.py
221 222 223 224 225 226 227 228 229 230 | |
session_folder(session_name)
staticmethod
Constructs the absolute path to a specific recording session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_name
|
str
|
The unique identifier/folder name of the session. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Absolute path to the session directory. |
Source code in gui\utils\app_paths.py
166 167 168 169 170 171 172 173 174 175 176 177 | |
update_user_root(new_root)
classmethod
Dynamically updates the base path location when a user selects a custom root folder from the interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_root
|
Path
|
The unique identifier/folder name of the session. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Simply Updated the class. |
Source code in gui\utils\app_paths.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
video_folder(session_name)
staticmethod
Constructs the absolute path to the video subfolder of a session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_name
|
str
|
The name of the target session. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Path to the session's 'annotated_videos' directory. |
Source code in gui\utils\app_paths.py
192 193 194 195 196 197 198 199 200 201 202 203 | |
Functions
get_external_root()
Resolves the root directory for external user data.
Ensures that output files (videos, CSVs) are saved relative to the user's executable environment in a 'frozen' state, preventing data from being written to temporary system folders.
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
The absolute path to the persistent external application environment. |
Source code in gui\utils\app_paths.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
get_internal_root()
Resolves the root directory for internal assets.
Handles the path shift that occurs when the application is bundled using
PyInstaller (_MEIPASS) versus running as a raw script. This is used for
read-only assets like icons, templates, and core application code.
Path
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
The absolute path to the bundled internal assets or the project source root. |
Source code in gui\utils\app_paths.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
options: show_root_heading: true
gui.utils.constants
ErgoMoCap: Project Constants and Enumerations
Centralized Definitions for Domain Entities, Metrics, and Data Indices.
This module serves as the single source of truth for constants used across the
ErgoMoCap ecosystem. It defines structured enumerations for biological segments,
assessment methodologies, and risk levels to ensure type safety and logic consistency
between the /calculators and /gui modules.
A critical component of this module is the synchronization with the FreeMoCap (FMC) nomenclature. It maps specific biomechanical degrees of freedom to their respective indices and column names used in the underlying data arrays and DataFrames.
Key Enumerations
BodyPart: Anatomical segments targeted by ergonomic assessments.MetricType: Classification of data points (Score, Angle, or Risk).AssessmentMethod: Supported ergonomic protocols (REBA, RULA).RiskLevel: Qualitative descriptors for calculated ergonomic risks.DegsIndexes: Integer mapping for raw biomechanical degree-of-freedom arrays.
Data Schemas
FMC_ANGLE_COLUMNS: Standardized list of strings for DataFrame column indexing.ANGLE_LABELS: Mapping ofBodyPartto project-specific FMC metric strings.
Classes
AssessmentMethod
Bases: Enum
Supported ergonomic assessment protocols.
Attributes:
| Name | Type | Description |
|---|---|---|
REBA |
str
|
Rapid Entire Body Assessment. |
RULA |
str
|
Rapid Upper Limb Assessment. |
Source code in gui\utils\constants.py
91 92 93 94 95 96 97 98 99 100 101 | |
BodyPart
Bases: Enum
Enumeration of anatomical segments targeted by ergonomic assessments.
Attributes:
| Name | Type | Description |
|---|---|---|
NECK |
str
|
The cervical spine region. |
TRUNK |
str
|
The main torso/spine region. |
LEGS |
str
|
Lower extremities including knees and hips. |
UPPER_ARM |
str
|
Humerus region (shoulder to elbow). |
LOWER_ARM |
str
|
Forearm region (elbow to wrist). |
WRIST |
str
|
Carpal region. |
SHOULDERS |
str
|
Bi-lateral shoulder alignment. |
HIPS |
str
|
Bi-lateral pelvic alignment. |
Source code in gui\utils\constants.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
DegsIndexes
Bases: IntEnum
Standardized indices mapping to FreeMoCap (FMC) biomechanical degree-of-freedom arrays.
These indices are used to slice raw data arrays based on the [bodypart][metric][method/subgroup] nomenclature.
Attributes:
| Name | Type | Description |
|---|---|---|
RIGHT_KNEE_EXTENSION_FLEXION |
int
|
Index 0. |
LEFT_KNEE_EXTENSION_FLEXION |
int
|
Index 1. |
SPINE_EXTENSION_FLEXION |
int
|
Index 2. |
SPINE_LATERAL_FLEXION |
int
|
Index 3. |
SPINE_ROTATION_TORSION |
int
|
Index 4. |
NECK_EXTENSION_FLEXION |
int
|
Index 5. |
NECK_LATERAL_FLEXION |
int
|
Index 6. |
NECK_ROTATION |
int
|
Index 7. |
RIGHT_SHOULDER_EXTENSION_FLEXION |
int
|
Index 8. |
LEFT_SHOULDER_EXTENSION_FLEXION |
int
|
Index 9. |
RIGHT_SHOULDER_ABDUCTION_ADDUCTION |
int
|
Index 10. |
LEFT_SHOULDER_ABDUCTION_ADDUCTION |
int
|
Index 11. |
RIGHT_SHOULDER_RISE |
int
|
Index 12. |
LEFT_SHOULDER_RISE |
int
|
Index 13. |
RIGHT_ELBOW_EXTENSION_FLEXION |
int
|
Index 14. |
LEFT_ELBOW_EXTENSION_FLEXION |
int
|
Index 15. |
RIGHT_HAND_EXTENSION_FLEXION |
int
|
Index 16. |
LEFT_HAND_EXTENSION_FLEXION |
int
|
Index 17. |
RIGHT_HAND_LATERAL_SIDE |
int
|
Index 18. |
LEFT_HAND_LATERAL_SIDE |
int
|
Index 19. |
RIGHT_HAND_TWIST |
int
|
Index 20. |
LEFT_HAND_TWIST |
int
|
Index 21. |
Source code in gui\utils\constants.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
MetricType
Bases: Enum
Classification of ergonomic data points and calculation results.
Attributes:
| Name | Type | Description |
|---|---|---|
SCORE |
str
|
Numerical assessment value (e.g., REBA final score). |
ANGLE |
str
|
Biomechanical joint angle in degrees. |
RISK |
str
|
Qualitative risk classification. |
Source code in gui\utils\constants.py
76 77 78 79 80 81 82 83 84 85 86 87 88 | |
RiskLevel
Bases: Enum
Qualitative descriptors for calculated ergonomic risk levels.
Attributes:
| Name | Type | Description |
|---|---|---|
NEGLIGIBLE |
str
|
No action required. |
LOW |
str
|
Further investigation may be needed. |
MEDIUM |
str
|
Further investigation and changes soon. |
HIGH |
str
|
Investigation and changes required immediately. |
VERY_HIGH |
str
|
Urgent changes required. |
Source code in gui\utils\constants.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
options: show_root_heading: true
gui.utils.models
ErgoMoCap: GUI - Backend Communication Models
Typed Data Contracts and Structural Communication Interfaces.
This module provides immutably frozen, memory-optimized (__slots__) data models
to standardize communications between asynchronous backend processes, workers,
and user interface threads.
By enforcing strict type boundaries across signals and slots, this architecture prevents thread-boundary race mutations and standardizes API contracts across the application lifecycle.
Classes
AnalysisRequest
dataclass
Typed command container parameters payload requested to run ergonomic calculations.
Attributes:
| Name | Type | Description |
|---|---|---|
method |
AssessmentMethod
|
Target metric evaluation system mapping layout configuration selection. |
export_frames |
bool
|
Flag determining whether single annotated frame matrices are generated to disk. Defaults to False. |
data_ref |
ndarray | Path | None
|
File tracking pointer reference indicating where tracking elements reside. Defaults to None. |
Source code in gui\utils\models.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
AnalysisResult
dataclass
Typed compilation results structural receipt dispatched back by the calculation engines.
Attributes:
| Name | Type | Description |
|---|---|---|
success |
bool
|
Operational completion assertion status flag tracking validation success. |
message |
str
|
Explanatory execution text trace reporting diagnostics details logs metadata. |
output_path |
Path | None
|
Systemic disk tracking target pointer path containing CSV sheets, or None. Defaults to None. |
scores |
Sequence[int]
|
Sequential collection of the frame-by-frame computed results score integers array. Defaults to empty list. |
stats |
dict[str, int]
|
Evaluative qualitative summary frequency grouping metadata calculation table. Defaults to empty dict. |
Source code in gui\utils\models.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
ErrorInfo
dataclass
Simplified structured telemetry error container packet optimized for cross-thread exception warning widgets deployment.
Attributes:
| Name | Type | Description |
|---|---|---|
title |
str
|
Bold notification dialogue header summary label classification metric context text string. |
message |
str
|
Core execution stack exceptions context message descriptive explanation logs parameters. |
Source code in gui\utils\models.py
312 313 314 315 316 317 318 319 320 321 322 323 | |
FrameData
dataclass
Typed contract for sequential video frame emission pipelines.
Encapsulates raw frame visual matrix blocks alongside contextual calculations and skeletal landmark parameters processed during asynchronous visual workers ticks.
Attributes:
| Name | Type | Description |
|---|---|---|
image |
ndarray
|
The raw multi-channel image matrix array matching OpenCV formats (BGR). |
frame_idx |
int
|
The absolute temporal timeline sequential element integer frame index identifier. |
landmarks |
list
|
Collection array structure holding multi-dimensional coordinate mapping elements. Defaults to empty list. |
score |
int | None
|
The specific calculated ergonomic evaluation integer score, or None if skipped. Defaults to None. |
risk |
RiskLevel | None
|
The qualitative risk ranking assignment context enum classification tracking value. Defaults to None. |
Source code in gui\utils\models.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
Functions
to_dict()
Helper for backward compatibility with dict-based consumer tracking slots.
Flattens the structured fields data layouts directly into primitive structural lookup dictionaries for legacy tracking elements components.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Composed metric values keys structure mapping frame information configurations. |
Source code in gui\utils\models.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
FramesExportResult
dataclass
Typed tracking receipt mapping operational metrics recording asynchronous batch frame processing operations.
Attributes:
| Name | Type | Description |
|---|---|---|
success |
bool
|
Execution tracking parameters completion validation monitoring status flag. |
message |
str
|
Text specification string details log tracing diagnostic parameters notes outputs. |
frames_paths |
str
|
Absolute file target path string tracking localized assembly folders directories layouts. Defaults to empty string. |
Source code in gui\utils\models.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
PlaybackState
Bases: Enum
Tracks whether the video engine ticker is active or paused.
Attributes:
| Name | Type | Description |
|---|---|---|
PLAYING |
bool
|
The background worker processing timer tick loop is enabled. |
PAUSED |
bool
|
The background worker parsing pipeline is halted. |
Source code in gui\utils\models.py
47 48 49 50 51 52 53 54 55 56 57 | |
ReportData
dataclass
Data payload model for generating standalone visual report templates sheets.
Attributes:
| Name | Type | Description |
|---|---|---|
df |
DataFrame
|
Dataframe container compiling synchronized evaluation data layers parameters metrics. |
file_path |
Path
|
System absolute path target pinpointing localized assets configurations metrics logs. |
total_frames |
int
|
Length magnitude configuration metrics representing overall timeline size scope counts. |
average_score |
float
|
Computed cumulative global standard score tracking mean floating-point calculations. |
summary_dict |
dict
|
Consolidated diagnostic lookup grouping keys defining assessment distribution metadata profiles. |
Source code in gui\utils\models.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
ReportExportRequest
dataclass
Unified command request container compiling raw visualization elements to generate printable document formats.
Attributes:
| Name | Type | Description |
|---|---|---|
save_path |
Path
|
Absolute system destination output file locator target route specifications tracking. |
chart_data |
bytes
|
Byte array buffer container streams processing embedded static graphics layouts parameters. |
Source code in gui\utils\models.py
282 283 284 285 286 287 288 289 290 291 292 293 | |
ReportExportResult
dataclass
Typed tracking response envelope returning results from background document generation sub-workers.
Attributes:
| Name | Type | Description |
|---|---|---|
success |
bool
|
Transaction completion state verification parameters flag tracking status indicator. |
message |
str
|
Technical context text trace layout providing detailed internal log strings configurations. |
report_path |
str
|
Final target localized storage path string tracking generated report elements on disk. Defaults to empty string. |
Source code in gui\utils\models.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
SessionData
dataclass
Typed session parsing and directory mapping validation meta context tracking model.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Label string identifying unique target folder recording session items profiles. |
success |
bool
|
Operational status assertion flag verifying disk structure lookup results mappings. |
message |
str
|
Log tracing diagnostic notification description text parameters. |
csv_path |
Path | None
|
Absolute system folder mapping target identifying joint coordinate files, or None. Defaults to None. |
video_paths |
list[str]
|
Sequential listing array containing absolute string links paths pointing to media files. Defaults to empty list. |
loaded |
bool
|
Initialization evaluation track status monitoring flag component. Defaults to False. |
Source code in gui\utils\models.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
Attributes
is_ready
property
Convenience checking query interface supporting transactional interface interactive states enablement.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if session paths resolution criteria parameters components matches healthy targets. |
VideoCommand
Bases: Enum
Transport action command primitive indicators navigating background worker media rendering buffers indices.
Attributes:
| Name | Type | Description |
|---|---|---|
TOGGLE |
auto
|
Reverses running execution playback state metrics tracking switches. |
STEP_FORWARD |
auto
|
Shifts background rendering arrays pointers ahead by exactly one index unit frame. |
STEP_BACKWARD |
auto
|
Regresses active frame buffers lookups markers back by exactly one frame iteration unit. |
SEEK |
auto
|
Forces operational media decoders directly onto target localized coordinate position bounds. |
Source code in gui\utils\models.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
VideoControl
dataclass
Unified execution envelope routing atomic layout command structures directly down into background transport streams.
Attributes:
| Name | Type | Description |
|---|---|---|
command |
VideoCommand
|
Action type designation key identifier tracking intent options mappings. |
target_frame |
int | None
|
Direct specific sequence coordinate framework positional index location parameters, or None. Defaults to None. |
Source code in gui\utils\models.py
252 253 254 255 256 257 258 259 260 261 262 263 | |
VideoLoadRequest
dataclass
Typed parameter targets initialization packet dispatched to establish background video engine playback context.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
Path
|
Absolute system directory file target locator tracking media recording structures source assets. |
scores |
list[int]
|
Sequential array indices carrying calculated timeline point score information markers. Defaults to empty list. |
thresholds |
list[tuple[int, RiskLevel]]
|
Structural intervals matrix tracking score-to-level translation limits. Defaults to empty list. |
Source code in gui\utils\models.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
VideoLoadResult
dataclass
Typed structural verification feedback payload reporting media worker initialization context success parameters.
Attributes:
| Name | Type | Description |
|---|---|---|
success |
bool
|
Verification parameter monitoring success of media asset loading pipelines. |
message |
str
|
Logging trace update text string specifying context setup diagnostics parameters. |
video_paths |
list[str]
|
Discovered system target files paths listings array tracks structure. Defaults to empty list. |
loaded |
bool
|
State indicator monitoring internal setup verification completeness metrics. Defaults to False. |
Source code in gui\utils\models.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
VideoPosition
dataclass
Typed real-time positional coordinate update tracking payload enabling cross-thread synchronization widgets interfaces.
Attributes:
| Name | Type | Description |
|---|---|---|
current_frame |
int
|
Absolute playback timeline frame positional index pointer integer position. |
total_frames |
int
|
Total bounded capacity layout limit tracking metric representing files stream dimension length. |
Source code in gui\utils\models.py
221 222 223 224 225 226 227 228 229 230 231 232 | |
options: show_root_heading: true
intl.update_intl
ErgoMoCap: Internationalization (i18n) Manager
Localization workflow automation for Qt-based strings.
This utility streamlines the process of updating and compiling translation files
for the ErgoMoCap interface. It automates the extraction of translatable strings
from the /gui and /calculators directories and manages the conversion between
Qt XML source files (.ts) and binary runtime files (.qm).
Workflow:
1. Extraction: Scans Python source files using pyside6-lupdate.
2. Aggregation: Updates the regional translation source files.
3. Compilation: Converts human-readable translations into high-performance
binary formats via pyside6-lrelease.
Functions
run_intl()
Orchestrates the extraction and compilation of translatable strings for the ErgoMoCap project.
This function automates the Qt localization workflow by:
1. Identifying all Python source files within the /gui and /calculators directories.
2. Executing pyside6-lupdate to synchronize translatable strings into an XML-based .ts file.
3. Prompting the user to compile the updated source into a high-performance binary .qm file
using pyside6-lrelease.
The generated files are stored in the intl/generated directory, which is utilized by
the main application entry point for runtime translation.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
The return value is always None. |
Raises:
| Type | Description |
|---|---|
CalledProcessError
|
If the external Qt tools ( |
OSError
|
If there are issues creating the |
Examples:
To update project translations from the terminal:
python -m intl.update_intl
Source code in intl\update_intl.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
options: show_root_heading: true
Main Entry Point
main
ErgoMoCap: Application Entry Point
Main execution script for the ErgoMoCap ergonomic analysis suite.
This module initializes the high-level application environment, including the Qt event loop, localization (i18n), visual theming, and the primary window instantiation. It serves as the bridge between the system environment and the MainWindow component.
Key Initialization Steps:
1. Stream Fallbacks: Safeguards standard I/O streams by intercepting detached or
missing system environments and overriding sys.stdout and sys.stderr with
in-memory io.StringIO buffers.
2. Multiprocessing Support: Invokes multiprocessing.freeze_support() to ensure
proper process spawning behaviors within PyInstaller frozen execution runtimes.
3. Subprocess Redispatching: Evaluates CLI arguments early to catch specific internal
routing directives (e.g., --run-freemocap-gui), dynamically self-modifying Python's
sys.path and working directories to isolate bundled background operations seamlessly.
4. Environment Setup: Configures the QApplication instance with native system arguments.
5. Localization: Detects system QLocale and attempts to load corresponding
.qm translation files from the intl/generated directory.
6. Theming: Applies the "Fusion" style and the project's custom dark-mode
stylesheet via get_stylesheet.
7. Path Management: Utilizes ErgoPaths to
locate resources like the application icon.
8. Window Management: Launches the main GUI and handles the clean exit
of the process.
Classes
Functions
main()
Primary entry point for the ErgoMoCap application.
Initializes the QApplication instance, configures the localization (i18n)
settings based on the user's system locale, applies the global visual theme
via get_stylesheet, and instantiates the
MainWindow.
The function orchestrates the following bootstrap sequence:
1. Handles PyInstaller multiprocessing requirements via freeze_support().
2. Intercepts custom CLI routing flags (e.g., --run-freemocap-gui) to
run bundled background modules dynamically from the frozen environment,
safely altering the working directory to _internal if present to guarantee
proper asset resolution.
3. Creates the QApplication and handles CLI arguments.
4. Searches for and loads .qm translation files from the intl/generated
directory.
5. Sets the application style to 'Fusion' and applies the custom dark
theme.
6. Configures the application-wide icon using
ErgoPaths.
7. Enters the Qt main event loop.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function terminates the process by calling |
Examples:
To start the application from the command line:
python main.py
Source code in main.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
options: show_root_heading: true
© 2026 medlav. Distributed under the AGPL-3.0 License.