Is there an easy way to determine the boundaries/start of a segmentation?

I have segmentations/contours which correspond to a CT analogous to this example

They exist only in approximately 20 slices buried within 200 slices of 3d image set. The remaining slices are completely empty space.

For quality assurance purposes I would like to determine where the contours starts and ends so I can save out representative images

e.g. goes from slice 120-140. I would then take sample images from 125, 130 and 135.

The contour files and images are initially DICOM but are converted to nrrd down the line. I suspect you could iterate through the image array to find the slices. I just wonder if there’s an easier way. Any help would be great.

Hello,

Look into using the LabelStatisticsImageFilter which computes an axis aligned bounding box in index space.

1 Like

The ITKMorphologicalContourInterpolation module will interpolate contours between slices.

Thanks! this worked well. For anyone reading in the future. Essentially below is what you’re looking for in python. This returns a bounding box where the format is [xmin, xmax, ymin, ymax, zmin, zmax].

stats = sitk.LabelStatisticsImageFilter()
stats.Execute(image_1, label_1)
stats.GetBoundingBox(1)
1 Like