Slice allows round-trip editing and exporting and importing with preserving all the segment names.
I would recommend to save the segmentation file as usual, in a seg.nrrd file, because it contains a regular 3D labelmap that any software can read (if you have overlapping segments, then it will be a 4D volume containing a few non-overlapping 3D volumes) and the segment names, in a single file. You can edit these files and the segment names are preserved, just make sure all the custom fields in the .nrrd file header are preserved.
I agree with you @lassoan but I´m working on a dataset to train Monai so I need the labelmap in nii format to work with. That is the reason fot not to work directly with segmentations (much better for almost everthing…).
I´m trying to mix my own cases with others form VerSe Dataset and I need to export as nii.gz labelmaps but it´s been impossible to me to get labelmaps with segments with the right label…
Labelmaps are not meant to preserve segmentation labels, just the indices. You need to create a color table, and when converting the labelmap to segmentation you need to apply this: this section might be useful:
the associate color table looks like this: First column is the label index, second column is the segment label to be applied, followed by the RGB code (and alpha).
I think i´m not explain properly…
I want to make labelmaps as they are in VerSe Dataset but my labelmaps exported with Slicer are not the same. Verse ones have labels inside because i you import them in Slicer and you send them to an empty Segmentation, segments are correctly labeled (first vertebra is “8” because it is T1, not “1” because it´s the first indice).
I need to add my cases to VerSe Dataset to retrain a Monai Pipeline with them.
It´s strange that Segmentation Module ask you for a ColorTable during export task and labels are not added to the labelmap and output labelmap have no color as @Dolzodmaa_D said.
Thanks @muratmaga for your explain about labelmap import task into a Segmentation.
The example I sent you is the programmatic approach to the same thing.
This may or may not be relevant for you, but we encountered an issue when using a labelmaps with non-contiguous numbers, and not starting from 1. We were training a multilabel model, and the source we used had for training had labelmaps that go from 1-50 (with couple gaps) and then 101-103. Monai didn’t like that so we ended having to reorder the labels in a continuous fashion from 1-50. So if your first label has an index of 8, you may or may not encounter the same issue. FYI.
Many MONAI examples use NIFTI format, but you should be able to use NRRD file format just as well. If you have trouble with that then you can post it as a question and @mention some MONAILabel people.
If some of the data is already in NIFTI format then it may be indeed simpler to add more data to it in the same format.
To make things easier for you, I’ve created a color table for the Verse data set. You can download it from here. Simply load this color table then select it when you load a labelmap volume or export a segmentation.
Thanks a lot @lassoan and @muratmaga for your kind explanations and the Verse ColorTable.
It’s a pity you can’t export slicers segmentations as NIFTI as other software do it because split labels and color in a diferent file is a bit tricky for sharing masks with other users in multilabel AI pipelines.
You can save segmentation in NIFTI file format, exactly for interoperability with other software. The color table ensures consistent label values <-> segment names mapping when importing or exporting NIFTI files.
I´ve been looking for a software to review NIFTI files metadata but I can´t find it. I don´t know what software were used to made VerSe masks and review documentation about.
I think I was in a mistake about labels in labelmaps file. Probably these VerSe masks don´t have labels but they are saved with “altered indexes”. I mean that first segment is not index 1 but has a higher index correlated with the vertebra level. They really don´t save label, they change first index in the labelmap.
Other issue is they have color info for each segment, but this is not critical for me.
Is there any way to save labelmap with this kind of “altered index” o edit indexes in labelmaps?
Yes, exactly. NIFTI files have a very limited and rigid header structure. It cannot store label values, but it entirely relies on external label description files to specify which label value correspond to what segment.
Hi @lassoan ,
Thanks for your export manual… Really clear what to do step by step!
I´ve been talking with @diazandr3s from MonaiLabel and we have reach another approach to the issue.
I´m going to add empty segments at the begining of segmentation till first vertebra has the same index as label. It´s supposed not to be a problem for MonaiLabel to manage empty segments…
I will give you fedback, maybe be intersting for anyone else because can fix many other problems with multilabel pipelines.