opentps.core.processing.segmentation package

Submodules

opentps.core.processing.segmentation.segmentation3D module

applyThreshold(image, thresholdMin, thresholdMax=inf)

Apply a threshold to an image and return a ROIMask object (True if value > thresholdMin and value < thresholdMax)

Parameters:
  • image (Image3D) – The image to be thresholded

  • thresholdMin (float) – The minimum threshold value

  • thresholdMax (float) – The maximum threshold value (default: np.inf)

Returns:

mask – The mask of the thresholded image

Return type:

ROIMask

getBoxAboveThreshold(data: Image3D, threshold=0.0)

Get the box around an ROI in scanner coordinates and apply a threshold (using the ROI origin and spacing)

Parameters:
  • data (Image3D) – The image with the ROI to be thresholded

  • threshold (float) – The minimum threshold value in the ROI(default: 0.)

Returns:

boundingBox – The box around which the data is cropped and the threshold applied under the form [[x1, X2], [y1, y2], [z1, z2]]

Return type:

list of tuples or list

getBoxAroundROI(ROI) Sequence[Sequence[float]]

Returns the 3D scanner coordinates (in mm) of the smallest box surrounding the given ROI. By convention, the returned box coordinates are the coordinates of centers of the voxels at the extremities of the box. In other words, a box that passes through the center of a voxel necessarily contains this voxel. For example, in 1 dimension, with a spacing of 1mm and origin at 0mm, a box around voxels [1,2] will results in box coordinates [1,2] mm even though the size of the box is 2mm (because it includes 2 voxels of 1mm spacing).

Parameters:

ROI (an ROIContour or ROIMask) – The contour that is contained in the desired box

Returns:

boxInUniversalCoords – The box coordinates, under the form [[x1, X2], [y1, y2], [z1, z2]]

Return type:

list of tuples or list

opentps.core.processing.segmentation.segmentationCT module

class SegmentationCT(ct)

Bases: object

Class for CT segmentation

Parameters:

ct (Image3D) – The CT image to be segmented

Variables:

ct (Image3D) – The CT image to be segmented

segmentBody()

Segment the body from the CT image

Returns:

body – The body mask (bool mask)

Return type:

Image3D

segmentBones(body=None)

Segment the bones from the CT image

Parameters:

body (Image3D) – The body mask (bool mask)

Returns:

bones – The bones mask (bool mask)

Return type:

Image3D

segmentLungs(body=None)

Segment the lungs from the CT image

Parameters:

body (Image3D) – The body mask (bool mask)

Returns:

lungs – The lungs mask (bool mask)

Return type:

Image3D

compute3DStructuralElement(radiusXYZ, spacing=[1, 1, 1])

Compute a 3D structural element for morphological operations (e.g. dilation, erosion).

Parameters:
  • radiusXYZ (list) – The radius of the structural element in each direction

  • spacing (list) – The spacing of the image in each direction (default: [1,1,1])

Returns:

filt – The structural element (bool mask)

Return type:

bool numpy array

Module contents