Classify voxels via a predefined threshold

Hi,

I am a user of 3Dslicer Mac version 5.2.1, with MarkUpsToModel, Sandbox and SegmentEditorExtraEffects extensions.
I used the threshold tool on a paralumbar muscle after obtaining its volume and extraction but it did not succeed.

My goal is to obtain a muscle volume or a muscle area in binary color: black for the pure muscle and white for the fat in the muscle, via a predefined cutoff, like this exemple:

Capture d’écran 2022-12-14 à 10.37.03

This is what I get when using threshold, and it doesn’t work:

No post seems to explain this subject precisely: on 3Dslicer, is it possible to carry out a binary classification of pixels or voxels via a predefined threshold in a gray scale?

Thanks

What have you tried so far? From your picture it seems that you are using the threshold visualization options in the Volume module.

Have you tried using the Segment Editor module? The Threshold editor effect may provide what you need. You can find documentation on the module here: Segment editor — 3D Slicer documentation

Thank you for your help.
Indeed, I tried different threshold tools (SegmentEditor → Local threshold // Volume → threshold // Filtering → threshold scalar volume), but not this one.

Once the threshold is done and saved, how to get a percentage of black voxel and white voxel in a table? Currently, I get this table in Quantification → SegmentStatistics but it doesn’t separate the 2 colors I want to get.

Thanks

After you threshold, there is no black voxel or white voxel. Only the voxels that assigned to that segment, the count of which are given in the table under the Number of Voxels field.

If you use a different threshold and then create a new segment, you can simply divide these two numbers.

What are you trying to calculate?

Thank you for your answer.

I’m trying to classify the pixels/voxels in a total muscle on MRI in a binary way according to an intensity threshold/cutoff, for example:

  • Black = pure muscle, and
  • White = muscle fat (like the first image in my first post).

I would like to do this work on a volume and on a surface.
The final goal would be to get the percentage of black and white pixels/voxels in the volume and the surface.

Within a fixed region, If you set one threshold to define muscle + fat and set it as a segment, then create a second segment and threshold specific to the muscle only, you can do what I said above, which is

(number of voxels in segment1 - number of voxels in segment2) / number of voxels in segment1 *100

which will give you the percentage of fat voxels in the defined area.

But you have to keep the area exactly the same in both segments.

Thank you so much for your reply!

I tried to apply your method but there is an error:
If I explode it in voxels, my volume of interest is 621650 voxels.
With the same thresholding at 75 :

  • If I choose to take the fat (white) in my volume of interest, it makes 188201 voxels.
  • If I choose to take the pure muscle (black) in my volume of interest, it makes 431195 voxels.
  • If I sum the two, I should in theory find the voxels of my total volume, that is 621650 voxels. Now, 188201+431195=619396.
    → Do you know where the lost voxels are?

Moreover, in the table created with the Segment statistics tool, they describe volume (1) (columns B C D), volume (2) (columns E F G), volume (3) (columns N O) cf image. What do the (1) (2) (3) correspond to?

Thanks

Actually I found my mistake do it this way and you will get correct values

  1. Download MRhead sample data
  2. create three empty segments
  3. In the first segment using the paint brush in 3D mode create a spherical region (I used 10%) in the center of the brain
  4. Copy this region to segment_2 and Segment_3 using Logical Operators
  5. Hide segment_1
  6. Switch to Segment_2, go to threshold tool and enter these threshold values 0 - 34.99 and then set the Masking fields to: Editable area to Inside Segment_2 and then modify other segments: Overwrite Visible (your segment_3 should be visible, that important). Then hit apply.
  7. Turn the visibility on for segment_1, go to segment editor and calculate values.

You will see that sum of voxel counts of segment_2 and segment_3 are now identical to the segment_1. This procedure split the original region into two none overlapping segmentations. You can adopt this procedure to your own dataset.

1 Like

Thank you for your reply!

I’m trying with MRhead sample data but it’s not very clear for me : what is “Logical Operators”?

Moreover, in your table, they describe volume (1) (columns B C D), volume (2) (columns E F G), volume (3) (columns N O). What do the (1) (2) (3) correspond to?

Thanks

@AmandineG you can find answers to your questions here:

https://slicer.readthedocs.io/en/latest/user_guide/modules/segmenteditor.html#logical-operators

https://slicer.readthedocs.io/en/latest/user_guide/modules/segmentstatistics.html

Thank you so much for your help and these links!

I was able to apply your threshold method on MRhead and then on my MRI. This technique is really easier, thank you.

Concerning the volumes and the “Segment Statistics” table, I understood that (1) (2) and (3) represent different volumes, but according to you, which volume represents better the reality (i.e. the real volume) between Labelmap statistics, scalar volume statistics or closed surface statistics?
A topic has already been opened concerning this question but there is no answer ( Differences between closed surface volume, labelmap volume and scalar volume ).

Thanks