Spaces:
Running
Running
Create app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,25 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
+
|
4 |
+
def calculate_tia(t1, a1, t2, a2):
|
5 |
+
try:
|
6 |
+
k = np.log(a1 / a2) / (t2 - t1)
|
7 |
+
a0 = a1 / np.exp(-k * t1)
|
8 |
+
tia = a0 / k
|
9 |
+
return f"A₀ = {a0:.2f} MBq\nk = {k:.5f} /h\nTIA = {tia:.2f} MBq·h"
|
10 |
+
except:
|
11 |
+
return "Error: please enter valid numbers."
|
12 |
+
|
13 |
+
with gr.Blocks() as demo:
|
14 |
+
gr.Markdown("## Lu-177 Dosimetry Tool (Two-Time-Point TIA)")
|
15 |
+
with gr.Row():
|
16 |
+
t1 = gr.Number(label="Time Point 1 (hours)", value=20)
|
17 |
+
a1 = gr.Number(label="Activity at t1 (MBq)", value=12)
|
18 |
+
with gr.Row():
|
19 |
+
t2 = gr.Number(label="Time Point 2 (hours)", value=60)
|
20 |
+
a2 = gr.Number(label="Activity at t2 (MBq)", value=4)
|
21 |
+
output = gr.Textbox(label="Results", lines=4)
|
22 |
+
button = gr.Button("Calculate TIA")
|
23 |
+
button.click(fn=calculate_tia, inputs=[t1, a1, t2, a2], outputs=output)
|
24 |
+
|
25 |
+
demo.launch()
|