I would like to compute (i.e. extract) volume from specific part of the spinal cord based on a binary mask. Here is what I am working with as an input:
And here is a mask based on which I want to compute volume:
My question is, is this possible to do this with SCT or do I need some external tool (if so, which one)?
Thank you for reaching out.
What do you mean by “from specific part of the spinal cord”? Did you mean at specific vertebral levels? Eg: your spinal cord segmentation mask would be divided into smaller chunks, and you would compute the volume of each chunk?
The simplest way to compute the volume from your mask is to do the following:
sct_analyze_lesion -m FILE_SEG -s FILE_SEG
Which gives you something like this:
Volume [mm^3] = 5780.0+/-0.0
(S-I) Length [mm] = -14.77+/-0.0
Equivalent Diameter [mm] = 6.08+/-0.0
Total volume = 5780.0 mm^3
It also outputs an XLS file.
Also see this related thread: Get spinal cord volume
Hi @jcohenadad! Thanks for fast reply!
Well, I think this will work, but to clarify my answer. So, I have 3D T1 image of the brain with portion of the spinal cord. I am able to detect C2-C3 discs on it, but I also label specific portion of the spine myself.
Based on that segmentation, I want to compute volume in the region specified by the segmentation image.
I think that your answer gives me that, just not sure how will this compute voxel volume in the 3D T1 image I am starting with (picture 1 I presented), if I pass segmentation files (-m and -s) for parameters only?
I’m sorry but I don’t understand exactly what you are trying to do. For example, would you like to compute the spinal cord volume at the vertebral level C2? (as opposed to in the whole spinal cord segmentation)
Yes, that’s exactly right.
OK, so the easiest way to do it is via the
sct_process_segmentation function, which computes the CSA across specified slices, and also the length along the spinal cord axis. So the volume is obtained by multiplying the CSA by the length, across the desired section.
For example, this command:
sct_process_segmentation -i t2_seg.nii.gz -vert 2:5 -vertfile t2_seg_labeled.nii.gz -perlevel 1
Produces this output CSV file:
Now to get the volume per vertebral level, you can simply multiply column MEAN(area) by column SUM(length), which gives you this (some columns were removed for clarity):
@jcohenadad thank you so much for your help!