File size: 1,158 Bytes
654bb88
 
 
 
 
395dfad
654bb88
395dfad
654bb88
395dfad
654bb88
395dfad
654bb88
395dfad
 
 
654bb88
 
395dfad
 
654bb88
 
 
395dfad
654bb88
 
 
395dfad
654bb88
395dfad
 
654bb88
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import gradio as gr
import numpy as np

def calculate_tia(t1, a1, t2, a2):
    try:
        # حساب معدل الإفراغ k
        k = np.log(a1 / a2) / (t2 - t1)
        # حساب النشاط الابتدائي A₀
        a0 = a1 / np.exp(-k * t1)
        # حساب النشاط التكاملي TIA
        tia = a0 / k
        result = f"**Results:**\n- A₀ = {a0:.2f} MBq\n- k = {k:.5f} per hour\n- TIA = {tia:.2f} MBq·h"
    except:
        result = "Error: Please enter valid numbers."

    return result

with gr.Blocks() as demo:
    gr.Markdown("# Lu-177 Dosimetry Tool\nEstimate Time-Integrated Activity (TIA) from Two SPECT Time Points using Mono-Exponential Modeling.")
    
    with gr.Row():
        t1 = gr.Number(label="Time Point 1 (hours)", value=20)
        a1 = gr.Number(label="Activity at t1 (MBq)", value=12)
    
    with gr.Row():
        t2 = gr.Number(label="Time Point 2 (hours)", value=60)
        a2 = gr.Number(label="Activity at t2 (MBq)", value=4)
    
    button = gr.Button("Calculate TIA")
    output = gr.Markdown()

    button.click(fn=calculate_tia, inputs=[t1, a1, t2, a2], outputs=output)

demo.launch()