DICOM Conversion#
NIfTI to DICOM RTSTUCT#
- platipy.dicom.io.nifti_to_rtstruct.convert_nifti(dcm_path, mask_input, output_file, color_map=<matplotlib.colors.LinearSegmentedColormap object>)#
Convert a set of masks to a DICOM RTStruct object.
This function now utilises the rt-utils package: https://github.com/qurit/rt-utils We keep this function in here for compatibility
- Parameters:
dcm_path (str|pathlib.Path) – Path to the reference DICOM series
mask_input (dict|list) – A dictionary containing the name as key and image as value. Or a list of string with comma separated name and mask paths (name,path)
output_file (str|pathlib.Path) – The path to the file to write the RTStruct
color_map (matplotlib.colors.Colormap, optional) – Colormap to use for output. Defaults to matplotlib.colormaps.get_cmap(“rainbow”).
DICOM RTSTRUCT to NIfTI#
- platipy.dicom.io.rtstruct_to_nifti.convert_rtstruct(dcm_img, dcm_rt_file, prefix='Struct_', output_dir='.', output_img=None, spacing=None, replace_slashes_with='')#
Convert a DICOM RTSTRUCT to NIFTI masks.
The masks are stored as NIFTI files in the output directory
- Parameters:
dcm_img (str|pathlib.Path) – Path to the reference DICOM image series
dcm_rt_file (str|pathlib.Path) – Path to the DICOM RTSTRUCT file
prefix (str, optional) – The prefix to give the output files. Defaults to “Struct_”.
output_dir (str|pathlib.Path, optional) – Path to the output directory. Defaults to “.”.
output_img (str|pathlib.Path, optional) – If set, write the reference image to this file as in NIFTI format. Defaults to None.
spacing (list, optional) – Values of image spacing to override. Defaults to None.
replace_slashes_with (str, optional) – String to replace “/” and “” with. Set to None disable replacement of slashes. Defaults to “”.
- platipy.dicom.io.rtstruct_to_nifti.fix_missing_data(contour_data)#
Fixed a set of contour data if there are values missing
- Parameters:
contour_data (pydicom.Sequence) – The contour sequence from the DICOM object
- Returns:
The array of contour data with missing values fixed
- Return type:
np.array
- platipy.dicom.io.rtstruct_to_nifti.read_dicom_image(dicom_path)#
Read a DICOM image series
- Parameters:
dicom_path (str|pathlib.Path) – Path to the DICOM series to read
- Returns:
The image as a SimpleITK Image
- Return type:
sitk.Image
- platipy.dicom.io.rtstruct_to_nifti.read_dicom_struct_file(filename)#
Read a DICOM RTSTRUCT file
- Parameters:
filename (str|pathlib.Path) – Path to the RTSTRUCT to read
- Returns:
The RTSTRUCT as a DICOM Dataset
- Return type:
pydicom.Dataset
- platipy.dicom.io.rtstruct_to_nifti.transform_point_set_from_dicom_struct(dicom_image, dicom_struct, spacing_override=None)#
Converts a set of points from a DICOM RTSTRUCT into a mask array
- Parameters:
dicom_image (sitk.Image) – The reference image
dicom_struct (pydicom.Dataset) – The DICOM RTSTRUCT
spacing_override (list) – The spacing to override. Defaults to None
- Returns:
Returns a list of masks and a list of structure names
- Return type:
tuple
DICOM RTDOSE to NIfTI#
- platipy.dicom.io.rtdose_to_nifti.convert_rtdose(dcm_dose, force=False, dose_output_path=None)#
Convert DICOM RTDose to SimpleITK image, saving as NiFTI if needed.
- Parameters:
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:
The dose grid as a SimpleITK image
- Return type:
SimpleITK.Image