Saving T1-weighted image and segmentation labels as one file

Hi,
I am segmenting muscles in the lower leg to later use these segmented volumes to combine them with DTI fascicle tracts and calculate muscle parameters of fascicles within the muscle volume.

For doing the fascicle tracking I am using DSI studio which uses a T1-weighted image and DTI image to do the tracking. It is difficult choosing the right muscle compartment from only the T1 image. I was now wondering if there is a way to overlay the T1 weighted image and segmentation map and save them together as .nii image so that I could use only this file for the DTI tracking.

Any help or hints would be very much appreciated! Thank you very much in advance!

Kind regards,
Clara

Operating system: Mac OS High Sierra 10.13.3
Slicer version: 4.8.0
Expected behavior: T1 weighted image and label map saved in one file to use for DTI tracking
Actual behavior: Both are separate files. I am able to load the segmentation file into the DTI software (DSI studio) but with only the labels a registration between DTI image and segmentation is not possible.

You can export segments into labelmap volume and then use LabelOverlayImageFilter in Simple Filters module to combine these images. You may also try scale the labelmap volume and then add it to the T1 volume.

There are some limitations in color image support in Simple Filters module, so you need to do the followings:

  • If the input T1 volume is not unsigned char then you need to convert it to unsigned char using Cast scalar volume (if your volume contained values <0 or >255 then before casting to unsigned char, use IntensityWindowingImageFilter in Simple Filters module, to fit a intensity range of your image data in the 0-255 output range)
  • After LabelOverlayImageFilter is completed, the resulting color image will not be displayed correctly in Slicer. You need to save the volume to file and then if you load the file into Slicer (or into DSI studio) then it should appear correctly.

Output of LabelOverlayImageFilter is a color image, so if DSI studio cannot load color images then you may need to combine the T1 and labelmap volumes by simply scaling the labelmap and adding it to the T1 volume.

Upgrade your Slicer to 4.8.1. There were many fixes in the 4.8.1 patch release.

1 Like

Thank you so much Andras for the extensive reply! How would I scale the labelmap and add it to the volume? I tried the LabelOverlayImageFilter you suggested but I get an error, that both images don’t match type or dimension.

Thank you again!

After you saved LabelOverlayImageFilter output to file and loaded it into Slicer, did the image show up correctly? When you tried to load the same file into DSI studio, then did DSI studio report some errors?

It was an error in the LabelOverlayImageFilter. But I realised it was related to the segmentation label and volume not having the same size. I tried it on another segmentation and now it works! Thank you very much!

Is there a way to easily adjust the dimensions of the T1 image and segmentation labels to the same size?

1 Like

By default they have the same size if the T1 image was the first volume that you selected as master volume when you created the segmentation node in Segment Editor module.

You can also resample the segmentation to match any image by selecting that image as ‚ÄúReference volume‚ÄĚ in Segmentations module / Export/import‚Ķ / Advanced section.

1 Like