#NEWLINE# @ staticmethod #NEWLINE# def cloneVolume( volumeNode , copyVolumeName , mrmlScene = None , cloneImageData = True , addToScene = True ) : #NEWLINE# #INDENT# ' Clone a scalar node or a labelmap and add it to the scene.\n        If no scene is passed, slicer.mrmlScene will be used.\n        This method was implemented following the same guidelines as in slicer.modules.volumes.logic().CloneVolume(),\n        but it is also valid for labelmap nodes\n        :param volumeNode: original node\n        :param copyVolumeName: desired name of the labelmap (with a suffix if a node with that name already exists in the scene)\n        :param mrmlScene: slicer.mrmlScene by default\n        :param cloneImageData: clone also the vtkImageData node\n        :param addToScene: add the cloned volume to the scene (default: True)\n        :return: cloned volume\n        ' #NEWLINE# scene = ( slicer . mrmlScene if ( mrmlScene is None ) else mrmlScene ) #NEWLINE# displayNode = volumeNode . GetDisplayNode ( ) #NEWLINE# displayNodeCopy = None #NEWLINE# if ( displayNode is not None ) : #NEWLINE# #INDENT# displayNodeCopy = slicer . mrmlScene . CreateNodeByClass ( displayNode . GetClassName ( ) ) #NEWLINE# displayNodeCopy . CopyWithScene ( displayNode ) #NEWLINE# scene . AddNode ( displayNodeCopy ) #NEWLINE# #UNINDENT# clonedVolume = slicer . mrmlScene . CreateNodeByClass ( volumeNode . GetClassName ( ) ) #NEWLINE# clonedVolume . CopyWithScene ( volumeNode ) #NEWLINE# clonedVolume . SetName ( scene ) #NEWLINE# if ( displayNodeCopy is not None ) : #NEWLINE# #INDENT# clonedVolume . SetAndObserveDisplayNodeID ( displayNodeCopy . GetID ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# clonedVolume . SetAndObserveDisplayNodeID ( None ) #NEWLINE# #UNINDENT# if cloneImageData : #NEWLINE# #INDENT# imageData = volumeNode . GetImageData ( ) #NEWLINE# if ( imageData is not None ) : #NEWLINE# #INDENT# clonedImageData = vtk . vtkImageData ( ) #NEWLINE# clonedImageData . DeepCopy ( imageData ) #NEWLINE# clonedVolume . SetAndObserveImageData ( clonedImageData ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# clonedVolume . SetAndObserveImageData ( None ) #NEWLINE# #UNINDENT# #UNINDENT# if addToScene : #NEWLINE# #INDENT# scene . AddNode ( clonedVolume ) #NEWLINE# #UNINDENT# return clonedVolume