I have generated a bounding box (cuboid) for the liver in 3d Slicer using the ROI tool. How can I get the coordinates of the cuboid ?
You can use the GetBounds
method of the markups ROI (or the legacy annotation ROI) node:
>>> import numpy as np
>>> bounds = np.zeros(6)
>>> getNode('R').GetBounds(bounds)
>>> bounds
array([-30.14435768, 79.05784416,
-20.47541332, 40.95082569,
-54.60110092, 54.60110092])
The returned values are R min, R max, A min, A max, S min, S max.
2 Likes
Thanks for the answer but sorry to say I’m new to 3d slicer so how can I implement this script along with 3d slicer. Like do I need to import some packages or we can run this code directly on 3d slicer ?
You can run this code as is, in Slicer’s Python console. To get started with Python scripting in Slicer, check out the developer tutorials.
Also one more thing the no. of coordinates should be 8 equal to the number of edges. But here’s it’s 6.
The returned values are R min, R max, A min, A max, S min, S max: 3 axes * 2 bounds = 6.