# Get the current volume node rendered in the Red Yellow Green view

**URL:** https://discourse.slicer.org/t/get-the-current-volume-node-rendered-in-the-red-yellow-green-view/9190
**Category:** Development
**Tags:** dicom, python, volume
**Created:** [November 18, 2019, 1:08pm UTC](https://discourse.slicer.org/t/get-the-current-volume-node-rendered-in-the-red-yellow-green-view/9190 "2019-11-18T13:08:08Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![CreepyTrick](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@CreepyTrick](https://discourse.slicer.org/u/CreepyTrick)
#### Post date: [November 18, 2019, 1:08pm UTC](https://discourse.slicer.org/t/get-the-current-volume-node-rendered-in-the-red-yellow-green-view/9190/1 "2019-11-18T13:08:08Z")

</div>

Hello

I’m trying to get the current volume rendered in the RYG views (from a Dicom).  
On the screen, i have 2 volume:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/2/e24a8c3fda2e45d6d022feb26ba994341d76fcf0.png)

For now, i already got all the vtkMRMLScalarVolumeNode in a VtkCollection, but i cannot find a way to get witch one is visible on the RYG.  
Since we cannot set visible multiple volumes, i try a basic solution:

```auto
#currentNode is a vtkMRMLScalarVolumeNode
currentNode.GetScalarVolumeDisplayNode().GetDisplayableNode().GetDisplayVisibility()

```

I expected this to return “1” for the volume rendered in the scene, 0 for all others, but it always return 1.

Does anyone have a solution ?

---

<div class="post-metadata">

### Author: ![Amine](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/amine/32/4844_2.png) [@Amine](https://discourse.slicer.org/u/Amine)
#### Post date: [November 18, 2019, 1:25pm UTC](https://discourse.slicer.org/t/get-the-current-volume-node-rendered-in-the-red-yellow-green-view/9190/2 "2019-11-18T13:25:21Z")

</div>

Hi, you can use this to set a volume as background  
`slicer.util.setSliceViewerLayers(background=currentNode)`  
Edit: i misread you want to get the displayed one

---

<div class="post-metadata">

### Author: ![CreepyTrick](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@CreepyTrick](https://discourse.slicer.org/u/CreepyTrick)
#### Post date: [November 18, 2019, 1:41pm UTC](https://discourse.slicer.org/t/get-the-current-volume-node-rendered-in-the-red-yellow-green-view/9190/3 "2019-11-18T13:41:15Z")

</div>

Hi,

This is not what i want  
The result expected is something like (pseudo code)  
`currentNodeRenderedInTheRYGViews = slicer.util.getFocusedVolume()`

or

```auto
for all scalarVolumeNode
  if(node.isDisplayed)
    return node

```

For now i just got the list of all scalarVolumes (red circle on the screen), but only one of them is displayed in these view, the one i want.

“Edit” Yes, that’s it 😉

---

<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: [November 18, 2019, 2:25pm UTC](https://discourse.slicer.org/t/get-the-current-volume-node-rendered-in-the-red-yellow-green-view/9190/4 "2019-11-18T14:25:15Z")

</div>

See this [example in the script repository](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Iterate_over_current_visible_slice_views.2C_and_set_foreground_and_background_images) for how to get/set foreground and background volume node in each slice view (you just need to replace Set…Volume… by Get…Volume…):

```python
layoutManager = slicer.app.layoutManager()
for sliceViewName in layoutManager.sliceViewNames():
    compositeNode = layoutManager.sliceWidget(sliceViewName).sliceLogic().GetSliceCompositeNode()
    volumeNodeID = compositeNode.GetBackgroundVolumeID()
    print(sliceViewName + ": " +volumeNodeID)

```

---

<div class="post-metadata">

### Author: ![CreepyTrick](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@CreepyTrick](https://discourse.slicer.org/u/CreepyTrick)
#### Post date: [November 18, 2019, 2:39pm UTC](https://discourse.slicer.org/t/get-the-current-volume-node-rendered-in-the-red-yellow-green-view/9190/5 "2019-11-18T14:39:58Z")

</div>

That’s totally what i wanted to do !  
I didn’t know that was called “background”, so i dont paid attention to it

Thanks for your help lassoan
