morphonets / SNT

The ImageJ framework for quantification of neuronal anatomy
https://imagej.net/plugins/snt
GNU General Public License v3.0
42 stars 18 forks source link

Feature request: Tubular geodesics #194

Open fethallah opened 1 year ago

fethallah commented 1 year ago

Is your feature request related to a problem? Please describe. Hi SNT dev team, really great to see this project still alive. Having contributed to the tubular geodesics plugins, I have just tested it to first generate the multi-scale filtered images, with OOF: Optimally Oriented Flux ) and had the error below (see additional context). I would love to get them back to life (could be helpful for a side project). It seems that the plugins are integrated with the latest version of SNT (under Fast Marching), but the multi-scale filtering is an essential step and it's not working.

Did anyone managed to execute these plugins recently ?

Describe the solution you'd like

If installing an older version of ImgeJ/Fiji would work, I'd be happy with it, but I couldn't easily find the release history (and java versions dependencies).

Describe alternatives you've considered

I could make a bit of time to help with a merge request if needed.

Additional context

[ERROR] java.lang.NoSuchMethodException: Could not find method ij3d.Image3DUniverse.getViewingPlatform()Lcom/sun/j3d/utils/universe/ViewingPlatform;
There was a problem with the class ij3d.Image3DUniverse which can be found here:
/home/fethallah/Downloads/fiji-linux64/Fiji.app/plugins/3D_Viewer-4.0.5.jar
java.lang.NoSuchMethodError: ij3d.Image3DUniverse.getViewingPlatform()Lcom/sun/j3d/utils/universe/ViewingPlatform;
    at FijiITKInterface.TubularGeodesics_Plugin.run(TubularGeodesics_Plugin.java:149)
    at ij.IJ.runUserPlugIn(IJ.java:244)
    at ij.IJ.runPlugIn(IJ.java:210)
    at ij.Executer.runCommand(Executer.java:152)
    at ij.Executer.run(Executer.java:70)
    at java.lang.Thread.run(Thread.java:750)

    at FijiITKInterface.TubularGeodesics_Plugin.run(TubularGeodesics_Plugin.java:149)
    at ij.IJ.runUserPlugIn(IJ.java:244)
    at ij.IJ.runPlugIn(IJ.java:210)
    at ij.Executer.runCommand(Executer.java:152)
    at ij.Executer.run(Executer.java:70)
    at java.lang.Thread.run(Thread.java:750)
carshadi commented 1 year ago

Hi @fethallah ,

I was able to get the multiscale filtering to work on Linux (OpenSUSE Tumbleweed) with the latest Fiji 2.14.0.

To reproduce: From SNT File > Load Demo Dataset > Drosophila OP Neuron From Fiji Plugins > MultiScale Oriented Flux Tubularity Measure

Number of Scales: 2
Minimum Scale: 0.33
Maximum Scale: 0.66
Show Gaussian Smooth Images: True

However, when I try to load the saved .oof image as a secondary layer using the "From File...", the auto-tracing mode switches to Fast Marching, as expected, but the secondary layer checkbox does not activate, and attempting to select points for tracing fails without an exception. I can look into why this is failing.

tferr commented 1 year ago

HI @fethallah , It would be great indeed to have tubular geodesics working again. We've tried everything a while back but I must admit we have not tried yet in a while, and we have not really tested it on recent releases.

But I am a bit confused about the error you are getting:

[ERROR] java.lang.NoSuchMethodException: Could not find method ij3d.Image3DUniverse.getViewingPlatform()Lcom/sun/j3d/utils/universe/ViewingPlatform;

My understanding is that all of those com.sun classes are deprecated since java 6, and my understanding is that ijiITKInterface.TubularGeodesics_Plugin. is still uses them and that is problematic on its own. scijava has alternatives for those, so I think it should be possible to just replace

import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;

with

import org.scijava.java3d.utils.universe.*;
import org.scijava.java3d.utils.geometry.*;

@carshadi if you are looking into the GUI failure, perhaps I can look into this refractioning. But @fethallah, how do you feel about Tubular Geodesics being ported into Java? Imglib2 and scijava -- that we use for other filtering -- have gone a long way and I'm wondering if direct porting wouldn't be the easiest at this point., as there are still deprecated dependencies being used by TubularGeodesics_Plugin

fethallah commented 1 year ago

Thank you @tferr and @carshadi for your prompt responses :-)

Why not porting to java. but have no idea how much effort it would take. The core of it was developed in C++, where we branched a few filter from ITK. Some of the (itk) filters are piety simple but not all.

I need to give myself a refresher, and rebuild a diagram of the components. Happy to take a call (ideally mornings CET time).

carshadi commented 1 year ago

I was able to get past the GUI failure in https://github.com/morphonets/SNT/commit/7381363b8bbe9d01a2ba7ad577e1c484ceec1a43 , but there is second point of failure when calling the ITK code:

Got an exception from call to ITK code: java.lang.NoClassDefFoundError: tracing/PathResult
java.lang.NoClassDefFoundError: tracing/PathResult
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
    at java.base/java.lang.Class.getMethodsRecursive(Class.java:3307)
    at java.base/java.lang.Class.getMethod0(Class.java:3293)
    at java.base/java.lang.Class.getMethod(Class.java:2106)
    at sc.fiji.snt.tracing.TubularGeodesicsTracer.run(TubularGeodesicsTracer.java:229)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.ClassNotFoundException: tracing.PathResult
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527)

It appears to reference the old tracing.PathResult class, which was moved to sc.fiji.snt.tracing.PathResult . Changing these references might allow it to run. https://github.com/fethallah/tubularity/blob/a52637c2722fa2bbbfe134c46aedb21521676825/FijiITKInterface/TubularGeodesics.java#L4-L5

I was trying to test it myself but ran into an issue compiling ITK 4.1 . It appears to require gcc < 5, and it is not straightforward to install super old gcc versions on my system, so I gave up. @fethallah do you think ITK >= 5.0 would work? Or would you have the bandwidth to try building it?

On porting to imglib2, that could allow it to run on images much larger than can fit in RAM. It feels like getting the current implementation working again should be fairly quick though.

tferr commented 1 year ago

@carshadi, this is great. I remade PathResult public with 45764a7.

@fethallah, I forked the project here and added minimum tweaks to have it compatible with the current fixes in SNT. I don't know how you guys were managing dependencies at the time (we use maven), but I did not want to make too many changes to your project in case I would break the C++ plus part). Here is what I did:

  1. I manually added the minimum dependencies see /jars folder which are:
    1. 3D_Viewer-4.0.5.jar
    2. ij-1.54f.jar
    3. SNT-4.2.2-45764a7.jar (this is the compiled version of SNT in the fix-tubular-geodesics branch that has the fixes @carshadi mentioned above)
    4. vecmath-1.6.0-scijava-2.jar (this replaces the old java6 calls to java 3D clasees)
  2. Removed outdated code, cleaned imports, and some other changes.

With these changes, I no longer get compilation warnings (Eclipse and Java 11 -- I assume Mark was using Eclipse at the time, so I also committed Eclipse project files in the fork --), but similarly to @carshadi, I was not able to compile the entire thing. Maybe you can give this a go and see if it works for you?

fethallah commented 1 year ago

Hi @tferr and @carshadi , thanks for moving forward .

I just created a draft pull request and added you to the repo.

A few things to consider if we decide to keep the C++ dependencies:

Referring to a previous question, bandwidth is a challenge. But if I understood well, I mainly need to focus on the 2 tasks above.

@tferr and @carshadi , what would be your preferred route ?

  1. rebuilding the static libraries with up-to-date itk.
  2. porting all to java leveraging imglib2. For this one, I can help with more detailed description (+ diagram) of the needed apps
tferr commented 1 year ago

@fethallah, I'd love to have this working 'properly' in Java, but I won't be able to commit to this in the near future. Unless @carshadi, has the bandwidth, I'd propose we try to go the ITK route. If those two items above (FFTW and ITK5) become too involved for you, we could re-assess.

tferr commented 1 year ago

@bogovicj just mentioned that there has been work on IJ/ITK integration here: https://github.com/imagej/imagej-itk @fethallah: if you do have a more detailed description/diagram, we can reach out to folks on the forum, and maybe we can get further insight there