In [107]:
M = 60 # Pajzsmirigy tömege [g]
D = 150 # Kívánt effektív dózis [Gy] 

cps0 = 26901 # Standard nyakfantomban
t = np.array([0, 0.09, 0.24, 0.94, 1.96, 5.95]) # mérési idópontok [napok]
peak = np.array([0, 3689, 8028, 13630, 13277, 9017]) # mért CPS
bkg  = np.array([0, 198, 143, 124, 118, 104]) # háttér CPS

In [108]:
import pandas as pd
import numpy as np

net  = peak - bkg*73/40
riu  = net/cps0
data = np.array([t, peak, bkg, net, riu]).T
data = pd.DataFrame(data, columns=['t', 'peak', 'bkg', 'net', 'riu'])

print(data)


      t   peak  bkg        net       riu
0  0.00      0    0      0.000  0.000000
1  0.09   3689  198   3327.650  0.123700
2  0.24   8028  143   7767.025  0.288726
3  0.94  13630  124  13403.700  0.498260
4  1.96  13277  118  13061.650  0.485545
5  5.95   9017  104   8827.200  0.328137

In [109]:
from scipy.optimize import curve_fit

def f(x, kt, kB, kT):
    return kt/(kB-kT)*(np.exp(-kT*x)-np.exp(-kB*x))

p, cov = curve_fit(f, t, riu, method='trf', p0=[1, 1, 0])
print('kt = ', p[0], '/d')
print('kB = ', p[1], '/d')
print('kT = ', p[2], '/d')


kt =  1.66494634359 /d
kB =  2.91931445486 /d
kT =  0.0985938908022 /d

In [110]:
import matplotlib.pyplot as plt

plt.plot(t, riu, 'ro', label='RIU')
tt = np.linspace(0, 10, 100)
plt.plot(tt, f(tt, p[0], p[1], p[2]), 'g-')
plt.xlabel('Nap')
plt.ylabel('RIU [%]')
plt.legend()
plt.grid()
plt.show()



In [111]:
from scipy.optimize import fmin

riu_max = max([f(x, *p) for x in tt])
t_max = fmin(lambda x: -f(x, *p), 0)
print('RIU_max = ', riu_max)
print('t_max = ', t_max[0])
print('T_eff = ', np.log(2)/p[2])
E = 2.808
Aa = M*D*p[1]*p[2]/(E*p[0])
print(Aa)


Optimization terminated successfully.
         Current function value: -0.506626
         Iterations: 25
         Function evaluations: 50
RIU_max =  0.506617682983
t_max =  1.201125
T_eff =  7.03032586421
554.084558401

In [ ]: