Copy/move segments programmatically in Python in Segmentations module

Slicer version: 4.11.20210226

Hello,

I’m writing a Python script for moving segments from a segmentation node to another. I looked up the source code and found that the function in C++ is qSlicerSegmentationsModuleWidget::copySegmentBetweenSegmentations(). However, the equivalent function in Python, i.e. slicer.modules.segmentations.widgetRepresentation().CopySegmentBetweenSegmentations() does not exist. Am I missing something?

Module widget methods are not to be called from other modules or scripts. You need to dig one level deeper and call vtkSegmentation::CopySegmentFromSegmentation method from Python.

2 Likes

It works now! Thank you for the quick response!

1 Like