Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -110,21 +110,22 @@ def predict_brain_age(nifti_file, actual_age, sex):
|
|
110 |
predicted_brain_age + (actual_age * 0.062) - 2.96 if actual_age > 18 else predicted_brain_age
|
111 |
)
|
112 |
|
113 |
-
|
|
|
|
|
114 |
|
115 |
-
#
|
116 |
-
return f"Predicted Brain Age
|
117 |
-
f"Brain Age Difference (BAD): {brain_age_difference:.2f} years"
|
118 |
|
119 |
# 🔹 Gradio Interface Setup
|
120 |
with gr.Blocks() as demo:
|
121 |
gr.Markdown("""
|
122 |
-
# 🧠 Brain Age
|
123 |
-
Upload a preprocessed T1w MRI scan (.nii.gz), enter the age and sex, and get a brain age prediction.
|
124 |
|
125 |
The following preprocessing are required.
|
126 |
1. Skull-stripping using [SynthStrip](https://surfer.nmr.mgh.harvard.edu/docs/synthstrip/) with the `--no-csf` flag for optimal results.
|
127 |
-
2. N4 bias field correction using [ANTs]
|
128 |
3. Affine registration to the MNI 1mm isotropic template space.
|
129 |
""")
|
130 |
|
@@ -136,8 +137,8 @@ with gr.Blocks() as demo:
|
|
136 |
submit_button = gr.Button("Predict")
|
137 |
|
138 |
with gr.Column(scale=2):
|
139 |
-
brain_age_output = gr.Textbox(label="Predicted Brain Age")
|
140 |
-
bad_output = gr.
|
141 |
|
142 |
submit_button.click(
|
143 |
fn=predict_brain_age,
|
|
|
110 |
predicted_brain_age + (actual_age * 0.062) - 2.96 if actual_age > 18 else predicted_brain_age
|
111 |
)
|
112 |
|
113 |
+
# Determine color: Red if positive, Green if negative
|
114 |
+
color = "red" if brain_age_difference > 0 else "green"
|
115 |
+
bad_output_html = f"<span style='color:{color}; font-weight:bold;'>Brain Age Difference (BAD): {brain_age_difference:.2f} years</span>"
|
116 |
|
117 |
+
# Return formatted outputs
|
118 |
+
return f"**Predicted Brain Age:** {predicted_brain_age_corrected:.2f} years", bad_output_html
|
|
|
119 |
|
120 |
# 🔹 Gradio Interface Setup
|
121 |
with gr.Blocks() as demo:
|
122 |
gr.Markdown("""
|
123 |
+
# 🧠 BrainAgeNeXt: Advancing Brain Age Modeling
|
124 |
+
Upload a preprocessed T1w MRI scan (.nii.gz), enter the age and sex of the subject, and get a brain age prediction.
|
125 |
|
126 |
The following preprocessing are required.
|
127 |
1. Skull-stripping using [SynthStrip](https://surfer.nmr.mgh.harvard.edu/docs/synthstrip/) with the `--no-csf` flag for optimal results.
|
128 |
+
2. N4 bias field correction using [ANTs](https://github.com/ANTsX/ANTs/wiki/N4BiasFieldCorrection).
|
129 |
3. Affine registration to the MNI 1mm isotropic template space.
|
130 |
""")
|
131 |
|
|
|
137 |
submit_button = gr.Button("Predict")
|
138 |
|
139 |
with gr.Column(scale=2):
|
140 |
+
brain_age_output = gr.Textbox(label="Predicted Brain Age", interactive=False)
|
141 |
+
bad_output = gr.HTML(label="Brain Age Difference (BAD)") # Use gr.HTML for colored text
|
142 |
|
143 |
submit_button.click(
|
144 |
fn=predict_brain_age,
|