The shape factors: how to calculate?


#1

Dear Developer:

Recently I want to use this amazing software to calculate the size of cells and mitochondrial. Unfortunetaly, I find the results are quite wired. Thus, I just draw a rectangle (22*122) and a circle (radius = 26) and use the MeasureObjectSizdeShape module.

I have several questions:

  1. For the rectangle, the aspect ratio should be 122/22 = 5.55. But I do not find such value here. Aspect ratio is really important for biology. For example, cell differentiation resulted morphology changes. The AreaShape_MajorAxisLength is 140.61 and AreaShape_MinorAxisLength is 25.40871. Obviously, they are not the width and length. So, how can we get the Aspect ratio?

2.The compactness
How do you define the compactness? Usually compactness c is c=P^2/4πA. P is perimeter and A is area. For the circle, AreaShape_Compactness is 1. That is correct. But for the rectangle, the value is 2.459. But Cellprofiler gives 2.997! That is not right.

3.The Form Factor and Zernike_0_0
Recently, a just-accepted paper published on ACS NANO titled as “Colloidal Gold Nanoparticles Induce Changes in Cellular and Subcellular Morphology” uses Cellprofiler to evaluate the mitochondrial morphology by calculate the Form Factor and Zernike_0_0. That is really wonderful! I also find the these two values in the results. But I dont know how you calculate them (equations or reference?). That is important because if I want to use them, I need to tell others how they are calculated. So, could you please tell me the calculation?

Here are the images and results. Thank you for helping me.(please change the .png to .tif)

test.cpproj (413.6 KB)

obj_test.csv (2.9 KB)


#2

Have you checked the help for the module? I"m just skimming so please forgive me if I’m wrong, but I seem to recall those metrics are for an ellipse that encapsulates the object, not the object itself.


#3

References and definitions of how everything is calculated are in the module help for the MeasureObjectSizeAndShape module; for your convenience I’ll reproduce them below but if you want the embedded links you’ll have to go to the module help to grab them yourself.

I’m not sure how much is the PNG conversion (though I suspect not much, because the Major and Minor axis lengths I’m getting are within ~0.2 pixels of yours), but there’s some blurring of the edges of your shapes that is leading to a) an imperfect segmentation but also b) the objects maybe not being the size you think they are- see here

Overall is here- the circle is closer to “right” than the rectangle but not perfect either.

The imperfect segmentation is going to lead to imperfect measurements.

  1. The ratio of those 2 axis lengths is 5.53, so it’s certainly a reasonable approximation of the 5.55 ideal value you’ve calculated. I’m not certain why the ratio isn’t included in our measurements; possibly due to historical reasons, possibly just because it’s easy to derive from measurements we DO include, etc etc. If you think it’s important to add to our feature space, you’re welcome to contribute an RFC with the proposed changes to the code base.

  2. That’s one measure of compactness but not the only one. The definition of ours is below.

Available measurements
See the Technical Notes below for an explanation of creating an ellipse with the same second-moments as an object region.

Area: The actual number of pixels in the region. 

Perimeter: The total number of pixels around the boundary of each region in the image. 

FormFactor: Calculated as 4*π*Area/Perimeter2. Equals 1 for a perfectly circular object. 

Solidity: The proportion of the pixels in the convex hull that are also in the object, i.e. ObjectArea/ConvexHullArea. Equals 1 for a solid object (i.e., one with no holes or has a concave boundary), or <1 for an object with holes or possessing a convex/irregular boundary. 

Extent: The proportion of the pixels in the bounding box that are also in the region. Computed as the Area divided by the area of the bounding box. 

EulerNumber: The number of objects in the region minus the number of holes in those objects, assuming 8-connectivity. 

Center_X, Center_Y: The x- and y-coordinates of the point farthest away from any object edge. Note that this is not the same as the Location-X and -Y measurements produced by the Identify modules. 

Eccentricity: The eccentricity of the ellipse that has the same second-moments as the region. The eccentricity is the ratio of the distance between the foci of the ellipse and its major axis length. The value is between 0 and 1. (0 and 1 are degenerate cases; an ellipse whose eccentricity is 0 is actually a circle, while an ellipse whose eccentricity is 1 is a line segment.) 


MajorAxisLength: The length (in pixels) of the major axis of the ellipse that has the same normalized second central moments as the region. 

MinorAxisLength: The length (in pixels) of the minor axis of the ellipse that has the same normalized second central moments as the region. 

Orientation: The angle (in degrees ranging from -90 to 90 degrees) between the x-axis and the major axis of the ellipse that has the same second-moments as the region. 

Compactness: The mean squared distance of the object's pixels from the centroid divided by the area. A filled circle will have a compactness of 1, with irregular objects or objects with holes having a value greater than 1. 

MaximumRadius: The maximum distance of any pixel in the object to the closest pixel outside of the object. For skinny objects, this is 1/2 of the maximum width of the object. 

MedianRadius: The median distance of any pixel in the object to the closest pixel outside of the object. 

MeanRadius: The mean distance of any pixel in the object to the closest pixel outside of the object. 

MinFeretDiameter, MaxFeretDiameter: The Feret diameter is the distance between two parallel lines tangent on either side of the object (imagine taking a caliper and measuring the object at various angles). The minimum and maximum Feret diameters are the smallest and largest possible diameters, rotating the calipers along all possible angles. 

Zernike shape features: Measure shape by describing a binary object (or more precisely, a patch with background and an object in the center) in a basis of Zernike polynomials, using the coefficients as features (Boland et al., 1998). Currently, Zernike polynomials from order 0 to order 9 are calculated, giving in total 30 measurements. While there is no limit to the order which can be calculated (and indeed users could add more by adjusting the code), the higher order polynomials carry less information. 
Technical notes
A number of the object measurements are generated by creating an ellipse with the same second-moments as the original object region. This is essentially the best-fitting ellipse for a given object with the same statistical properties. Furthermore, they are not affected by the translation or uniform scaling of a region.
The Zernike features are computed within the minimum enclosing circle of the object, i.e., the circle of the smallest diameter that contains all of the object's pixels.
References

Rocha L, Velho L, Carvalho PCP, "Image moments-based structuring and tracking of objects", Proceedings from XV Brazilian Symposium on Computer Graphics and Image Processing, 2002. (pdf) 

Principles of Digital Image Processing: Core Algorithms (Undergraduate Topics in Computer Science): Section 2.4.3 - Statistical shape properties 

Chrystal P (1885), "On the problem to construct the minimum circle enclosing n given points in a plane", Proceedings of the Edinburgh Mathematical Society, vol 3, p. 30 

#4

Dear bicmino:

Thank you for your reply, especially the compactness, Form Factor and Zernike. It is really helpful!!! Thank you for your patience and profession. Cellprofiler is really amazing and it has already help me published 2 paper with high Impact Factors (>11).

I still have a question about the width and length of the rectangle. I am sorry for so many question.

I noticed that, you said “I’m not sure how much is the PNG conversion (though I suspect not much, because the Major and Minor axis lengths I’m getting are within ~0.2 pixels of yours), but there’s some blurring of the edges of your shapes”. Please changed the “.png” to “.tif” and no blurring will occur. (I dont know why I cannot upload the .tif, so I upload .png)

The image is opened in Photoshop and you can see no blurring, no round corner. The image is exactly 122*22.

You can see the results I measured after “identifyPrimaryObject”,as shown below:

I measure the the length and width. You can see “length” at the right bottom. The measured length is 123.5 and width is 23.6. They are close to my setting values (122*20). My question is, the AreaShape_MajorAxisLength is 140.61 and AreaShape_MinorAxisLength is 25.40871. These values are very much different from the value I measured in the Cellprofiler (especially the length, 123.5 vs 140.61?). How can this happen?

Best
Dingcheng


#5

If you look at the major and minor axis length definitions, you’ll notice they’re based on the ellipse representation of the object; for most cell-like shapes (which of course don’t have corners!) this works fine, but for something like a rectangle the numbers will be not identical to the shape you’ve drawn since the ellipse will be slightly different. You should maybe instead look at the Feret diameters- those should be closer to the values you’re expecting.