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

Path fitting freezes in version v4.0.2 #72

Closed alejoe91 closed 2 years ago

alejoe91 commented 2 years ago

Hi,

First of all thanks for the amazing plugin!

Describe the bug

With version v4.0.2 the Refine->Fit freezes when I try to fit even a single path. I tried on several different machines with different parameters (snapping True/False, Keep original paths True/False, number of threads from 4 to 16).

To Reproduce Steps to reproduce the behavior:

With a z-stack loaded and after reconstructing the entire morphology:

  1. Select one (or multiple) paths
  2. Click on Refine->Fit for one path

Expected behavior We used Refine->Fit on previous versions and it worked smoothly in a few minutes.

Screenshots image

The fitting of a single path has been frozen for over an hour now.

Additional context The z-stack comes from a confocal and deconvolved image.

Fiji details (If possible, please paste here the contents of Plugins>Debug>System Information): fiji_details.txt

carshadi commented 2 years ago

Hi @alejoe91 ,

Thanks for the report.

If you enable Debug mode in the Options tab, does the console indicate that the process is running? It should look similar to this image

Also, that image is quite large - how much memory is used by the program during the fitting, relative to the total memory allocated to the JVM? (can check max memory via Edit > Options > Memory & Threads)

Would also be curious about the number of points in that Path...

alejoe91 commented 2 years ago

Hi @carshadi

Thanks for your reply. Will check the memory consumption first thing tomorrow.

The interesting thing is that I was able to fit all paths in like 10 minutes with 10 threads after downgrading to version 3! Maybe this can be helpful

carshadi commented 2 years ago

I can reproduce this, the process is much faster with version 3.2.14. Something must be off, I'll investigate...

carshadi commented 2 years ago

Hi @alejoe91 ,

I have a fix for this, so there's no need to check memory consumption.

The issue is that there is a significant performance overhead when working with ImageJ2 data structures that are "wrapped" into ImageJ1 format for backwards compatibility (formally, RandomAccessibleInterval -> ImagePlus conversion).

I refactored the fitting code to use the ImageJ2 data structures directly. Unsurprisingly, this makes the process a lot faster than before, so there should be a significant speed boost compared to version 3.X

It will go out in the next release.

alejoe91 commented 2 years ago

Thank you for fixing it @carshadi !!

Sorry for the beginner question (I haven't been using ImajeJ for long), but how can I test the master version of SNT on my end?

carshadi commented 2 years ago

Hey @alejoe91 ,

Right now, the easiest way to keep up with the current state of the repo would be to get the project into an IDE of your choice, see Developing - Locally

A more bare bones approach would be to just clone the repository and install maven, then navigate to the repository directory and run: mvn -Dscijava.app.directory=/path/to/your/Fiji.app -Ddelete.other.versions=true clean install That will build the project (including dependencies) into your local Fiji.appfolder.

Currently, we don't do a nightly build, but maybe that could be worthwhile (@tferr thoughts?)

In any case, I haven't pushed the fitter fix yet, but will try to do so later today after some more testing.

carshadi commented 2 years ago

Hi @alejoe91 ,

I pushed the fix (https://github.com/morphonets/SNT/commit/c1a3ba6f5d8bc3b9395694818241e5ca480682e1) to the branch https://github.com/morphonets/SNT/tree/fitter-imglib2 if you want to test it out.

On my machine, fitting the demo tracing (Drosophila OP neuron) with 49 paths (combined total of 1544 points) now takes ~0.5 seconds, whereas with version 3.2.14 this takes ~17 seconds

alejoe91 commented 2 years ago

Thank you @carshadi Closing the issue!

tferr commented 2 years ago

@carshadi Awesome! On the continuous builds: We do have https://github.com/morphonets/neuroanatomy that should be publishing to the neuroanatomy-unstable update site on every commit to master. But I think it stopped working while back, we would need to look into it. @carshadi, @alejoe91: this could go on the v4.0.3 release, in a week or so.