Update app.py
Browse files
app.py
CHANGED
@@ -6,9 +6,9 @@ import plotly.graph_objs as go
|
|
6 |
|
7 |
# Constants from linear regression
|
8 |
REGRESSION_CONSTANTS = {
|
9 |
-
'
|
10 |
-
'
|
11 |
-
'
|
12 |
}
|
13 |
|
14 |
# Load medication data
|
@@ -37,8 +37,7 @@ def generate_predictions(medication_data, site, bmd, mu, sigma):
|
|
37 |
for year in row.index[1:-1]: # Skip 'Medication' and 'Site' columns
|
38 |
if not pd.isna(row[year]):
|
39 |
percentage_increase = row[year]
|
40 |
-
|
41 |
-
predicted_bmd = bmd * (1 + percentage_increase)
|
42 |
predicted_tscore = calculate_tscore(predicted_bmd, mu, sigma)
|
43 |
|
44 |
predictions['Year'].append(year.replace(" Year", "")) # Simplify year label
|
@@ -48,7 +47,6 @@ def generate_predictions(medication_data, site, bmd, mu, sigma):
|
|
48 |
all_results.append({'Drug': drug, 'Predictions': predictions})
|
49 |
return all_results
|
50 |
|
51 |
-
|
52 |
# Display results as table and plots
|
53 |
def display_results(predictions, site):
|
54 |
st.subheader(f"Predictions for {site}")
|
@@ -86,6 +84,16 @@ def display_results(predictions, site):
|
|
86 |
def main():
|
87 |
st.title("BMD and T-score Prediction Tool")
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
# Input patient data
|
90 |
bmd_patient = st.number_input(
|
91 |
"Initial BMD",
|
@@ -93,8 +101,6 @@ def main():
|
|
93 |
value=0.800, step=0.001,
|
94 |
format="%.3f"
|
95 |
)
|
96 |
-
site_options = ['FN', 'TH', 'LS']
|
97 |
-
site = st.selectbox("Select Region (Site)", site_options)
|
98 |
|
99 |
# Load constants and medication data
|
100 |
constants = REGRESSION_CONSTANTS[site]
|
|
|
6 |
|
7 |
# Constants from linear regression
|
8 |
REGRESSION_CONSTANTS = {
|
9 |
+
'Femoral Neck': {'mu': 0.916852, 'sigma': 0.120754},
|
10 |
+
'Total Hip': {'mu': 0.955439, 'sigma': 0.125406},
|
11 |
+
'Lumbar spine (L1-L4)': {'mu': 1.131649, 'sigma': 0.139618},
|
12 |
}
|
13 |
|
14 |
# Load medication data
|
|
|
37 |
for year in row.index[1:-1]: # Skip 'Medication' and 'Site' columns
|
38 |
if not pd.isna(row[year]):
|
39 |
percentage_increase = row[year]
|
40 |
+
predicted_bmd = bmd * (1 + percentage_increase) # Adjusted as per your update
|
|
|
41 |
predicted_tscore = calculate_tscore(predicted_bmd, mu, sigma)
|
42 |
|
43 |
predictions['Year'].append(year.replace(" Year", "")) # Simplify year label
|
|
|
47 |
all_results.append({'Drug': drug, 'Predictions': predictions})
|
48 |
return all_results
|
49 |
|
|
|
50 |
# Display results as table and plots
|
51 |
def display_results(predictions, site):
|
52 |
st.subheader(f"Predictions for {site}")
|
|
|
84 |
def main():
|
85 |
st.title("BMD and T-score Prediction Tool")
|
86 |
|
87 |
+
# DEXA Machine Selection
|
88 |
+
dexa_machine = st.selectbox("DEXA Machine", ["LUNAR"])
|
89 |
+
|
90 |
+
# Gender Selection
|
91 |
+
gender = st.selectbox("Gender", ["Female"])
|
92 |
+
|
93 |
+
# Location (Site) Selection
|
94 |
+
site_options = ['Lumbar spine (L1-L4)', 'Femoral Neck', 'Total Hip']
|
95 |
+
site = st.selectbox("Select Region (Site)", site_options)
|
96 |
+
|
97 |
# Input patient data
|
98 |
bmd_patient = st.number_input(
|
99 |
"Initial BMD",
|
|
|
101 |
value=0.800, step=0.001,
|
102 |
format="%.3f"
|
103 |
)
|
|
|
|
|
104 |
|
105 |
# Load constants and medication data
|
106 |
constants = REGRESSION_CONSTANTS[site]
|