3D element is not filling out the whole cube

Operating system: Windows
Slicer version: 4.10.2
Expected behavior: When I load my Data into 3D-Slicer I expect the object to be in ) the “centre” of the cube.
Actual behavior: Sometimes it happens, that my object is very “far away” in one corner of the cube, in my case in the lower right corner, and i have to zoom a lot to get there. It’s not easy to move the object because it’s not in the centre.

HelpCube

I think you should press the “center the 3D view” button to center the object

Screenshot from 2020-04-14 15-51-20

I already did that. When I press “Center the 3D view” button it appears as I’ve sent it to you.

That means you have something else in the scene. Maybe even just a small point in the opposite corner of the cube.

Just a though on visualizing if there is a very small point/points in the opposite corner,

Segment the object you want, and create a second segment , selecting everything else, even if you do not see anything.

then use the the script repository code,

segmentationNode = getNode(‘Segmentation’)

Compute bounding boxes

import SegmentStatistics
segStatLogic = SegmentStatistics.SegmentStatisticsLogic()
segStatLogic.getParameterNode().SetParameter(“Segmentation”, segmentationNode.GetID())
segStatLogic.getParameterNode().SetParameter(“LabelmapSegmentStatisticsPlugin.obb_origin_ras.enabled”,str(True))
segStatLogic.getParameterNode().SetParameter(“LabelmapSegmentStatisticsPlugin.obb_diameter_mm.enabled”,str(True))
segStatLogic.getParameterNode().SetParameter(“LabelmapSegmentStatisticsPlugin.obb_direction_ras_x.enabled”,str(True))
segStatLogic.getParameterNode().SetParameter(“LabelmapSegmentStatisticsPlugin.obb_direction_ras_y.enabled”,str(True))
segStatLogic.getParameterNode().SetParameter(“LabelmapSegmentStatisticsPlugin.obb_direction_ras_z.enabled”,str(True))
segStatLogic.computeStatistics()
stats = segStatLogic.getStatistics()

Draw ROI for each oriented bounding box

import numpy as np
for segmentId in stats[‘SegmentIDs’]:
# Get bounding box
obb_origin_ras = np.array(stats[segmentId,“LabelmapSegmentStatisticsPlugin.obb_origin_ras”])
obb_diameter_mm = np.array(stats[segmentId,“LabelmapSegmentStatisticsPlugin.obb_diameter_mm”])
obb_direction_ras_x = np.array(stats[segmentId,“LabelmapSegmentStatisticsPlugin.obb_direction_ras_x”])
obb_direction_ras_y = np.array(stats[segmentId,“LabelmapSegmentStatisticsPlugin.obb_direction_ras_y”])
obb_direction_ras_z = np.array(stats[segmentId,“LabelmapSegmentStatisticsPlugin.obb_direction_ras_z”])
# Create ROI
segment = segmentationNode.GetSegmentation().GetSegment(segmentId)
roi=slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLAnnotationROINode”)
roi.SetName(segment.GetName()+’ bounding box’)
roi.SetXYZ(0.0, 0.0, 0.0)
roi.SetRadiusXYZ((0.5obb_diameter_mm))
# Position and orient ROI using a transform
obb_center_ras = obb_origin_ras+0.5*(obb_diameter_mm[0] * obb_direction_ras_x + obb_diameter_mm[1] * obb_direction_ras_y + obb_diameter_mm[2] * obb_direction_ras_z)
boundingBoxToRasTransform = np.row_stack((np.column_stack((obb_direction_ras_x, obb_direction_ras_y, obb_direction_ras_z, obb_center_ras)), (0, 0, 0, 1)))
boundingBoxToRasTransformMatrix = slicer.util.vtkMatrixFromArray(boundingBoxToRasTransform)
transformNode = slicer.mrmlScene.AddNewNodeByClass(‘vtkMRMLTransformNode’)
transformNode.SetAndObserveMatrixTransformToParent(boundingBoxToRasTransformMatrix)
roi.SetAndObserveTransformNodeID(transformNode.GetID())

which will help you in visualizing where the other segment is.

or maybe there are better way of locating it.

1 Like