Currently, I am using a ROI to crop the volume rendering in the 3D view : the volume array is not changed, only the rendering.
I would like to have a similar behavior in the 2D views: only see the portion of the image where the ROI is defined without modifying the input volume array (nor creating a new one as it is done in the crop volume widget): something similar to the threshold.
This could be done by adding a step in the pipeline of the ScalarVolumeDisplayNode (/Libs/MRML/Core/vtkMRMLScalarVolumeDisplayNode.cxx), before applying the Threshold (line 97) this->AlphaLogic->SetInputConnection(0, this->Threshold->GetOutputPort() );
This would require some modification in Slicer code. Do you think this could be an interesting feature to add ? Would it be better to add it to AnnotationROI or to MarkupsROI ? or both ?
I’d be reluctant to make that slice rendering pipeline any more complex than it already is. Can you explain why having another volume is a problem? it seems to me that you could have a module that observes the volume and roi nodes and generates a new cropped volume dynamically and then delete it when the operation is over. Such a module could also recenter the views to track the roi as it’s updated. Can you elaborate on why you want to actually crop in the slice views even though the roi is already visible?
We usually use the threshold feature of the slice view pipeline to show only a region of a volume in a slice view:
create a mask volume: labelmap volume, the mask volume is non-zero in the region where you want to show the volume
choose the mask volume as background volume
choose the volume that you want to show using foreground volume
set opacity of the foreground volume to 100%
You can create the mask volume using VolumeClip extension’s “Volume clip with ROI” module. It is a very quick operation (takes a fraction of a second) and it is a short Python script, so you can easily put it into your own modules, if you prefer not to depend on another extension. The only thing is that it still uses the old AnnotationROI, so you would need to update it to use the current Markups ROI node.
In fact, having another volume complexifies a bit our pipeline, but we should be able to deal with it. We would like to crop in the slice views so that the user may only concentrate on the relevant information.
At a first look, using the VolumeClip extension should work. So we will update it with the Markups ROI node and see how it works.
Instead of VolumeClip extension you can also use the Mask Volume effect in Segment Editor. It can be used in combination with the Surface Cut effect, which generates surface from points the same ways as “Volume clip with model” module.
Thanks a lot for your suggestion @lassoan !
Indeed, the Mask Volume effect could be very interesting if we want to use another shape than the standard cubic ROI to mask our volume !