I have a 3D array for RTDose. one for predicted and one for ground truth. also, I have 3D array of OAR masks. How do I calculate the mean and max dose at each OAR?
Consider having rtss with two structures one is PTV and second is GTV. below code works to calculate mean and max dose at PTV and GTV. while loading rtss nifti file... PTV contours contains value=1 and GTV contains value=2. and hence same is used while getting dose for these contours.
import nibabel as nib
import numpy as np
rtss_fname="rtss0.nii.gz"
rtdose_fname="rtdose0.nii.gz"
rtss_img = nib.load(rtss_fname)
rtss_array=rtss_img.get_data()
rtdose_img = nib.load(rtdose_fname)
rtdose_array=rtdose_img.get_data()
dose_at_label1=rtdose_array[rtss_array==1]
dose_at_label2=rtdose_array[rtss_array==2]
print("PTV max dose ",dose_at_label1.max())
print("GTV max dose ",dose_at_label2.max())
print("PTV mean dose ",dose_at_label1.mean())
print("GTV mean dose ",dose_at_label2.mean())