Hello, I am doing an extension with Slicer 14.11 on windows in Python. So, I try to import the segmentation directly with. It gets stuck at the time of import (for the selection everything works) and convertion.
Hi Guillaume,
You have to first import the volume “MRHead” using the “sample data” module and do a segmentation with the segmentation module, before calling slicer.util.getNode functions.
Pierre
GetNodeByID gets a node by node ID, not by node name. Node name is displayed for users and it is not required to be unique. You can get the first node in the scene by the specified name by using GetFirstNodeByName method, but for interactive use in the Python console, I would recommend to use getNode method because it can take either node name or ID as input and throws an exception if the node is not found (instead of just returning None, so that you only find out that you did not get the node when you try to access its methods). This is all described in detail here.
List of input arguments to this helper function has changed a few times over the last 1-2 years, so I don’t know what arguments are needed in the Slicer version that you use. You can runhelp(object.methodname) to display the method’s documentation.
I would recommend to use the latest Slicer Preview Release, because there arrayFromSegmentBinaryLabelmap returns an array that has the same geometry as the first selected master volume, while earlier the array was cropped to the minimum required size, which was a bit more complicated than the use.
“Latest” documentation at the link https://slicer.readthedocs.io/en/latest/ is for the latest Slicer Preview Release. Therefore, all the examples in the script repository page work in the latest Slicer Preview Release. You can find documentation for the current stable release (4.11) at https://slicer.readthedocs.io/en/v4.11/.