soft-matter / trackpy

Python particle tracking toolkit
http://soft-matter.github.io/trackpy
Other
437 stars 131 forks source link

Error in eccentricity calculation #728

Open AlexShkarin opened 1 year ago

AlexShkarin commented 1 year ago

It looks like there's a problem with eccentricity calculations related to the cosine mask produced by the cosmask function. The logic of the calculations and the related normalization code (e.g., in _refine function) assumes that this mask is equal to zero at the center. However, in reality it is equal to one, since np.arctan2 function used by theta_mask simply returns 0 rad when both of its arguments are zero at the center. As a result, the eccentricity values are systematically off, especially for compact features (in the limit of a single-pixel feature it would give an eccentricity of infinity).

One way to solve this issue is to explicitly set the center to zero either in the cosmask definition, or in all the places where it is later used (as far as I can see, 4 different places in the code).