Volume rendering disappears after placing a markups ROI

Version: Slicer 5.0.3
System: Ubuntu 64-bit

Hi there,
I’m trying to create a markups ROI, place it into the 3d view and turn on the cropping.
Here is the code snippet I execute in the python console:

# Get the Volume node of "MRHead".
volumeNode = slicer.util.getNode("MRHead")

# Get the display node of volume rendering.
vrLogic = slicer.modules.volumerendering.logic()
displayNode = vrLogic.GetFirstVolumeRenderingDisplayNode(volumeNode)

#Create a markups ROI node.
roiNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsROINode")
roiNodeID = roiNode.GetID()

# Fit markups ROI to volume and enable the cropping.

However, as shown below, after I executed the above code, the volume rendering in the ROI box disappeared unexpectedly.
To be precise, after the


is executed, the volume rendering disappears.

However, I also executed the same code snippet on Windows and Mac, the volume rendering didn’t disappear, and everything was ok.

Why does this happen? Is my code correct? What exactly should I do to fix/avoid this on the Ubuntu/Linux version of Slicer?

Any help would be appreciated!

I cannot reproduce this on a linux computer, so most likely the problem is not due to using linux but due to some Slicer or system configuration or driver issue.

Can you reproduce the behavior if you use the application GUI?
Does it occur with all volume rendering settings (CPU, GPU, multi-volume), depth peeling enabled/disabled (in view settings)?
Does the volume rendering reappears if you rotate around the view, hide the ROI, …?
Try to remove your Slicer.ini file (to reset all settings to default) and see if it makes any difference.

Hello @lassoan
Thank you so much for your reply!
Just to make sure, after you executed my code on your Linux computer, the volume rendering didn’t disappear and is still there, right? In fact, the above code was executed on my VMware ubuntu system. Could this be the reason why volume rendering disappeared?

The premise of executing my code and reproducing is selecting ‘MRHead’ in the ‘Sample Data’ module and enabling volume rendering of ‘MRHead’ in the ‘volume rendering’ module.

Here are the results of what I just tried on VMware ubuntu I’m using:
CPU rendering and enabled depth peeling: appears
CPU rendering and disabled depth peeling: appears

GPU rendering and enabled depth peeling: disappears
GPU rendering and disabled depth peeling: reappears

multi-volume rendering and enabled depth peeling: disappears
multi-volume rendering and disabled depth peeling: reappears

Rotate around the view: volume rendering doesn’t reappear.
Hide the ROI: reappear.

All of the above situations are also the same as when using the application GUI (Create a markups ROI in the ‘Markups’ module and drag it to the 3d view.)

However, on Windows or Mac computers(not VMware), volume rendering does not disappear after ROI placement, whether depth peeling is enabled or not and no matter what type of rendering is used.

Because my expectation/goal is to create a new markups ROI in 3d view and enable cropping with GPU volume rendering and depth peeling turned on. Therefore, can this issue be fixed in the Linux version of Slicer?

By the way, how can I find Slicer.ini in ubuntu? I searched for it in the file manager, but there are no results found:

Thank you very much!

It seems to be a problem with the graphics driver (or how it is used) when initializing the Z buffer. Enabling/disabling depth peeling resets the Z buffer.

Does this happen with Slicer-5.0.3? As a workaround, you can disable/enable depth peeling in your script.

See Application settings — 3D Slicer documentation

Yes. The same issue also happens with version 5.0.2 and version 4.11.20210226.

Therefore, Is there any possibility to fundamentally solve this problem?

Thank you so much!

In general, we cannot fix problems that we cannot reproduce. An easy workaround is to enable and disable depth peeling in your script to reset the Z buffer state; or maybe use CPU volume rendering (if that is OK for your use case).

Most likely the issue is in VTK. However, VTK developers - similarly to us - can only work on problems that they can reproduce on their systems.