bonej-org / BoneJ2

Plugins for bone image analysis
BSD 2-Clause "Simplified" License
20 stars 12 forks source link

Particle Analyser produces negative Enclosed Volume #112

Closed mdoube closed 6 years ago

mdoube commented 6 years ago

Enclosed volume is the volume calculated from the surface mesh.

In BoneJ2 the legacy particle analyser code reports negative enclosed volume. (Fiji with BoneJ installed from the update site)

Steps to reproduce: Open bat cochlea sample image Run Plugins > BoneJ > Analyze > Particle Analyser with the default settings

Perhaps the surface mesh is produced inside out.

This is the code that does the enclosed volume calculation:

private static double[] getSurfaceVolume(
        final Collection<List<Point3f>> surfacePoints)
    {
        return surfacePoints.stream().mapToDouble(p -> {
            if (p == null) {
                return 0;
            }
            final CustomTriangleMesh mesh = new CustomTriangleMesh(p);
            return mesh.getVolume();
        }).toArray();
    }
mdoube commented 6 years ago

I'm a bit concerned that a Math.abs() call, although fixing the immediate problem, does little to address the underlying error in the calculation. It's also strange that this error doesn't occur on ImageJ1, with the 3D viewer and Java 3D 1.5 libraries.

rimadoma commented 6 years ago

I noticed I had left out the Math.abs() call when modifying code that originated from here. Calling CustomTriangleMesh.getVolume() returns the result of this method. It might be worth creating an issue about negative mass in sc.fiji.3D_Viewer.

mdoube commented 6 years ago

Ah, so it is my hack! Touché.

Sent from ProtonMail, encrypted email based in Switzerland.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On 8 August 2018 9:46 PM, Richard Domander notifications@github.com wrote:

I noticed I had left out the Math.abs() call when modifying code that originated from (here)[https://github.com/bonej-org/bonej/blob/master/src/org/doube/bonej/ParticleCounter.java#L958]. Calling CustomTriangleMesh.getVolume() returns the result of this method. It might be worth creating an issue about negative mass in sc.fiji.3D_Viewer.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.