Can the image slices be made semi-transparent in 3D view?

Operating system:
Slicer version:
Expected behavior:
Actual behavior:

Hi, i dont know if it’s possible via the interface
You can paste this code in the python console to set a specific opacity (Red can be changed to Green or Yellow)

opacity = 0.7
Red = getNode("Red Volume Slice")
Red.GetDisplayNode().SetOpacity(opacity)

This following code is supposed to work too as it allows setting slices to visible models in models module and changing the opacity easily but it does make slicer crash when trying to scroll slices (on both 4.10 and 4.11) @lassoan could you please check this out? is this a bug or isn’t it intended to be used? :

Red = getNode("Red Volume Slice")
Red.HideFromEditorsOff()
1 Like

I tried out your suggestion. It partially works. I can see Fiducials behind a semi-transparent slice. However, a surface model and a trajectory path that I have in my scene do not show through.

Any thoughts? Thanks!

1 Like

It’s a curious behavior, if you use that code Before enabling the slice visibility in 3d it works fine, try it with a fresh scene (setting it to 1 then again to a lower value seems to cause the problem)

You might also try depth peeling. Some discussion here.

I still have the same issue. I have a model in my scene created from GreyscaleModelMaker. It does not show through the partially transparent slice.

Textured models (such as slices) are forced to be rendered as opaque if they are shown with opacity = 1.0. There was a slight mistake in the forcing logic that resulted in forced opaque rendering “stuck” after it was once rendered as opaque (this caused the behavior that you had to set opacity before the slice was ever rendered). I have fixed this now (rev28539).

Until a few years ago, VTK did not have a robust way of rendering transparent surfaces, so we had to remove opacity setting option for slice planes and forced the slices to be opaque and rendered last. Now depth peeling in VTK works reasonably well and robustly, so we might consider allowing making slice views transparent. However, there could be rendering issues on some older graphics cards (see bug4253) and point picking may be impacted, too. So, it is probably better to keep it as an experimental feature (can be enabled using Python console only).

2 Likes
Red = getNode("Red Volume Slice")
Red.HideFromEditorsOff()

Using this on the slice nodes works (allows modification from models module) but makes slicer crash as soon as slices are scrolled even in the new nightly

Amine’s observation that the opacity has to be set to a value like 0.7 in advance does work with models as well. I had created the model with GreyscaleModelMaker which automatically displayed the model in 3D View - before I had modified the opacity. Once I ensured that the first thing I did was to set the opacity to a value smaller than, the slice did become translucent as expected.

In latest preview release the order of making the slice transparent and showing it in 3D view should not matter anymore.

Models module should not be used to adjust slice properties. Slice view transparency would be added to the view controller, but for now we will not add GUI as this is not ready for users (would need more testing).

Hi Amine I’ve never used the Python console before and can’t get the CT scan coronal plane (in the red slice) to be transparent. When I paste your code (line Red = getNode(“Red Volume Slice”))
into the console i get:

Screenshot 2022-03-31 213859

“Traceback (most recent call last):
File “”, line 1, in
File “”, line 12, in getNode
MRMLNodeNotFoundException: could not find nodes in the scene by name or id ‘Red Volume Slice’”

I get this error for both the codes you’ve provided.

Is there a solution to this?

Looking up nodes by name is not robust (node names may change). Instead, you can use node IDs or get the list of slice nodes from the layout manager - see examples here.

Thanks so much for your reply.

I have tried that but still unsuccessful:
image

image

Other failed attemps:
image
image

image

I’m quite a beginner so there may be something that I’m missing. Any solution? Thanks so much

I know, it is quite confusing. There are about 10 objects for each slice view for controlling various aspects - see an overview here.

You can change opacity of a slice appearing in 3D views by modifying Opacity value in the slice display node.