Hi!
I am making an extension where I load three CT images into the separate windows (Green, Red and Yellow). If available, I would also like to load the PET scan as foreground. Loading the three CT images is successful, but adding the PET scan does not work yet. Can someone help?
self.volume0_node = slicer.util.loadVolume(file_path[0]["image"])
self.volume1_node = slicer.util.loadVolume(file_path[1]["image"])
self.volume2_node = slicer.util.loadVolume(file_path[2]["image"])
layoutManager = slicer.app.layoutManager()
sliceWidget0 = layoutManager.sliceWidget('Red')
sliceNode0 = sliceWidget0.mrmlSliceNode()
sliceNode0.SetOrientation('Axial')
compositeNode0 = sliceWidget0.mrmlSliceCompositeNode()
compositeNode0.SetBackgroundVolumeID(self.volume0_node.GetID())
if file_path[0]["PET"]:
self.pet0_node = slicer.util.loadVolume(file_path[0]["PET"])
compositeNode0.SetForegroundVolumeID(self.pet0_node.GetID())
sliceWidget1 = layoutManager.sliceWidget('Green')
sliceNode1 = sliceWidget1.mrmlSliceNode()
sliceNode1.SetOrientation('Axial')
compositeNode1 = sliceWidget1.mrmlSliceCompositeNode()
compositeNode1.SetBackgroundVolumeID(self.volume1_node.GetID())
if file_path[1]["PET"]:
self.pet1_node = slicer.util.loadVolume(file_path[1]["PET"])
compositeNode1.SetForegroundVolumeID(self.pet1_node.GetID())
sliceWidget2 = layoutManager.sliceWidget('Yellow')
sliceNode2 = sliceWidget2.mrmlSliceNode()
sliceNode2.SetOrientation('Axial')
compositeNode2 = sliceWidget2.mrmlSliceCompositeNode()
compositeNode2.SetBackgroundVolumeID(self.volume2_node.GetID())
if file_path[2]["PET"]:
self.pet2_node = slicer.util.loadVolume(file_path[2]["PET"])
compositeNode2.SetForegroundVolumeID(self.pet2_node.GetID())
I have also tried this:
slicer.util.setSliceViewerLayers(background=self.volume2_node, foreground=self.pet2_node)
But then I get the same CT/PET scan for each window.