Calculating Second Moment of Area from Segment

In the SlicerMorph workshop yesterday, @muratmaga and I briefly talked about the steps needed to measure second moment of area from a long bone image stack/volume. Currently I do this using ImageJ with BoneJ, but it’d be nice to do that in 3D Slicer. My current workflow involves segmenting the bone in 3D Slicer, but I end up having to transform and re-slice the bone volumes so that they are aligned with major axes. Then I save the resampled volume move on to BoneJ. This is a bit of a lengthy process and not totally ideal because it leads to a slight reduction in quality when re-slicing the image stacks.

I have been told the segment statistic module can measure second moment of area, but I’m not seeing this option. Am I missing something?

Also as a humble feature request, it would be nice to have the ability to measurement second moment area along the length of a segment similar to how the “Segment cross-section area” module calculates cross sectional area for each slice.

1 Like

Just chiming in to second Jonathan’s request, and to suggest going further to implement other BoneJ functionalities in Slicer. In particular the “Moments of Inertia” plugin and the “Slice Geometry” plugin. Slice Geometry uses the major-axis-aligned bone slices, and the user selects a slice (often midshaft for long bones) for cross-sectional measurements such as cross-sectional area, polar section modulus, min/max feret diameter, etc.

I currently use slicer to segment the bones and mask the bone segment, leaving black pixels outside the bone. I then export each bone as its own .nrrd for cross-sectional analysis in BoneJ. Being able to perform these calculations directly in Slicer for multiple bones in a specimen and export the measurements as a CSV would have an enormous positive impact on my and others’ workflows.

I’d be eager to help if I can!

Segment statistics module can compute principal axes and moments (eigenvectors and eigenvalues of the inertia matrix) using eigensystem decomposition. You need to enable it in the labelmap statistics option:

These metrics are “labelmap statistics”, i.e., it only takes into account the segmentation and does not use voxel values of the selected “Scalar volume”. We could make available central moments, principal moments and principal axes “scalar volume statistics” (that takes density values from the selected scalar volume node), because the implementation is readily available in ITK.

For this, probably the best is to resample the volume along the chosen axis. You could redistribute effect of each voxel to discrete axial positions one by one, but it would probably not be any more accurate but several magnitudes slower than resampling the entire volume first and then process it slice by slice.

Segment cross-section area module is a Python scripted module, so you should be able to modify it to add some more computations. You could also add computation of all the other features to this module, so that you would have everything available in a single module, computing all metrics by a single click (you would then of course rename it accordingly).

Everything that you described very doable. Probably no algorithm development is needed, and you could just start by cloning and modifying “Segment cross-section area” module. It already has plotting and slicing, so you would just need to add more slice-based metric computation, call segment statistics, etc.

Slicer core developers could help with making ITK’s ImageMomentsCalculator conveniently available from Python, but this may not be necessary if you find a good-quality Python package that can compute all the metrics that you need.

1 Like

Thanks for the support @lassoan. I decided to take a stab at adding to the segment cross-sectional area module and I’m glad I did. I’ve been able to implement many of calculations that BoneJ does. It’s not pretty and there’s still a lot I want to fix in terms of the output as well as the UI of the module, but so far so good. Will hopefully get to a point where I can share it soon.

2 Likes