Skip to content

Commit

Permalink
Merge pull request #119 from pyplati/allow-dose-conversion-from-dataset
Browse files Browse the repository at this point in the history
Allow RTDose to pass in pydicom Dataset
  • Loading branch information
pchlap authored Feb 22, 2022
2 parents f4e4cd1 + 2b1894f commit 2fe43d6
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 2fe43d6

Please sign in to comment.