I have a DICOM RT dose file (It contains physical dose). I want to convert it to equivalent dose of 2 Gy (EQD2) based on the below formula. That is, find the dose of each voxel (di) and put it in the formula and convert it to EQD2 (I have assumed the value of n to be one in the formula.).
I am beginner in Python. To do this, using the following code, I got the dose of each pixel and put it in the formula. But as you can see in the figure 3, the dose is not converted correctly. (Even, the dose in the green areas is zero) Can you help me? thanks a lot
import pydicom
import numpy as np
# Load the DICOM RT dose file
dose_file = pydicom.dcmread(r'D:\rt d\RD.1.3.6.1.4.1.33868.20240822152035.dcm')
# Extract the dose data (physical dose at each voxel in Gy)
dose_array = dose_file.pixel_array.astype(np.float32)
# Print shape of the dose array (3D shape for the dose distribution)
print("Dose array shape:", dose_array.shape)
# Parameters for the LQ model
alpha_beta_tumor = 10 # α/β ratio for tumor tissue
# Apply the LQ formula to each voxel's dose
eqd2_array = dose_array * (1+(dose_array / alpha_beta_tumor))/ (1+(2 / alpha_beta_tumor))
# Print shape of the EQD2 array to verify it's the same as the dose array
print("EQD2 array shape:", eqd2_array.shape)
# Store the EQD2 values back into the DICOM file
dose_file.PixelData = eqd2_array.tobytes()
# Save the new DICOM RT dose file with EQD2 values
dose_file.save_as(r'D:\rt eqd2_file.dcm')
RT Dose uses a scaling factor to convert the raw integer values in Pixel Data to dose:
from pydicom import dcmread
ds = dcmread("path/to/dicom/file")
dose = ds.pixel_array.astype("f4") * ds.DoseGridScaling
The next step is to convert to EQD2, which it looks like you've got correct, however after that you need to convert your float EQD2 values back to integers (as Pixel Data must be encoded integers) along with a valid scaling factor. Once you've done that you can then set Pixel Data and Dose Grid Scaling with the new values.