Slicer crashes on exporting segmentation to binary labelmap volume

Hello, attached is a screenshot of the report- I have tried countless things - however not sure why 3d slicer is crashing when I try to export a segmentation to a label map volume.

I was closely following this example by @lassoan - https://gist.github.com/lassoan/5ad51c89521d3cd9c5faf65767506b37

This is the function I am using - ExportVisibleSegmentstoLabelMapNode(…)

If any other info or detail is needed, could do that gladly. Any insight please would be super nice, Thank you!

ExportVisibleSegmentsToLabelmapNode tries to retrieve the list of visible segments from the display node of your segmentation node, but your segmentation does not have a display node. You can create one by calling segmentationNode.CreateDefaultDisplayNodes() or export all segments by using ExportAllSegmentsToLabelmapNode method. I’ll update the code to display a helpful error message instead of crashing.

1 Like

@lassoan Thank you very very much for pointing this out!!! I got it to work after incorporating your feedback. Had spent tons of time trying to fix it, just glad it worked out with this update, otherwise would have done it manually which would have been quite a pain for a lot of CT scans.

I had no idea about this, displayNode function - I believe based on your explanation as to what this function does - fetching the display nodes etc - I now also understand the error that was popping up in the crash report, in the meantime, I was going through this, trying to investigate what could have caused it :stuck_out_tongue:

memory_crash_mac

Once I am done, I will share the whole python 3d slicer code with the hope that it could help someone in the future.

Appreciate the help! :slight_smile: :grinning_face_with_smiling_eyes:

1 Like