Hi. I have 7 different timepoint (so variable in size) CT data without contrast. I need to mark the gap (meant to be a growth plate) between the bony parts (marked in beige in the screenshot) . It is not uniform so 3D painting doesn’t really help as it includes other gaps inside the segment. I have tried wrap solidify method but when I use it either the software crushes or I get something very inaccurate:
I tried coding as well but it somehow overlaps bone segment instead of filling the gap. This is the code I used:
import slicer
import vtk
import SimpleITK as sitk
import sitkUtils
# 1. Get your segmentation node
segmentationNode = slicer.util.getNode("Segmentation") # Replace with your segmentation name
# 2. Export segmentation to labelmap (binary image)
labelmapVolumeNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLLabelMapVolumeNode")
slicer.modules.segmentations.logic().ExportVisibleSegmentsToLabelmapNode(segmentationNode, labelmapVolumeNode)
# 3. Convert to SimpleITK image
image = sitkUtils.PullVolumeFromSlicer(labelmapVolumeNode)
# 4. Fill gap between two segments (cartilage should be in between)
# We will use morphological closing (dilate then erode) to fill the gap
# Increase kernel size if gap is large
filledImage = sitk.BinaryMorphologicalClosing(image, [5]*3)
# 5. Extract cartilage as the difference (filled - original)
cartilage = sitk.Subtract(filledImage, image)
# 6. Push the cartilage mask as a new labelmap node
cartilageLabelmap = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLLabelMapVolumeNode", "CartilageMask")
sitkUtils.PushVolumeToSlicer(cartilage, targetNode=cartilageLabelmap)
# 7. Import the cartilage mask into the original segmentation as a new segment
slicer.modules.segmentations.logic().ImportLabelmapToSegmentationNode(cartilageLabelmap, segmentationNode)
segmentationNode.GetSegmentation().GetNthSegment(segmentationNode.GetSegmentation().GetNumberOfSegments() - 1).SetName("Cartilage")
# 8. Optional: Change cartilage color
cartilageSegmentID = segmentationNode.GetSegmentation().GetSegmentIdBySegmentName("Cartilage")
segmentationNode.GetSegmentation().GetSegment(cartilageSegmentID).SetColor(0.0, 1.0, 1.0) # Cyan
Ideally, I am looking for an automated method as I will have to segment out 80 growth plates.
Thanks in advance