phyjaafar commited on
Commit
654bb88
·
verified ·
1 Parent(s): 3875308

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -3
app.py CHANGED
@@ -1,3 +1,25 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:bb1161037fd3eb081bd36ecf5c134132270b9e13ddd6d3f74ca5ccdb30f63f15
3
- size 1812
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()