@manjula as loassan said running the effect lots of times may cause inaccuracies but if you have to do it because of computer power then you could try this script, it worked ok for me. Once the margin effect has run a few times (amount chosen by you) it will print out the total amount that the segment has grown by.
You will need to make some changes to the code for it to work for you including:
- Set how much you want the segment to grow per iteration (change growSize variable)
- Set how many interations or how many times you want the effect to run (change nOfIterations variable)
- Change the volume getNode line to include the title or MRML ID of the volume you are using for the segmentation.
- Change the segmentation node getNode line to include the title or MRML ID of the segment node you wish to grow.
- Change the getSegment line to the title of the actual segment you wish to grow within that segmentation node.
I have added # comments by the lines which you need to change.
Hopefully this works for you,
growSize = 0.5 # set how much you want to grow the segment per iteration here
nOfIterations = 4 # set how many times you want to run the effect here
volume = getNode('vtkMRMLScalarVolumeNode1') # put the name of the main volume here
# get the segmentation node
segmentationNode = getNode('vtkMRMLSegmentationNode1') # put the name of the segment node here
segmentID = segmentationNode.GetSegmentation().GetSegmentIdBySegmentName('Segment_1') # put the name of the segment here
# setup temporary segment editor widget
segmentEditorWidget = slicer.qMRMLSegmentEditorWidget()
segmentEditorNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentEditorNode")
# set active effect to 'Margin' and set margin size
effect = segmentEditorWidget.activeEffect()
totalGrowth = 0
# run the effect several times using a loop
for i in range(nOfIterations):
totalGrowth += growSize
print('The Segment Has Successfully Grown by ' + str(totalGrowth) + 'mm')
# delete temporary segment editor
segmentEditorWidget = None