Page MenuHomePhabricator

Segmentation interpolation in 2D not working (occasionally crashes)
Closed, ResolvedPublic

Description

Underlying segmentation is attached, contains two slices of kidney in Pic3D.nrrd segmented with 3 slices in between.

  1. Select 2D interpolation and move to middle slice -> confirm for one slice. The resulting segmentation seems completely random, filling other parts of the image (not always the same), occasionally crashes (this is due to an integer variable "numberOfPixels" overflowing, probably because too many pixels are segmented?)
  2. Confirm for all slices works sometimes
  3. The suggested/interpolated segmentation (the yellow outline) looks good, would expect that confirm for either one or all slices just adds this outline to the segmentation, which is not the case

Could be related to T16326

Event Timeline

Fixed by setting ipMITKSegmentationTYPE to mitkIpUInt2_t (which is unsigned short) and ipMITKSegmentationBPE to 16 in both ipSegmentation.h and ipSegmentationP.h.
Additionally we updated deprecated CastToIpPicDescriptor for lower/upperPICSlice with Image Accessors (see http://www.mitk.org/wiki/Image_Accessor_Integration) in mitkShapeBasedInterpolationAlgorithm.cpp
There is still use of CastToImageDescriptor, but ideally the whole process should move to the new standard, i.e. no longer use IpPic (is that the correct name?).

UPDATE: Bugfix leads to errors with region grower, need to adapt RegionGrowingTool

User petersej has pushed new remote branch:

bug-19275-Segmentation-Interpolation-Char-Short-Conversion

mprojectedPointIn2D in mitkRegionGrowingTool.cpp has wrong indices (y in our case), but WorldToIndex transform seems to work. Problem could be in GetAffectedWorkingSlice

The indices are calculated the same if we remove the changes implemented in ipSegmentation.h and ipSegnentationP.h. So that does not seem to be the source of the error. GetAffectedWorkingSlice also delivers the right slice. That was tested by initializing a datanode with the slice and adding it to the datastorage. My suggestion is that the calculations of the contour fail due too the switch from unsigned char to unsigned short somewhere in the ipPic sections of the code.

Removed dependency to 19447 since these two bugs are not related.
The reason is that the shape-based interpolation still uses the ipSegmentation library which is deprecated. The ipSegmentation library has a lot of code that assumes that the pixel type of a segmentation image is unsigned char. But since the migration to the new multilabel segmentation data structure the pixel type is unsigned short.

We should replace the ipSegmentation library with ITK-based code. T15985 is about removing the ipSegmentation code from the 2D interpolation.