Extracting coordinates of muscle segmented on all slices from MRI scans

Hello,

I have segmented muscles on MRI scans every 10 slices and I would like to find the line of action of a muscle. I have to get the centroid of each area segmented to then draw a line between these points.

I can’t find a module to do that in Slicer.
Is there a module which calculate the centroid of each area segmented ? Or can we extract every outlines coordinates of each area segmented ?

Thank you for your response,

Eva

Check out segment statistics

If you want to get the centerline of the area segmented then you can use Extract Centerline module in VMTK extension. Once you have the centerline you can use Cross-section analysis module to get further information (cross-section areas, resliced images, etc.).

You may also find SegmentGeometry extension useful.

Thank you for your respond.

Unfortunatly, the Extract Centerline module don’t work on the muscle I’m intersting in. The centerline doesn’t follow the muscle line of action at all. I think it’s because this module is adapted to get the centerline of a vessel (which is thin and long) and not on a fat muscle.

Do you have an another solution ?

Centerline extraction with the “Tree” method should work even if the shape is not very elongated:

If you share an example segmentation (upload the .seg.nrrd file somewhere and post the link here) then I can confirm.


Have you tried to use the SegmentGeometry extension? It can give you the coordinates of the centroid points along a reslice axis, which is exactly what you are looking for. The only possible inconvenience is that these centroid positions are reported in voxel coordinate system of the resampled volume, so if you need the centroid positions in RAS coordinate system then you’ll need to multiply voxel coordinates by IJKtoRAS matrix of the resampled volume.

@jmhuie

Thank you very much. SegmentGeometry extension contains exactly what I was searching. Can you precise how I can transform voxel coordinates to RAS coodinates ?

Yuo need to use the ijkToRasTransformMatrix from the cirrent volume

Thank you but the IJKtoRAS matrix is a 3x3 matrix and I have only 2 coordinates in voxel (Cx, Cy). The multiplication between these 2 matrices is not possible. Can you help me with that ?

If you have only two coordinates you should use something like appears on this post

If you have 1 slice only you dhould add a 0 to the third coordinate

IJKtoRAS is a 4x4 homogenous matrix. As @mau_igna_06 said, if you have a single slice then K coordinate (third value) is 0. The last value is 1 if the coordinates specify a position (and 0 if the coordinates specify a direction vector). Note that this is not some Slicer specific thing but standard “homogeneous coordinates” representation and “homogeneous linear transformations”.

1 Like

Thank you for your help.
I understand that I have to use the IJKtoRAS matrix to find the centroid coordinates in RAS coordinates system from IJK coordinates system.
I found a IJKtoRAS matrix in the “Segment” section. Can I use this matrix ?
I also found how to calculate the IJKtoRAS matrix with the origin and the spacing, but I don’t found the same result as the IJKtoRAS matrix in Slicer.
One last thing, the Slicer documentation says “Cx correspond to the resampled and cropped volume exported by SegmentGeometry”. Is that mean that the origin of IJK coordinates system is at then beginning of the segmented muscle and not at the beginning of the MRI image ?