Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:19:57

0001 import numpy as np
0002 from numpy import exp, sqrt, log, pi
0003 
0004 def Integrate(f, x) :
0005     dx = x[1:] - x[:-1]
0006     integral = np.sum(f[:-1] * dx)
0007     return integral
0008 
0009 input_file = "analysed_spectra.csv"
0010 y, f, d = np.loadtxt(input_file, delimiter=',', unpack=True)
0011 
0012 
0013 # --------------------------------------
0014 #        Microdosimetric means
0015 # --------------------------------------
0016 
0017 yBarF = Integrate(y*f, y)
0018 yBarD = Integrate(y*d, y)
0019 
0020 print("")
0021 print("Weighted averages of:")
0022 print("f(y):   ", round(yBarF, 3) )
0023 print("d(y):   ", round(yBarD, 3) )
0024 print("")
0025 
0026 
0027 # --------------------------------------
0028 #        Quality factor
0029 # --------------------------------------
0030 
0031 # Quality factor of the radiation, used in radiation protection to weight the absorbed dose.
0032 
0033 # The approximation employed here follows ICRU 40.
0034 Q_y = 5510./y * ( 1 - exp(-5E-5*y**2 -2E-7*y**3) )
0035 
0036 Q = Integrate(Q_y*d, y)
0037 
0038 print("Average quality factor Q:   ", round(Q, 3) )
0039 print("")
0040 
0041 
0042 # --------------------------------------
0043 # RBE via Microdosimetric Kinetic Model
0044 # --------------------------------------
0045 
0046 # The MKM can calculate the alpha parameter of the survival curve from an average of the microdosimetric
0047 # spectrum, weighted by y and corrected for saturation.
0048 
0049 # Saturation coefficient:
0050 y0 = 125. # keV/um  according to ICRU 36
0051 #y0 = 150. # keV/um according to Kase 2006, for Carbon ions
0052 
0053 # Saturation corrected average, usually written as y*:
0054 y_star = y0**2 * Integrate( (1 - exp(-(y/y0)**2))* f, y ) / yBarF
0055 
0056 print("y*:   ", round(y_star, 3) )
0057 
0058 # The following parameters depend on the cell line, and need to be known in advance.
0059 # The ones below are the ones employed by Kase 2006 for HSG cells.
0060 # Refer to said paper for a description of each parameter.
0061 alpha_0 = 0.13 # Gy**-1
0062 beta = 0.05 # Gy**-2
0063 rho = 1. # g/cm**3
0064 r_d = 0.42 # um
0065 
0066 keV_to_Gy=1.602E-16; um_to_cm=1.E-4; g_to_kg=1.E-3
0067 rho*=g_to_kg; r_d*=um_to_cm; y_star*=(keV_to_Gy/um_to_cm)
0068 
0069 alpha = alpha_0 + beta/(rho*pi*r_d**2) * y_star
0070 
0071 print("alpha:   ", round(alpha, 3) )
0072 
0073 # The RBE is not an absolute value, but depends on the desired survival fraction S
0074 # and on the corresponding photon dose. The latter is also taken from Kase 2006.
0075 S = 0.1
0076 Dx = 5 # Gy for S=0.1
0077 
0078 RBE_MKM = Dx*2*beta / ( sqrt(alpha**2-4*beta*log(S)) - alpha )
0079 
0080 print("RBE via MKM (HSG cells):   ", round(RBE_MKM, 3) )
0081 print("")
0082 
0083 
0084 # --------------------------------------
0085 #   RBE via Loncol weight function r(y)
0086 # --------------------------------------
0087 
0088 # A weight function can be used to estimate the RBE for S=0.1 by weighting the whole spectrum.
0089 # The one by Loncol 1994 provides a good estimate for neutron or proton beams targeting crypt cells,
0090 # but not necessarily for other beams-target combinations.
0091 
0092 weight_function = "weight_function.csv"
0093 y_wf, r_wf, stdev_r_wf = np.loadtxt(weight_function, delimiter=',', unpack=True)
0094 
0095 # The standard deviation of r(y) is due to the uncertainty of radiobiological measurements,
0096 # and as such doesn't represent a limitation of the model.
0097 # Consequently it won't be used in the following RBE estimate.
0098 
0099 # The abscissae of f(y) and r(y) don't (usually) match
0100 # For every value of f(y), I find the corresponding r(y) via linear interpolation
0101 size = len(y)
0102 r = np.zeros(size)
0103 
0104 for i in range(size) :
0105     j = np.argmax( y_wf > y[i] )    # index of first element of y_wf greater than y[i]
0106     
0107     r[i] = ( r_wf[j] + r_wf[j-1] ) /2
0108 
0109 RBE_Lwf = Integrate(r*d, y)
0110 
0111 print("RBE via weight function (crypt cells):   ", round(RBE_Lwf, 3) )
0112 print("")