From feb5b434dd00abdd36f0707442d19f2a9e0d5ff3 Mon Sep 17 00:00:00 2001 From: Phillip Chlap Date: Tue, 22 Feb 2022 23:39:15 +0000 Subject: [PATCH 1/2] Pass through force flag --- platipy/dicom/io/rtdose_to_nifti.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/platipy/dicom/io/rtdose_to_nifti.py b/platipy/dicom/io/rtdose_to_nifti.py index 2152e635..e65c44b6 100644 --- a/platipy/dicom/io/rtdose_to_nifti.py +++ b/platipy/dicom/io/rtdose_to_nifti.py @@ -16,11 +16,12 @@ 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. @@ -28,11 +29,7 @@ def convert_rtdose(dcm_dose, dose_output_path=None): 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) dose = sitk.ReadImage(str(dcm_dose)) dose = sitk.Cast(dose, sitk.sitkFloat32) dose = dose * ds.DoseGridScaling From 1af5cabd437f904a83e23297f4fcfbbe6c40cc9f Mon Sep 17 00:00:00 2001 From: Phillip Chlap Date: Tue, 22 Feb 2022 23:40:06 +0000 Subject: [PATCH 2/2] Pass force --- platipy/dicom/io/rtdose_to_nifti.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platipy/dicom/io/rtdose_to_nifti.py b/platipy/dicom/io/rtdose_to_nifti.py index e65c44b6..8544d71c 100644 --- a/platipy/dicom/io/rtdose_to_nifti.py +++ b/platipy/dicom/io/rtdose_to_nifti.py @@ -29,7 +29,7 @@ def convert_rtdose(dcm_dose, force=False, dose_output_path=None): SimpleITK.Image: The dose grid as a SimpleITK image """ - 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