Skip to content

Commit

Permalink
Merge pull request #120 from pyplati/allow-dose-conversion-from-dataset
Browse files Browse the repository at this point in the history
Allow dose conversion from dataset
  • Loading branch information
pchlap authored Feb 22, 2022
2 parents 2fe43d6 + 1af5cab commit 5329478
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions platipy/dicom/io/rtdose_to_nifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,20 @@
import SimpleITK as sitk


def convert_rtdose(dcm_dose, dose_output_path=None):
def convert_rtdose(dcm_dose, force=False, dose_output_path=None):
"""Convert DICOM RTDose to SimpleITK image, saving as NiFTI if needed.
Args:
dcm_dose (str|path|pydicom.Dataset): Path to DICOM dose file
dcm_dose (str|path): Path to DICOM dose file
force (bool): force flag to pass to pydicom
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
"""

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

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

0 comments on commit 5329478

Please sign in to comment.