Hi everyone,
I am interested in cropping images around each segmentation I have at hand. Naively, I though that the method GetBounds would provide me a bounding box around each segmentation. Here is the snippet I used to get the information.
def getbounds_segmentations(node_string=‘RTSTRUCT’):
segmentationNode = slicer.util.getNode(node_string)
segmentation = segmentationNode.GetSegmentation()
dico_seg = {}
for i in range(segmentation.GetNumberOfSegments()):
bounds = [0]*6
seg_name = segmentation.GetNthSegment(i).GetName()
current_seg = segmentation.GetNthSegment(i)
current_seg.GetBounds(bounds)
dico_seg[seg_name] = bounds
return dico_seg
here is the output dictionnary:
{‘FOIE (% Max=40) - R’: [-178.71093750000003, 88.8671875, 141.59375, 193.3515625, -677.5, -355.5], ‘FOIE (Adaptatif) - R’: [-178.71093750000003, 83.3479995727539, 142.82000732421875, 189.4453125, -675.5, -355.5], ‘FOIE (Black) - R’: [-178.71093750000003, 88.23500061035156, 142.5703125, 192.50799560546875, -675.5, -353.5], ‘FOIE (Fitting) - R’: [-178.71093750000003, 78.45999908447266, 146.4765625, 187.62100219726562, -673.5, -357.5], ‘FOIE (Nestle) - R’: [-178.71093750000003, 82.53299713134766, 145.4669952392578, 188.46875, -675.5, -355.5], ‘Structure 001-os (% Max=40) - R’: [-178.9429931640625, 88.8671875, 141.59375, 193.3515625, -677.5, -355.5], ‘Structure 001-os (Adaptatif) - R’: [-178.73899841308594, 82.03125, 143.546875, 189.4453125, -675.5, -355.5], ‘Structure 001-os (Black) - R’: [-178.9429931640625, 87.890625, 142.5703125, 192.375, -675.5, -353.5], ‘Structure 001-os (Fitting) - R’: [-178.73899841308594, 77.1484375, 146.4765625, 187.4921875, -673.5, -356.40350341796875], ‘Structure 001-os (Nestle) - R’: [-178.9429931640625, 82.03125, 145.5, 188.46875, -675.5, -355.5]}
As you can see, despite the fact that the structures are way apart, the bounding box values are quite the same.
What am I missing here ?
Best regards
Ludovic