bonej-org / bonej

BoneJ 1.x releases. For up-to-date code see https://github.com/bonej-org/BoneJ2
6 stars 7 forks source link

Fit Ellipsoid reports a "NaN" radius #32

Closed rimadoma closed 6 years ago

rimadoma commented 8 years ago

The Results table shows "Radius 1" as "NaN" when point ROIs are close on the xy-plane.

Steps to reproduce:

  1. Open bundled bone sample (File > Open Samples > Bat Cochlea Volume)
  2. Select slide 3
  3. Select point tool
  4. Draw a point ROI on the white area
  5. Press T to add the point to ROI manager
  6. Select next slide.
  7. Return to step 4 until you have 9 points on 9 consecutive slides (place the points roughly on the same xy-coordinates)
  8. Run Fit Ellipsoid (Plugins > BoneJ > Fit Ellipsoid)
rimadoma commented 6 years ago

This is caused by the fact that the "yuryPetrov" ellipsoid fitting used in BoneJ does not guarantee that the result is an ellipsoid. In fact, it just solves the quadric that best fits the points. It may be any quadric: such as a cone, hyperboloid or a set of parallel planes.

You can determine the type of quadric from the eigenvalues of the quadric, or the the values on the diagonal of the matrix. If a, b, c are all positive, it's an ellipsoid( \frac{ x^{2} }{ a^{2} }  +  \frac{ y^{2} }{ b^{2} }  +  \frac{ z^{2} }{ c^{2} } = 1). Thus after calling the method, you should check if it's an ellipsoid, and display an error if it's not.

rimadoma commented 6 years ago

Also these are not really issues, but it could be worth mentioning in the comments that: 1) eigen vectors may form a left-handed basis. 2) The inverse of the design matrix being solved is most often a pseudoinverse matrix.

mdoube commented 6 years ago

Fixed in https://github.com/mdoube/BoneJ/commit/56b600a8bb630a766b72ffc00020c94cb3e37b8a