Good afternoon,
I have almost finished to do this thanks to your explanation but I have a problem at the last step : to convert my labelmapvolume into a scalarvolumenode…
I have done this :
def CorrectionFinale(self, masterVolumeNode, inputVolCor):
# Etape 1 : creer un labelmap de mon volume final
volumesLogic = slicer.modules.volumes.logic()
vollabel= volumesLogic.CreateAndAddLabelVolume(slicer.mrmlScene, inputVolCor, "labelmapfoie" )
labelmaptocorrect = volumesLogic.CreateLabelVolumeFromVolume(slicer.mrmlScene, vollabel, inputVolCor)
# Etape 2 : Importation du labelmap dans le module segmentation pour creer une segmentation
segmentationNode = slicer.vtkMRMLSegmentationNode()
slicer.mrmlScene.AddNode(segmentationNode)
segmentationNode.CreateDefaultDisplayNodes() # only needed for display
segmentationNode.SetName("CorrectionSegmentationFoie")
segmentationNode.SetReferenceImageGeometryParameterFromVolumeNode(inputVolCor)
segmentationLogic = slicer.modules.segmentations.logic()
importlabelmaptocorrect = segmentationLogic.ImportLabelmapToSegmentationNode (labelmaptocorrect, segmentationNode)
segmentationNode.CreateClosedSurfaceRepresentation()
# Etape 3 : Correction de la segmentation par les effets paint / erase
editorWidget = slicer.modules.segmenteditor.createNewWidgetRepresentation()
editorWidget.setMRMLScene(slicer.app.mrmlScene())
editorWidget.show()
labelmaptocorrect.GetImageData().Modified()
labelmaptocorrect.Modified()
def ExportFinal(self, masterVolumeNode):
# Exporter le labelmap node de la segmentation
seg = slicer.util.getNode(‘CorrectionSegmentationFoie’)
labelmapVolumeNode = slicer.mrmlScene.AddNewNodeByClass(‘vtkMRMLLabelMapVolumeNode’,‘LabelFoiefinal’)
foiesegfin = slicer.modules.segmentations.logic().ExportAllSegmentsToLabelmapNode(seg, labelmapVolumeNode)
a = slicer.util.array('LabelFoiefinal')
volumeNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLScalarVolumeNode',"VolumeFoieSegmente")
foieseg = slicer.util.updateVolumeFromArray(volumeNode, a)
To explain, my first function creates my labelmap from my segmented organ volume, then import this labelmap into the segmentation module and finally do the different corrections thanks to “Segment editor”.
My second function is here to convert my labelmap corrected by Segment Editor into volume : to do that, I use the “export” to labelmap to update this labelmap. Then, I convert into array (a) my last labelmap.
However, to convert from numpy array to vtkMRMLScalarVolumeNode, I don’t succeed…
Maybe I have mixed up the features ?
I have also a little additional question : how can I check the ‘sphere brush’ in my ‘Segment editor’ module and force my “MasterVolume” to be my “labelmapfoie” ?
Thanks a lot for your help !
Laura