How to Renumber Segment Labels After Deleting Regions in a Label File?


Dear 3D Slicer Community,

I need some assistance with modifying a label file. The file contains five segmented regions, labeled 1, 2, 3, 4, and 5. I would like to delete the segments corresponding to labels 1 and 2, leaving only the regions with labels 3, 4, and 5. However, I want to update the label numbers of the remaining segments, so that the new labels will be 1, 2, and 3, respectively (instead of 3, 4, and 5).

Could you please guide me on how to:

  1. Delete the segments labeled 1 and 2.
  2. Reassign the labels of the remaining segments to 1, 2, and 3.

I would appreciate any help or suggestions on how to perform these actions within 3D Slicer.

Thank you!

If you use a segmentation node instead of a labelmap volume node, I think you can just delete the segments and when you export to labelmap, the label numbers will start at 1. Segment names and IDs do not have an effect on the labelmap labels. Isn’t this so?

Actually I think it is counterproductive using integers as segment names, better use terminologies and automatically generated names from those entries.

Thanks! I’ll try it sometime and see if I can fix it.