FrancescoLR commited on
Commit
912d400
·
verified ·
1 Parent(s): 411c17a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -35
app.py CHANGED
@@ -125,40 +125,37 @@ def predict_brain_age(nifti_file, actual_age): #sex
125
 
126
  # 🔹 Gradio Interface Setup
127
  with gr.Blocks() as demo:
128
- gr.Markdown("""
129
- # 🧠 **BrainAgeNeXt**: Advancing Brain Age Modeling
130
- Upload a preprocessed T1w MRI scan (.nii.gz), enter the age and sex of the subject, and get the brain age prediction.
131
-
132
- The following preprocessing steps are required.
133
- 1. Skull-stripping using [SynthStrip](https://surfer.nmr.mgh.harvard.edu/docs/synthstrip/) with the `--no-csf` flag for optimal results.
134
- 2. N4 bias field correction using [ANTs](https://github.com/ANTsX/ANTs/wiki/N4BiasFieldCorrection).
135
- 3. Affine registration to the MNI 1mm isotropic template space.
136
-
137
- **BrainAgeNeXt** has been trained and validated using over 11,000 T1w MRI acquired at 1.5, 3, and 7T. A 1mm isotropic resolution is preferred for the input image but not required. Our [manuscript](https://doi.org/10.1162/imag_a_00487) presents a detailed explanation of **BrainAgeNeXt** and its potential applications.
138
-
139
- Note: this app allows to process only a single MRI at the time. Please visit our [GitHub repository](https://github.com/FrancescoLR/BrainAgeNeXt/tree/main) to install the code on your machine and run BrainAgeNeXt on large datasets )
140
- """)
141
 
142
- with gr.Row():
143
- with gr.Column(scale=1):
144
- mri_input = gr.File(label="Upload a T1w MRI (NIfTI .nii.gz)")
145
- age_input = gr.Number(label="Enter Age", value=50)
146
- sex_input = gr.Radio(["Male", "Female"], label="Select Sex")
147
- submit_button = gr.Button("Predict")
148
-
149
- with gr.Column(scale=2):
150
- #brain_age_output = gr.Textbox(label="Predicted Brain Age", interactive=False)
151
- #bad_output = gr.HTML(label="Brain Age Difference") # Use gr.HTML for colored text
152
- brain_age_output = gr.Textbox(label="Output")
153
-
154
- submit_button.click(fn=predict_brain_age, inputs=[mri_input, age_input], outputs=[brain_age_output])
155
-
156
- #submit_button.click(
157
- # fn=predict_brain_age,
158
- # inputs=[mri_input, age_input], #sex_input
159
- # outputs=[brain_age_output, bad_output]
160
- #)
161
-
162
  gr.Markdown("""
163
  **Disclaimer:** This is a research tool and is not intended for clinical use.
164
 
@@ -184,5 +181,5 @@ download_model()
184
 
185
  # 🔹 Run Gradio App
186
  if __name__ == "__main__":
187
- # demo.launch(share=True)
188
- demo.launch(share=False, show_api=False)
 
125
 
126
  # 🔹 Gradio Interface Setup
127
  with gr.Blocks() as demo:
128
+ # gr.Markdown("""
129
+ # # 🧠 **BrainAgeNeXt**: Advancing Brain Age Modeling
130
+ # Upload a preprocessed T1w MRI scan (.nii.gz), enter the age and sex of the subject, and get the brain age prediction.
131
+
132
+ # The following preprocessing steps are required.
133
+ # 1. Skull-stripping using [SynthStrip](https://surfer.nmr.mgh.harvard.edu/docs/synthstrip/) with the `--no-csf` flag for optimal results.
134
+ # 2. N4 bias field correction using [ANTs](https://github.com/ANTsX/ANTs/wiki/N4BiasFieldCorrection).
135
+ # 3. Affine registration to the MNI 1mm isotropic template space.
136
+
137
+ # **BrainAgeNeXt** has been trained and validated using over 11,000 T1w MRI acquired at 1.5, 3, and 7T. A 1mm isotropic resolution is preferred for the input image but not required. Our [manuscript](https://doi.org/10.1162/imag_a_00487) presents a detailed explanation of **BrainAgeNeXt** and its potential applications.
138
+ #
139
+ # Note: this app allows to process only a single MRI at the time. Please visit our [GitHub repository](https://github.com/FrancescoLR/BrainAgeNeXt/tree/main) to install the code on your machine and run BrainAgeNeXt on large datasets )
140
+ # """)
141
 
142
+ # with gr.Row():
143
+ # with gr.Column(scale=1):
144
+ # mri_input = gr.File(label="Upload a T1w MRI (NIfTI .nii.gz)")
145
+ # age_input = gr.Number(label="Enter Age", value=50)
146
+ # sex_input = gr.Radio(["Male", "Female"], label="Select Sex")
147
+ # submit_button = gr.Button("Predict")
148
+ #
149
+ # with gr.Column(scale=2):
150
+ # brain_age_output = gr.Textbox(label="Predicted Brain Age", interactive=False)
151
+ # bad_output = gr.HTML(label="Brain Age Difference") # Use gr.HTML for colored text
152
+ #
153
+ # submit_button.click(
154
+ # fn=predict_brain_age,
155
+ # inputs=[mri_input, age_input], #sex_input
156
+ # outputs=[brain_age_output, bad_output]
157
+ # )
158
+
 
 
 
159
  gr.Markdown("""
160
  **Disclaimer:** This is a research tool and is not intended for clinical use.
161
 
 
181
 
182
  # 🔹 Run Gradio App
183
  if __name__ == "__main__":
184
+ demo.launch(share=True)
185
+