# Volume rendering disappears after placing a markups ROI

**URL:** <https://discourse.slicer.org/t/volume-rendering-disappears-after-placing-a-markups-roi/25321>\
**Category:** Support\
**Tags:** python, volume-rendering\
**Created:** [September 19, 2022, 2:54am UTC](https://discourse.slicer.org/t/volume-rendering-disappears-after-placing-a-markups-roi/25321 "2022-09-19T02:54:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![CharlesChen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/charleschen/32/8444_2.png) [@CharlesChen](https://discourse.slicer.org/u/CharlesChen)\
**Post date:** [September 19, 2022, 2:54am UTC](https://discourse.slicer.org/t/volume-rendering-disappears-after-placing-a-markups-roi/25321/1 "2022-09-19T02:54:33Z")

</div>

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:

```auto
# 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()
displayNode.SetAndObserveROINodeID(roiNodeID)

# Fit markups ROI to volume and enable the cropping.
vrLogic.FitROIToVolume(displayNode)
displayNode.SetCroppingEnabled(True)

```

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

> vrLogic.FitROIToVolume(displayNode)

is executed, the volume rendering disappears.

 ![ROI 1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/1/f185c91079acb8fe5f6a62a863a4d465295ca349.png)

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!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 19, 2022, 5:05am UTC](https://discourse.slicer.org/t/volume-rendering-disappears-after-placing-a-markups-roi/25321/2 "2022-09-19T05:05:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![CharlesChen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/charleschen/32/8444_2.png) [@CharlesChen](https://discourse.slicer.org/u/CharlesChen)\
**Post date:** [September 19, 2022, 6:45am UTC](https://discourse.slicer.org/t/volume-rendering-disappears-after-placing-a-markups-roi/25321/3 "2022-09-19T06:45:25Z")

</div>

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?

**Note:**  
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:

 ![no result](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/9/89db6dc426a5f2cd8d90321387661c13b39bf15c.png)

Thank you very much!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 19, 2022, 7:34am UTC](https://discourse.slicer.org/t/volume-rendering-disappears-after-placing-a-markups-roi/25321/4 "2022-09-19T07:34:41Z")

</div>

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.

> [@CharlesChen](#):
>
> 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:

See [Application settings — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/user_guide/settings.html#settings-file-location)

---

<div class="post-metadata">

**Author:** ![CharlesChen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/charleschen/32/8444_2.png) [@CharlesChen](https://discourse.slicer.org/u/CharlesChen)\
**Post date:** [September 19, 2022, 6:48pm UTC](https://discourse.slicer.org/t/volume-rendering-disappears-after-placing-a-markups-roi/25321/5 "2022-09-19T18:48:00Z")

</div>

> [@lassoan](#):
>
> Does this happen with Slicer-5.0.3?

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

> [@lassoan](#):
>
> It seems to be a problem with the graphics driver (or how it is used) when initializing the Z buffer.

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

Thank you so much!

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 19, 2022, 7:00pm UTC](https://discourse.slicer.org/t/volume-rendering-disappears-after-placing-a-markups-roi/25321/6 "2022-09-19T19:00:56Z")

</div>

> [@CharlesChen](#):
>
> > [@lassoan](#):
> >
> > It seems to be a problem with the graphics driver (or how it is used) when initializing the Z buffer.
> 
> Therefore, Is there any possibility to fundamentally solve this problem?

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.
