Lars Masanneck
commited on
Commit
·
ee7a14d
1
Parent(s):
523afc6
Adjust Z-score classification and typos
Browse files- Z-Score_Calculator.py +1 -1
- batch_utils.py +10 -10
- pages/1_Batch_Analysis.py +1 -0
- pages/2_PDF_Report.py +5 -5
Z-Score_Calculator.py
CHANGED
|
@@ -46,7 +46,7 @@ DISABLED_BIOMARKERS = {"weight", "sbp", "dbp", "pwv", "nb_vigorous_active_minute
|
|
| 46 |
def main():
|
| 47 |
if "disclaimer_shown" not in st.session_state:
|
| 48 |
st.info(
|
| 49 |
-
"These calculations are dedicated for
|
| 50 |
"For detailed questions regarding personal health data contact your "
|
| 51 |
"healthcare professionals."
|
| 52 |
)
|
|
|
|
| 46 |
def main():
|
| 47 |
if "disclaimer_shown" not in st.session_state:
|
| 48 |
st.info(
|
| 49 |
+
"These calculations are dedicated for scientific purposes only. "
|
| 50 |
"For detailed questions regarding personal health data contact your "
|
| 51 |
"healthcare professionals."
|
| 52 |
)
|
batch_utils.py
CHANGED
|
@@ -121,7 +121,7 @@ def process_batch_data(df: pd.DataFrame, normative_df: pd.DataFrame,
|
|
| 121 |
result[f'{biomarker}_z'] = round(res['z_score'], 2)
|
| 122 |
result[f'{biomarker}_percentile'] = round(res['percentile'], 1)
|
| 123 |
|
| 124 |
-
# Context-aware interpretation
|
| 125 |
z = res['z_score']
|
| 126 |
higher_is_better = biomarker in HIGHER_IS_BETTER
|
| 127 |
|
|
@@ -129,9 +129,9 @@ def process_batch_data(df: pd.DataFrame, normative_df: pd.DataFrame,
|
|
| 129 |
# For steps, sleep, activity: high is good
|
| 130 |
if z < -2:
|
| 131 |
result[f'{biomarker}_interpretation'] = 'Very Low ⚠️'
|
| 132 |
-
elif z < -
|
| 133 |
result[f'{biomarker}_interpretation'] = 'Below Average'
|
| 134 |
-
elif z <
|
| 135 |
result[f'{biomarker}_interpretation'] = 'Average'
|
| 136 |
elif z < 2:
|
| 137 |
result[f'{biomarker}_interpretation'] = 'Above Average ✓'
|
|
@@ -141,9 +141,9 @@ def process_batch_data(df: pd.DataFrame, normative_df: pd.DataFrame,
|
|
| 141 |
# For HR, BP, PWV: low is good
|
| 142 |
if z < -2:
|
| 143 |
result[f'{biomarker}_interpretation'] = 'Very Low ✓✓'
|
| 144 |
-
elif z < -
|
| 145 |
result[f'{biomarker}_interpretation'] = 'Below Average ✓'
|
| 146 |
-
elif z <
|
| 147 |
result[f'{biomarker}_interpretation'] = 'Average'
|
| 148 |
elif z < 2:
|
| 149 |
result[f'{biomarker}_interpretation'] = 'Above Average'
|
|
@@ -334,16 +334,16 @@ def generate_pdf_report(patient_info: dict, measurements: dict, z_scores: dict =
|
|
| 334 |
value = measurements.get(biomarker, 'N/A')
|
| 335 |
label = BIOMARKER_LABELS.get(biomarker, biomarker.replace('_', ' ').title())
|
| 336 |
|
| 337 |
-
# Context-aware interpretation
|
| 338 |
higher_is_better = biomarker in HIGHER_IS_BETTER
|
| 339 |
|
| 340 |
if higher_is_better:
|
| 341 |
# For steps, sleep, activity: high is good
|
| 342 |
if z < -2:
|
| 343 |
interp = "Very Low ⚠️"
|
| 344 |
-
elif z < -
|
| 345 |
interp = "Below Average"
|
| 346 |
-
elif z <
|
| 347 |
interp = "Average"
|
| 348 |
elif z < 2:
|
| 349 |
interp = "Above Average ✓"
|
|
@@ -353,9 +353,9 @@ def generate_pdf_report(patient_info: dict, measurements: dict, z_scores: dict =
|
|
| 353 |
# For HR, BP, PWV: low is good
|
| 354 |
if z < -2:
|
| 355 |
interp = "Very Low ✓✓"
|
| 356 |
-
elif z < -
|
| 357 |
interp = "Below Average ✓"
|
| 358 |
-
elif z <
|
| 359 |
interp = "Average"
|
| 360 |
elif z < 2:
|
| 361 |
interp = "Above Average"
|
|
|
|
| 121 |
result[f'{biomarker}_z'] = round(res['z_score'], 2)
|
| 122 |
result[f'{biomarker}_percentile'] = round(res['percentile'], 1)
|
| 123 |
|
| 124 |
+
# Context-aware interpretation (Average = -0.5 to 0.5)
|
| 125 |
z = res['z_score']
|
| 126 |
higher_is_better = biomarker in HIGHER_IS_BETTER
|
| 127 |
|
|
|
|
| 129 |
# For steps, sleep, activity: high is good
|
| 130 |
if z < -2:
|
| 131 |
result[f'{biomarker}_interpretation'] = 'Very Low ⚠️'
|
| 132 |
+
elif z < -0.5:
|
| 133 |
result[f'{biomarker}_interpretation'] = 'Below Average'
|
| 134 |
+
elif z < 0.5:
|
| 135 |
result[f'{biomarker}_interpretation'] = 'Average'
|
| 136 |
elif z < 2:
|
| 137 |
result[f'{biomarker}_interpretation'] = 'Above Average ✓'
|
|
|
|
| 141 |
# For HR, BP, PWV: low is good
|
| 142 |
if z < -2:
|
| 143 |
result[f'{biomarker}_interpretation'] = 'Very Low ✓✓'
|
| 144 |
+
elif z < -0.5:
|
| 145 |
result[f'{biomarker}_interpretation'] = 'Below Average ✓'
|
| 146 |
+
elif z < 0.5:
|
| 147 |
result[f'{biomarker}_interpretation'] = 'Average'
|
| 148 |
elif z < 2:
|
| 149 |
result[f'{biomarker}_interpretation'] = 'Above Average'
|
|
|
|
| 334 |
value = measurements.get(biomarker, 'N/A')
|
| 335 |
label = BIOMARKER_LABELS.get(biomarker, biomarker.replace('_', ' ').title())
|
| 336 |
|
| 337 |
+
# Context-aware interpretation (Average = -0.5 to 0.5)
|
| 338 |
higher_is_better = biomarker in HIGHER_IS_BETTER
|
| 339 |
|
| 340 |
if higher_is_better:
|
| 341 |
# For steps, sleep, activity: high is good
|
| 342 |
if z < -2:
|
| 343 |
interp = "Very Low ⚠️"
|
| 344 |
+
elif z < -0.5:
|
| 345 |
interp = "Below Average"
|
| 346 |
+
elif z < 0.5:
|
| 347 |
interp = "Average"
|
| 348 |
elif z < 2:
|
| 349 |
interp = "Above Average ✓"
|
|
|
|
| 353 |
# For HR, BP, PWV: low is good
|
| 354 |
if z < -2:
|
| 355 |
interp = "Very Low ✓✓"
|
| 356 |
+
elif z < -0.5:
|
| 357 |
interp = "Below Average ✓"
|
| 358 |
+
elif z < 0.5:
|
| 359 |
interp = "Average"
|
| 360 |
elif z < 2:
|
| 361 |
interp = "Above Average"
|
pages/1_Batch_Analysis.py
CHANGED
|
@@ -266,3 +266,4 @@ st.markdown(
|
|
| 266 |
"Built with ❤️ in Düsseldorf. © Lars Masanneck 2026."
|
| 267 |
)
|
| 268 |
|
|
|
|
|
|
| 266 |
"Built with ❤️ in Düsseldorf. © Lars Masanneck 2026."
|
| 267 |
)
|
| 268 |
|
| 269 |
+
|
pages/2_PDF_Report.py
CHANGED
|
@@ -218,16 +218,16 @@ if st.button("📄 Generate PDF Report", type="primary"):
|
|
| 218 |
pct = data['percentile']
|
| 219 |
value = measurements[biomarker]
|
| 220 |
|
| 221 |
-
# Context-aware interpretation
|
| 222 |
higher_is_better = biomarker in HIGHER_IS_BETTER
|
| 223 |
|
| 224 |
if higher_is_better:
|
| 225 |
# For steps, sleep, activity: high is good
|
| 226 |
if z < -2:
|
| 227 |
interp = "Very Low ⚠️"
|
| 228 |
-
elif z < -
|
| 229 |
interp = "Below Average"
|
| 230 |
-
elif z <
|
| 231 |
interp = "Average"
|
| 232 |
elif z < 2:
|
| 233 |
interp = "Above Average ✓"
|
|
@@ -237,9 +237,9 @@ if st.button("📄 Generate PDF Report", type="primary"):
|
|
| 237 |
# For HR: low is good
|
| 238 |
if z < -2:
|
| 239 |
interp = "Very Low ✓✓"
|
| 240 |
-
elif z < -
|
| 241 |
interp = "Below Average ✓"
|
| 242 |
-
elif z <
|
| 243 |
interp = "Average"
|
| 244 |
elif z < 2:
|
| 245 |
interp = "Above Average"
|
|
|
|
| 218 |
pct = data['percentile']
|
| 219 |
value = measurements[biomarker]
|
| 220 |
|
| 221 |
+
# Context-aware interpretation (Average = -0.5 to 0.5)
|
| 222 |
higher_is_better = biomarker in HIGHER_IS_BETTER
|
| 223 |
|
| 224 |
if higher_is_better:
|
| 225 |
# For steps, sleep, activity: high is good
|
| 226 |
if z < -2:
|
| 227 |
interp = "Very Low ⚠️"
|
| 228 |
+
elif z < -0.5:
|
| 229 |
interp = "Below Average"
|
| 230 |
+
elif z < 0.5:
|
| 231 |
interp = "Average"
|
| 232 |
elif z < 2:
|
| 233 |
interp = "Above Average ✓"
|
|
|
|
| 237 |
# For HR: low is good
|
| 238 |
if z < -2:
|
| 239 |
interp = "Very Low ✓✓"
|
| 240 |
+
elif z < -0.5:
|
| 241 |
interp = "Below Average ✓"
|
| 242 |
+
elif z < 0.5:
|
| 243 |
interp = "Average"
|
| 244 |
elif z < 2:
|
| 245 |
interp = "Above Average"
|