MHD segmentation coloring

Hi,

I have segmented body parts using totalsegmentator from dicom files. I have segmentation files as nii.gz files. I have created mhd files from dicom files without resampling. To explain what I would like to do with an example: Let’s assume I want to use clavicula_right.nii.gz file to recolor the clavicula right bone in the corresponding mhd file. I would like to change the inside of the bone to 3000 HU value and outside of the bone to -1024 . How can I do that? Would you show me the way to do that?

Thanks in advance
Operating system: Ubuntu 22.04
Slicer version: 5.3.0
Expected behavior: Recolor specific region in mhd using nii.gz segmentations
Actual behavior: none

It sounds like you could use the ColorizeVolume module. It creates an rgba volume for you and you can toggle the visibility of individual segments.

https://github.com/Slicer/VTK/pull/43#issuecomment-1752104540

https://github.com/Slicer/VTK/pull/43

https://discourse.slicer.org/t/new-colorize-volume-module/32254

Hi Steve,
thanks a lot for the fast response. I would like to use HU values as coloring, not want to use RGBA values. I will ask the same question in the links you have mentioned. Do you have any suggestion for the HU value change for segmentations?

Thanks in advance

Maybe you can explain what you mean here. It still sounds a lot like ColorizeVolume to me. Maybe you also want to try the Mask effect i the Segment Editor.

I believe the issue may be related to the mask effect. Currently, I’m working with an MHD file alongside its corresponding segmentation file in NII.GZ format. My objective is to preserve the HU values (pixel values) within the MHD file for the regions delineated by the bone segmentation, while setting the values outside of this segmentation to approximate air, which is around -1024 HU for pixels. I’m seeking assistance to accomplish this using the SimpleITK and Python libraries.

Any guidance on this matter would be greatly appreciated. Thank you in advance for your help.

This example shows how to get the coordinates in the CT for all voxels of a given label value.

https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-the-values-of-all-voxels-for-a-label-value

Between this operation and regular numpy array assignments you should have no problem emulating the mask operation. There are other script examples showing how to do these operations.