Switching between different volume display


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?

In general we suggest this method:


For this feature you can look for the PropagateVolumeSelection method.

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()

Here ‘a’ is the Mrml Node ID