Hello,
I am developing a scriptedLoadableModules and I am currently facing a small issue. So,
- I’am loading a segmentation and labelmap in which, for the sake of simplicity, I have three segmented regions (IDs: 3, 6 and 48)
- Next, let’s say I select region 48, and click “Remove”. (it will be removed)
- I have the following code, taken from the documentation, to save the current/modified labelmap (so without the region 48):
name = “current_results.nii.gz”
filePath = slicer.app.temporaryPath + ‘/’ + name
localLabelmap = slicer.mrmlScene.AddNewNodeByClass(‘vtkMRMLLabelMapVolumeNode’) slicer.modules.segmentations.logic().ExportAllSegmentsToLabelmapNode(self.segmentationVolumeNode, localLabelmap)
slicer.util.saveNode(localLabelmap, filePath)
- When I load current_results.nii.gz, I see two regions, which is good, but their IDs are 1 and 2. I see the same IDs when I open the image in ITKsnap. So, clearly the IDs are not being saved based on existing ones.
In logs file, I see the following:
[ERROR][VTK] 30.01.2020 00:20:20 [vtkLookupTable (00000255CE57F650)] (D:\D\S\Slicer-4100-build\VTK\Common\Core\vtkLookupTable.cxx:143) - Bad table range: [0, -1]
[ERROR][VTK] 30.01.2020 00:20:20 [vtkMRMLLabelMapVolumeDisplayNode (00000255D3176EE0)] (D:\D\S\Slicer-4100\Libs\MRML\Core\vtkMRMLLabelMapVolumeDisplayNode.cxx:150) - GetOutputImageData: Lookup table exists but empty!
[ERROR][VTK] 30.01.2020 00:20:20 [vtkLookupTable (00000255CE57FB90)] (D:\D\S\Slicer-4100-build\VTK\Common\Core\vtkLookupTable.cxx:143) - Bad table range: [0, -1]
[ERROR][VTK] 30.01.2020 00:20:20 [vtkMRMLLabelMapVolumeDisplayNode (00000255D3176EE0)] (D:\D\S\Slicer-4100\Libs\MRML\Core\vtkMRMLLabelMapVolumeDisplayNode.cxx:150) - GetOutputImageData: Lookup table exists but empty!
[WARNING][VTK] 30.01.2020 00:20:20 (unknown:0) - Generic Warning: In D:\D\S\Slicer-4100\Libs\MRML\Core\vtkDataFileFormatHelper.cxx, line 237
vtkDataFileFormatHelper::GetFileExtensionFromFormatString: please update deprecated extension-only format specifier to ‘File format name (.ext)’ format! Current format string: .nii.gz
I have no clue what those errors mean! I would really appreciate your help in telling me what am I doing wrong. How can I do the export keeping the same IDs as when loading?
Just so you know, I also tried (unsuccessfully) to do the export using this line of code:
slicer.modules.segmentations.logic().ExportVisibleSegmentsToLabelmapNode(self.segmentationVolumeNode, localLabelmap, self.labelmapVolumeNode)