Threshold scalar volume error

I have a signed distance field that I am thresholding to a label map volume, everything below zero should be identified as the segmentation that I am interested in, however when I do this the returned mask is larger than expected.

Thresholding with below and -0.01 values one can see that the data probe (arrow missing in screenshot) is on the blue edge next to pink region is segmented but the levelset background image is positive. So somehow the region is growing by a layer of voxels?

Is there something I am doing wrong, or is this a bug? the levetset is of type float.

How did you threshold the distance field to a labelmap?
Does the labelmap, the distance map, the segmentation master volume, and the segmentation’s internal binary labelmap representation has the same geometry (origin, spacing, axis directions)?

@kayarre to facilitate investigation it would help if you can provide a sample dataset and sequence of steps to replicate where you see the inconsistency.

@lassoan threshold scalar volume, same origin, spacing and directions)

@pieper: see steps below, also give me a place to upload the image data and I will.

  1. load levelset image (same origin, spacing, and directions as source image. type float)
  2. threshold scalar volume
    • input volume: 1.
    • output volume: set to label map (create new)
    • Type: Below, Threshold Value: -0.01, Outside Value: 1.0
    • Apply
  3. observe weird behavior described above where the label map covers positive values of the levelset

I’ve tested thresholding of a distance map IN Segment Editor and it worked perfectly. Have you tried that?

Could you share a scene where you can reproduce your problem?

@lassoan Yep that works, :man_facepalming:
is the scene the xml file that slicer always is wanting me to save?

Yes, the .mrml file stores the scene (state of all MRML nodes).

@lassoan here is the scene
https://gist.github.com/kayarre/1889a1be1a1b65d5f93548eb3be77381

The scene file does not contain any bulk data (images, etc.). To share a scene with someone, the easiest is to click on the small “giftbox” icon to create a .mrb file that saves the scene file and all data in a single file.

That is fancy!

shared file from googel drive

I’ve tested “Threshold Scalar Volume” module with your data set and it works as intended.

You might have though that thresholding binarizes the image, while it is not. It changes values below/above/outside the specified range and leaves other values unchanged. You see the “band” because you’ve created a labelmap volume for storing the output, which discretizes the output to integer values.

To get a binary volume, you can do it by running thresholding twice (once with “Negate threshold” disabled, then enabled) as shown below. However, you can binarize the image much more easily by using Segment Editor’s Threshold effect or Simple Filter module’s BinaryThresholdImageFilter.

Binarizing an image using Threshold Scalar Volume effect:

Step 1:

Step 2:

That makes a lot more sense. thank you.

1 Like