# What is the difference of Compactness 1 and compactness 2 in heterogeneity CAD package?

Operating system: Windows
Expected behavior:
Actual behavior:

Hello.
I have a question about the compactness 1 and compactness 2 parameters in the Heterogeneity CAD package for tumor segmentation.
On the website it is explained;

• Compactness 1: A dimensionless measure, independent of scale and orientation. Compactness 1 is defined as the ratio of volume to the (surface area)^(1.5). This is a measure of the compactness of the shape of the image ROI
• Compactness 2: a dimensionless measure, independent of scale and orientation. This is a measure of the compactness of the shape of the image ROI.

So what does compactness 2 really mean?

I’m asking this question because in a study I’m participating, In group A and group B the compactness 1 and compactness 2 showed reverse characters.
(The compactness 1 was larger in group B and compactness 2 was larger in group A, which was weird for me)

Thanks a lot Hi Teresa,

What exactly do you mean by “reverse characters”?

I’m not entirely sure about the precise implementation in HeterogeneityCAD, but I expect it to follow the ommon definition. In that case, Compactness1 and Compactness2 are different formulas expressing the same property (they are also mathematically related. The formulas can be found here for compactness1 and compactness2. These are the definitions of the features as they are implemented in PyRadiomics, which is also available in Slicer through the SlicerRadiomics extension.

N.B. If you want to use this extension, you’d need customization with the parameter file, as Compactness1 and 2 are disabled by default (due to the mathematical correlation to sphericity). If you need any help, please let me know.

Cheers,

Joost

Hi,

documentation and implementation seem to be inconsistent (exponent 3/2 vs. 2/3). The documentation for Compactness 1 states “(surface area)^(1.5)” but the source code around l. 64 shows the following calculations for compactness[1|2]:

def compactness1 (self, surfaceArea, volumeMM3):
return ( (volumeMM3) / ((surfaceArea)**(2/3.0) * math.sqrt(math.pi)) )

def compactness2 (self, surfaceArea, volumeMM3):
return ((36 * math.pi) * ((volumeMM3)**2)/((surfaceArea)**3))

Christina

@crossmanith, Yes, that is due to the fact that the documentation is PyRadiomics’ documentation, not heterogeneityCAD (in PyRadiomics, the Compactness1 function uses the exponent as defined in the documentation).

The reason the implementation is different in PyRadiomics is due to the fact that the reversal of the exponent in Compactness1 is a common (and rather persistent) error. If you use the function as it is defined in HeterogeneityCAD, it will NOT be dimensionless (i.e. the value will be dependent on the volume, not just the relationship between volume and surface area).

Joost

The sphericity and compactness formulas are based on comparisons to a perfect sphere, where the surface area (A) = 4 * pi * r^2 (with r being the radius) and the volume (V) = (4/3) * pi * r^3.

This could be rewritten as r = (A / 4 * pi)^(1/2) and r = (V * pi * (3/4))^(1/3)

So, in case of a perfect sphere, you can write the correlation between A and V as
A = 4 * pi * ( (V * pi * (3/4))^(1/3)) ^2 = (36 * pi * V^2) ^ (1/3)

This correlation (which is independent from the radius (the dimension)!) is reflected in the sphericity and compactness formulas. If you look at the formula for sphericity, this is directly visible, and Compactness 1 and 2 can be mathematically derived from this.
Therefore, they are independent of the radius of the perfect sphere, making them dimensionless…

Joost

I just wanted to make clear that Teresa is calculating something different than what she might guess from the HeterogeneityCAD documentation, which is what she quoted. The author of OpenCAD has been informed.

1 Like