# 3D element is not filling out the whole cube

**URL:** <https://discourse.slicer.org/t/3d-element-is-not-filling-out-the-whole-cube/11114>\
**Category:** Support\
**Created:** [April 14, 2020, 1:35pm UTC](https://discourse.slicer.org/t/3d-element-is-not-filling-out-the-whole-cube/11114 "2020-04-14T13:35:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zeliair](https://avatars.discourse-cdn.com/v4/letter/z/f6c823/32.png) [@zeliair](https://discourse.slicer.org/u/zeliair)\
**Post date:** [April 14, 2020, 1:35pm UTC](https://discourse.slicer.org/t/3d-element-is-not-filling-out-the-whole-cube/11114/1 "2020-04-14T13:35:17Z")

</div>

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](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/9/f95feb98b8c16fd81d42addc63ed2dedc58a6c50.jpeg)

---

<div class="post-metadata">

**Author:** ![manjula](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/manjula/32/80981_2.png) [@manjula](https://discourse.slicer.org/u/manjula)\
**Post date:** [April 14, 2020, 1:52pm UTC](https://discourse.slicer.org/t/3d-element-is-not-filling-out-the-whole-cube/11114/2 "2020-04-14T13:52:46Z")

</div>

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

![Screenshot from 2020-04-14 15-51-20](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/8/98acc716e08cf8cc7112744c57370819d89e3482.png)

---

<div class="post-metadata">

**Author:** ![zeliair](https://avatars.discourse-cdn.com/v4/letter/z/f6c823/32.png) [@zeliair](https://discourse.slicer.org/u/zeliair)\
**Post date:** [April 14, 2020, 2:07pm UTC](https://discourse.slicer.org/t/3d-element-is-not-filling-out-the-whole-cube/11114/3 "2020-04-14T14:07:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [April 14, 2020, 4:07pm UTC](https://discourse.slicer.org/t/3d-element-is-not-filling-out-the-whole-cube/11114/4 "2020-04-14T16:07:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![manjula](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/manjula/32/80981_2.png) [@manjula](https://discourse.slicer.org/u/manjula)\
**Post date:** [April 14, 2020, 8:51pm UTC](https://discourse.slicer.org/t/3d-element-is-not-filling-out-the-whole-cube/11114/5 "2020-04-14T20:51:50Z")

</div>

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.5_obb\_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.
