# Switching between different volume display

**URL:** <https://discourse.slicer.org/t/switching-between-different-volume-display/24860>\
**Category:** Support\
**Created:** [August 22, 2022, 11:02am UTC](https://discourse.slicer.org/t/switching-between-different-volume-display/24860 "2022-08-22T11:02:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AMK](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@AMK](https://discourse.slicer.org/u/AMK)\
**Post date:** [August 22, 2022, 11:02am UTC](https://discourse.slicer.org/t/switching-between-different-volume-display/24860/1 "2022-08-22T11:02:03Z")

</div>

Hi,

I have imported a Dicom file containing various volumes of pelvic and ankle of different slice thicknesses. The view window always shows the last volume imported. I can switch between different volumes by going to the ‘Data’ Module. But I am trying to implement this functionality in python. Could anyone suggest how should I proceed?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 22, 2022, 3:40pm UTC](https://discourse.slicer.org/t/switching-between-different-volume-display/24860/2 "2022-08-22T15:40:11Z")

</div>

In general we suggest this method:

[https://slicer.readthedocs.io/en/latest/developer\_guide/python\_faq.html#how-to-find-a-python-function-for-any-slicer-features](https://slicer.readthedocs.io/en/latest/developer_guide/python_faq.html#how-to-find-a-python-function-for-any-slicer-features)

For this feature you can look for the `PropagateVolumeSelection` method.

---

<div class="post-metadata">

**Author:** ![AMK](https://avatars.discourse-cdn.com/v4/letter/a/f0a364/32.png) [@AMK](https://discourse.slicer.org/u/AMK)\
**Post date:** [August 24, 2022, 12:32pm UTC](https://discourse.slicer.org/t/switching-between-different-volume-display/24860/3 "2022-08-24T12:32:06Z")

</div>

Thanks Steve for your answer. The link has proven really helpful.

I was able to solve using the following code. Maybe it might be helpful to someone else also.

```
def displaySelectVolume(self, a):
    layoutManager = slicer.app.layoutManager()
    for sliceViewName in layoutManager.sliceViewNames():
        view = layoutManager.sliceWidget(sliceViewName).sliceView()
        sliceNode = view.mrmlSliceNode()
        sliceLogic = slicer.app.applicationLogic().GetSliceLogic(sliceNode)
        compositeNode = sliceLogic.GetSliceCompositeNode()
        compositeNode.SetBackgroundVolumeID(str(a))

```

Here ‘a’ is the Mrml Node ID
