Skip to content

Commit

Permalink
Allow RTDose to pass in pydicom Dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
pchlap committed Feb 22, 2022
1 parent f4e4cd1 commit 2b1894f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions platipy/dicom/io/rtdose_to_nifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ def convert_rtdose(dcm_dose, dose_output_path=None):
"""Convert DICOM RTDose to SimpleITK image, saving as NiFTI if needed.
Args:
dcm_dose (str|path): Path to DICOM dose file
dcm_dose (str|path|pydicom.Dataset): Path to DICOM dose file
dose_output_path (str|path, optional): If set, NiFTI file will be written. Defaults to
None.
Returns:
SimpleITK.Image: The dose grid as a SimpleITK image
"""

ds = pydicom.read_file(dcm_dose)
if isinstance(dcm_dose, pydicom.Dataset):
ds = dcm_dose
else:
ds = pydicom.read_file(dcm_dose)

dose = sitk.ReadImage(str(dcm_dose))
dose = sitk.Cast(dose, sitk.sitkFloat32)
dose = dose * ds.DoseGridScaling
Expand Down

0 comments on commit 2b1894f

Please sign in to comment.