I’m looking for python Get and Set methods for the ROI Settings in markups. In the picture below, I am trying to retrieve the current value of the lower bound of the I-S range (-26.52 here) and then set it to 0. All I can find information on is getting and setting Control Point center/radius.
Thanks in advance for any help
I have found out how to retrieve the values (although they are mysteriously slightly off from the GUI values) but I still cannot figure out how to set new ranges.
sz = [0,0,0,0,0,0]
roiNode.GetBounds(sz) #stores the dimensions of my ROI into sz
This documentation seems to imply that even if I load in a markup roi from a file it will need to simply be the center and size rather than specified bounds. There has to be a way to do this, right?
It looks to me like the two ways to control the position and range of a MarkupsROI are the
SetSize() methods. Those don’t provide a convenience method for setting the range on one dimension exactly, but it’s not too hard to do the calculations you would need. You can get the current center (
GetCenter(), and then change the 3rd element to the middle of your new desired I-S range, and get the current size (
GetSize()) and change the 3rd element to your new desired range (or half your new desired range, I can’t tell right off whether the size is like a radius or a diameter…)
Thanks Mike, I was just in the middle of responding with my solution when you commented. The only issue I’m still having is the inaccuracy of the GetBounds() method, see below:
I don’t know if this warrants a bug report, it reduces my precision but I am still getting good results.
I have written 2 functions, getCenterfromBounds() and getSizefromBounds(). I think I need this slightly more involved approach to edit the ROI to account for skewed volumes. To set a new lower bound, it looks like this:
bounds = [0,0,0,0,0,0]
newLower = getNewLowerBound(bounds,bounds)
bounds = newLower
newCenter = getCenterFromBounds(bounds)
newSize = getSizeFromBounds(bounds)
I don’t think there is a bug in the bounds computation. Both
GetBounds() methods return accurate results. The difference is that one returns the extents in the world coordinate system while the other in the markup’s own coordinate system.