src.preprocess package

Submodules

src.preprocess.crop_dicom module

src.preprocess.crop_dicom.crop_dicom(path_to_dicom, begin, end, output=None)

This function crops a dicom series in the x-, y- and z-dimension. If an output path is provided, it will save the new series at that location.

Examples for how to specify cropping mask using the begin- and end-parameter:

The given DICOM series contains images with the resolution of 512x512 pixels and 133 images starting at a depth of -10 mm to a depth of -340 mm. Using begin = [0, 0, -10] and end = [512, 512, -340] would give you back the full series. Using begin = [100, 200, -160] and end = [120, 220, -170] would give you a new series with 5 images of size 20x20 pixels.
Parameters:
  • path_to_dicom – String containing the path containing the DICOM-series
  • begin – List containing three numbers representing the starting point for cropping. See examples above.
  • end – List containing three numbers representing the starting point for cropping. See examples above.
  • output – (optional) String containg the path to where to save the cropped series.
Returns:

A list of pydicom Dataset-objects representing the cropped series.

src.preprocess.errors module

exception src.preprocess.errors.EmptyDicomSeriesException(*args)

Bases: Exception

Exception that is raised when the given folder does not contain dcm-files.

src.preprocess.load_dicom module

src.preprocess.load_dicom.load_dicom(path)

Function that orchestrates the loading of dicom datafiles of a dicom series into a numpy-array.

Parameters:path (str) – contains the path to the folder containing the dcm-files of a series.
Returns:numpy-array containing the 3D-representation of the DICOM-series
src.preprocess.load_dicom.read_dicom_files(file_pattern)

Module contents