Error when editing a segmentation

Operating system: MAC OS M2 running Sonoma
Slicer version: 5.6
Expected behavior: painting and drawing will not add on to a segmentation
Actual behavior: Get the following error

Traceback (most recent call last):
File “/Applications/”, line 110, in processInteractionEvents
File “/Applications/”, line 305, in apply
self.scriptedEffect.modifySelectedSegmentByLabelmap(modifierLabelmap, slicer.qSlicerSegmentEditorAbstractEffect.ModificationModeAdd)
RuntimeError: std::logic_error: vector

without knowing the steps leading to the error, we can’t really help you much apart from guessing.

Also I don’t think your slicer version is 5.6, the path shown is for Slicer 5.4

Did you by any change tried to install Slicer 5.6 in the same place as 5.4?

Sorry I have been trying past versions to see if the error is replicable across versions but I get the same error no matter what version. I load a segmentation, and when trying to edit it in the segmentation editor I get this error with paint and draw functions. The erase function works fine on the segmentation.

I would rather not post the segmentations that I’m working with. Ive recently been working with the development functions but can’t see how that can be causing this error especially after trying to download it again.

The best way to get help sorting this out is to post some data and the exact steps that lead to the issue. It doesn’t have to be any particular data, just something you can share publicly that reproduces the issue. Sometimes the process of trying to replicate the issue on other data helps lead to the solution.

Here is some data that replicated the error. I load the segmentation and volume. Try adjust the segmentation with the draw or paint and get the following errors.

[FD] 2023-12-03 08:35:52.482 Slicer[3977:146752] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/ky/44gy8dbj30v74d3bh0zgp35c0000gn/T/org.slicer.slicer.savedState
[Qt] Populating font family aliases took 151 ms. Replace uses of missing font family “.AppleSystemUIFont” with one that exists to avoid this cost.
Traceback (most recent call last):
File “/Applications/”, line 113, in processInteractionEvents
File “/Applications/”, line 307, in apply
self.scriptedEffect.modifySelectedSegmentByLabelmap(modifierLabelmap, slicer.qSlicerSegmentEditorAbstractEffect.ModificationModeAdd)
RuntimeError: std::logic_error: vector

I can replicate your issue with the same error on Mac. It appears to me for some reason conversion from the original labelmap to Slicer’s segmentation is not entirely correct. While the segments are shown, it also has some weird display issues (like it shows only in one of the viewers). I do not have this problem if I create a blank segmentation within Slicer and proceed with segmentation. Where did you create this segmentation? Is there anohter format you can export to?

This data comes from the verse20 dataset in a nifti format. The other data I am working with, that has the same issue, is generated from a machine learning algorithm derived from the verse20 dataset also producing nifti formats segmentations.

I can load them labelmap as fine, and the conversion to segmentation doesn’t report an error. So, I am not sure why the resultant segmentation is not editable and generating the error. Perhaps @pieper or @lassoan can chime.

This feature worked on this data before. Maybe with the update or because I have been working in developer mode, but I have tried turning off the developer mode and reinstalling the program but still keep getting the error.

I see two highly unusual properties of these images:

  • The image is turned inside out (i.e., its axes form a left-handed coordinate system). This is an error, it is not valid NIFTI. This can be fixed by resampling the volume into a right-handed coordinate system by using Crop volume module (using default settings, using the entire volume’s region).
  • Voxel type is float. This is not technically an error, but there should be no reason for a clinical CT to use this type, and using this voxel type for segmentation is even worse (as you need to store discrete label values). You can fix this by converting to Short type using Cast scalar volume module.

Slicer should be able to cope with such images (at least it should display a warning or error when loading them), but we come across with such images so rarely that it is hard to justify investing much time into dealing with them.

I don’t see any errors on Windows (the segmentation is editable without any issue), so it is hard for me to investigate. @muratmaga To narrow down the issue, could you please check if the problem is caused by the first or the second issue? Do you see the issue on linux as well?

Converting the labelmap first to unsigned char and then exporting as segmentation fixed the issue. I didn’t have to make any changes to the original intensity image.

This solution worked. I will modify the algorithm to produce these images correctly.