Get Segmentation layer

Hi all,

In my I create a slider to visualize MIPs of different slab thicknesses on all views:

logics = getSlicesLogics()
nodes = getSlicesNodes()
for sliceNode, sliceLogic in zip(nodes, logics):
    layers = [
    for layer in layers:
        reslice = layer.GetReslice()

How do I get access to the Segmentation layer? There is no sliceLogic.GetSegmentationLayer(). execution happens very early in the application loading process. If something is missing that you would normally find in the command prompt, it usually means that the corresponding library hasn’t been fully loaded yet. Probably the simplest option is to create a scripted module with your functionality. If you still want to use slicerrc, then you can hook up delayed loading with the onStartupCompleted event. See:

For example, you might put the delay loaded code in a separate file, and do something like this in

def load_delayed():
  execfile("/path/to/")"startupCompleted()", load_delayed)

Hi @ihnorton,

Thanks for your answer. I might have not been totally clear. There isn’t anything missing on startup in my case, the slice nodes don’t have a GetSegmentationLayer method even in the Python console. That’s a name I made up in order to explain what I wanted to do.

@cpinter might be able to help, I think he worked on this when the Segmentations framework was included in the core.

Hi Fernando,
Segmentation is a totally different animal than the other layers. As it’s not a volume, it has its own 2D displayable manager. It’s more complicated than the volume one because it can show the labelmap as well as the closed surface. In order to do the same thing for segmentations, we’d need to implement slab mode in vtkMRMLSegmentationDisplayableManager2D and add the same options to vtkMRMLSegmentationDisplayNode.


Ok @cpinter, thanks for the info.