phyjaafar commited on
Commit
395dfad
·
verified ·
1 Parent(s): 8f2ac13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -3,23 +3,32 @@ 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()
 
3
 
4
  def calculate_tia(t1, a1, t2, a2):
5
  try:
6
+ # حساب معدل الإفراغ k
7
  k = np.log(a1 / a2) / (t2 - t1)
8
+ # حساب النشاط الابتدائي A₀
9
  a0 = a1 / np.exp(-k * t1)
10
+ # حساب النشاط التكاملي TIA
11
  tia = a0 / k
12
+ result = f"**Results:**\n- A₀ = {a0:.2f} MBq\n- k = {k:.5f} per hour\n- TIA = {tia:.2f} MBq·h"
13
  except:
14
+ result = "Error: Please enter valid numbers."
15
+
16
+ return result
17
 
18
  with gr.Blocks() as demo:
19
+ gr.Markdown("# Lu-177 Dosimetry Tool\nEstimate Time-Integrated Activity (TIA) from Two SPECT Time Points using Mono-Exponential Modeling.")
20
+
21
  with gr.Row():
22
  t1 = gr.Number(label="Time Point 1 (hours)", value=20)
23
  a1 = gr.Number(label="Activity at t1 (MBq)", value=12)
24
+
25
  with gr.Row():
26
  t2 = gr.Number(label="Time Point 2 (hours)", value=60)
27
  a2 = gr.Number(label="Activity at t2 (MBq)", value=4)
28
+
29
  button = gr.Button("Calculate TIA")
30
+ output = gr.Markdown()
31
+
32
  button.click(fn=calculate_tia, inputs=[t1, a1, t2, a2], outputs=output)
33
 
34
  demo.launch()