ROI on slice intersection

Hello, I have been trying to create a custom workflow GUI on a Slicelet used for segmentation. part of this workflow is a Crop Volume to select only a precise part of the DICOM I try to segment.

I managed pretty well (considering my base skills) to implement the crop function, but I have 2 small problems that I don’t manage to solve :

  1. Is there a way that when I create my ROI, I set it to be located at the Slice Intersection of the currently selected volume?

image

  1. I have a case where the crop works overhaul but applies a sort of Grey filter on the image, which is a bit weird, any idea why?

Before Crop :
image

After Crop :
image

In my code, the crop parameters are use are these ones :
cropVolumeLogic.CropInterpolated(roi, inputVolume, outputVolume, True, 1.00, 0, 0)

Thanks for the hints if you have some !

For the first, you can set the ROI location to the offsets which you can get from the slice nodes (in psuedocode you get the app’s layoutManager and then iterate through the slice views to get their slide nodes from which you can get the planes which can be used to figure out the intersection.

For the second probably it’s a window/level auto on the cropped volume. So you can copy the source window and level from the display node to the new cropped node’s display node.

Hope that gives you the hints you need.

1 Like

Okay so if I understand well, there is no way I can get the intersection coordinates, or the crossbar coordinates (since that option exists also) through a builtin function? I have to figure out a process to get it, right?

Hmmm okay I think I get it, I’ve got to copy the level parameters from the original window right? Gotta figure out the code for that

Okay, after a few trials :

  • I manage to set the ROI location on the crosshairs location. I have to manually set the crosshair beforehand but that’s already a lot better. I used the following code :

    crosshairNode=slicer.util.getNode(‘Crosshair’)
    pos = crosshairNode.GetCrosshairRAS()
    self.MyROI.SetXYZ(pos)

  • I managed to solve the filtering level by copying the InputVolume in the OutputVolume before doing the crop (previously, OutputVolume was a blank scalar volume node). Simply used the .Copy(inputVolume) method for this one.

Edit : I modified the way I initialize my outputVolume : instead of using .Copy, I use CloneVolume (from Volumes Logic) to be able to have a different name (.Copy creates a volume with the same name which is not optimal to navigate afterwards). Here’s the code :

  volumesLogic = slicer.modules.volumes.logic()
  outputVolume = volumesLogic.CloneVolume(slicer.mrmlScene, inputVolume, 'Cropped Volume' )

Thank you very much !