Python: Programmatically set the Dimensions for ROI

Hello,

I am trying to write a script to automate the cropping of volume for quite a few CT scans using Python. Thanks to the previous questions and the documentation, I have been able to figure out pretty much the whole code but one thing is still user-dependent which too I would like to set and function automatically. This is the dimension for the ROI - I have read and gone through the pages for vtkMRMLAnnotationROINode and vtkMRMLCropVolumeParametersNode. As per an earlier post, this should be doable through the Annotation ROI Node but after many hours, can’t figure out. Could someone please provide a code snipped or guide me to the correct function etc. for setting the dimensions, as shown in the picture attached, automatically - for example a tuple (69, 93, 227) ?

Thank you

Screenshot 2021-07-20 at 5.03.51 AM

You can set the Annotation ROI center and radius as shown here. I would recommend to switch to the Markups ROI node, as it is more powerful (e.g., it can represent an ROI with rotated axes) and it will completely replace Annotation ROIs in a year or two.