Preparing Segmentations for MonaiLabel

Hi all,

I have read several posts about the topic of label values and wanted to double check about the best approach.
We have segmentations of shoulder bones but have not ensured label value consistency, so we need to fix this before using MonaiLabel.

I see one option is to export labels using slicerio and this code from @lassoan : How to change the label value of binary labelmap volume? - #9 by lassoan

It looks like the other option is to create a color table as described here

Do I understand correctly that the color table can be used to to assign label values on export (if having an existing scene where I wish to change the label values?) using Slicer: vtkSlicerSegmentationsModuleLogic Class Reference

And the color table can also be used to load existing segmentations into a scene (by selecting it on import) and it will match the segment name to the segment value specified in the table (so if I load a segmentation with a segment called “right scapula”, the color table will be used to assign the correct ID)?

I assume the color table is preferable to the first option since it can then also be used to make new segmentations and assign the correct segment value?

Thank you!

To convert between .seg.nrrd files and labelmap images that use hardcoded label values:

  • In Slicer: you can use a color table when importing/exporting segmentations
  • Outside Slicer: you can use slicerio Python package

Thank you @lassoan for the quick reply.

Is there a difference between using .seg.nrrd or .nrrd for inputs in MonaiLabel? Do they both work?

As far as I can tell seg.nrrd has more info such as colors etc, ie the color table would not need to be loaded again into a new file once I have my updated seg.nrrds with the updated values?

Or will the colormap export for assigning new label values only work with .nrrd and not seg.nrrd?

Thank you,
Eva

MONAILabel can read both .nrrd and .seg.nrrd files, because .seg.nrrd files are just standard .nrrd files with some extra metadata.

Ideally, AI training frameworks should not rely on hardcoded label values but they would get the label value for each segment based on metadata in the .seg.nrrd file. I don’t think MONAILabel currently does this, so you can pre-process your seg.nrrd files using slicerio before using them in MONAILabel.

When you load a plain .nrrd file then you can use a color table to create a segmentation with correct colors and segment names. I’m working on updating color tables in Slicer to allow setting segment terminology as well (terminology codes are more robust and cleaner way to specify segment content than some arbitrary chosen names).