# Slicer caught an application error

**URL:** <https://discourse.slicer.org/t/slicer-caught-an-application-error/34672>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [March 3, 2024, 3:48am UTC](https://discourse.slicer.org/t/slicer-caught-an-application-error/34672 "2024-03-03T03:48:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [March 3, 2024, 3:48am UTC](https://discourse.slicer.org/t/slicer-caught-an-application-error/34672/1 "2024-03-03T03:48:38Z")

</div>

I am working these two files:

[https://raw.githubusercontent.com/SlicerMorph/SampleData/master/IMPC\_sample\_data.nrrd](https://raw.githubusercontent.com/SlicerMorph/SampleData/master/IMPC_sample_data.nrrd)

and its segmentation

[https://raw.githubusercontent.com/SlicerMorph/MD/main/IMPC\_sample\_data.seg.nrrd](https://raw.githubusercontent.com/SlicerMorph/MD/main/IMPC_sample_data.seg.nrrd)

When I load them both into the scene, switch to Segment editor and create a new segment and try to paint, I am getting this error.

`[Qt] "Slicer has caught an application error, please save your work and restart.\n\nIf you have a repeatable sequence of steps that causes this message, please report the issue following instructions available at https://slicer.org\n\n\nThe message detail is:\n\nException thrown in event: vector"`

After this point paint tool doesnt work anymore. This on a Mac (intel) with 5.6.1 and seems to happen with the preview (Feb 7th) on the same computer. There is nothing else in the log files…

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 3, 2024, 1:18pm UTC](https://discourse.slicer.org/t/slicer-caught-an-application-error/34672/2 "2024-03-03T13:18:19Z")

</div>

This is moet likely because voxel type of the segmentation is float or double. This does not make sense, index values must be stored in integer type for numerical stability and space efficiency. Please check the file and if this is indeed the case then report the issue to the developers of the software that produced thile file.

Still, we cannot prevent unknowing users attempting to load flawed segmentations files, therefore we are adding automatic conversion at segmentation loading:

> <https://github.com/Slicer/Slicer/pull/7605>
>
> Adds the functions ValidateSegmentationImageType and CastToSmallestUnsignedInteg…erType to vtkOrientedImageDataResample.
> \- IsSegmentationScalarTypeValid: Returns True if the scalar type of the image is valid for representing segmentations. False otherwise.
> \- CastToSmallestUnsignedIntegerType: Casts the contents of the image to the smallest unsigned integer type that can contain all values in the image.
> \- ValidateSegmentationImageType: Checks to see if the scalar type of the image is a valid type, and casts the image to the smallest valid type if it is not.
> 
> The function ValidateSegmentationImageType is used during binary labelmap read/import to automatically convert the labelmap.
> If a labelmap representation with an invalid scalar type is added to a segment, we only log a warning and don't automatically convert the labelmap.
> Before performing binary labelmap to closed surface conversion, we check that the scalar type is valid, and log/return an error if it is not.
> 
> This should prevent errors from arising due to the use of floating point images for segmentations.
> 
> Re #6941

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [March 4, 2024, 5:42pm UTC](https://discourse.slicer.org/t/slicer-caught-an-application-error/34672/3 "2024-03-04T17:42:03Z")

</div>

We have generated that segmentation, but I think the issue is segment editor defaults to the data type of the master volume (or at least I though it did), and in this case, these were indeed float volumes (intensity normalized).

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 6, 2024, 12:18pm UTC](https://discourse.slicer.org/t/slicer-caught-an-application-error/34672/4 "2024-03-06T12:18:30Z")

</div>

Slicer should always create integer segmentations, but of course it is possible that we missed something. How did you create the segmentation ‐ using the GUI (using which module, how?) or by Python script (can you send a link to the code)?
