I am using Slicer 4.11.0 on a Windows 10 computer and developing a Python scripted module.
I want to call a function from my scripted module that will allow the user to select a 3D region of interest, then once the user selects this region, I want to return to the processing steps in my scripted module and use the voxel coordinates of the user selected region.
Unfortunately, I don’t know the syntax for calling Slicer’s CropVolume module from my scripted module, and I don’t know any other methods in Python for creating a GUI that looks similar to the CropVolume module.
Any help would be greatly appreciated. If I can create a GUI that looks similar to the CropVolume module but takes a 3D numpy array as an input, that would be the preferred method. Otherwise, using CropVolume module would be fine.
Hello,
After looking through these links, I’m aware that you input roi into CropVolume module like this
cropVolumeParameterNode.SetROINodeID(roi.GetID())
But unfortunately I’m still not sure how to allow the user to interactively define roi through a GUI that displays the input volume. Are there any simple examples that go through this?
Or maybe you could tell me which lines of code in the links you already shared do this part?
you can initialize its position based on the geometry of the volume you need to crop. Then once the user is done positioning and adjusting the ROI, they could click a button, and you would call CropVolume logic passing the ROI and input volume. I don’t think you need any additional GUI to do that - ROI visualization and resizing is handled by Slicer, it’s a core widget.
Thanks Andrey! I’ll probably be able to figure out the button part on my own.
Other than that, I now know how to implement everything I need for ROI selection from scripted module.