morphonets / SNT

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

Installation via pyimagej? #60

Closed cyrilcros closed 3 years ago

cyrilcros commented 3 years ago

Describe the bug I can't seem to be able to install SNT via a Maven endpoint. I see a failed to resolve version for sc.fiji.snt:3.2.14:jar:RELEASE.

To Reproduce

import imagej
ij = imagej.init(['sc.fiji:fiji:2.2.0', 'sc.fiji.snt:3.2.14'])

Expected behavior I get an installed and versioned install of SNT. I am not sure if it possible or not...

Screenshots notebook shell

cyrilcros commented 3 years ago

Well, I just realized that this should be sc.fiji.snt:snt:3.2.14... Will try that.

cyrilcros commented 3 years ago

Ok, so I don't see it in https://maven.scijava.org/content/repositories/releases/sc/fiji/. I am assuming it won't be possible to install it this way. Could you please consider adding it to the Maven repository? I can still install it via the Fiji update CLI, but pyimagej seems easier for tracking versions....

carshadi commented 3 years ago

Hi @cyrilcros , currently it is only possible to initialize pyimagej with a local Fiji installation that is subscribed to the Neuroanatomy update site (at least we have not tested other ways of doing so recently). E.g.,

import imagej
ij = imagej.init("/path/to/your/Fiji.app/", headless=False)

There are detailed instructions on how to set up the jupyter environment with SNT here

cyrilcros commented 3 years ago

Ok, that definitely works. I was just thinking about what would be the best way to install a specific version via CLI. I can do something like cd Fiji.app/ && ./ImageJ-linux64 --update update Neuroanatomy for now. I would just ask you to consider adding it to Maven like it used to be (https://maven.scijava.org/content/repositories/releases/sc/fiji/Simple_Neurite_Tracer/3.1.9/), that's a jar / poml and digests to update per release...

Write up:

carshadi commented 3 years ago

Hey @cyrilcros, try this

import imagej
ij = imagej.init(['sc.fiji:fiji', 'org.morphonets:SNT:3.2.9'], headless=False)

It sort of appears to work, although it will be an old release. I had actually not known this was possible. @tferr thoughts on what it would take to make 4.0.0 available this way?

ctrueden commented 3 years ago

@carshadi The reason 4.0.0 is not available from maven.scijava.org is because this repository is still configured to build with travis-ci.org, but travis-ci.org is no longer operational. We have migrated all the core libraries to GitHub Actions already. I would recommend that this repository be migrated to GitHub Actions as well. I am happy to help do that. If you add me as an admin to the morphonets organization temporarily, I can add the necessary secrets as environment variables, and then you can run github-actionify.sh from the scijava-scripts repository to migrate over.

carshadi commented 3 years ago

That sounds good to me, I think either @tferr or @kephale would need to add you, as they are the org. owners

tferr commented 3 years ago

Added you both as owners. @ctrueden, thanks for looking into it. Coincidently, I was only now looking into it, and noticed that all the other Fiji repos, migrated to GitHub Actions en masse a couple of months. Was about to ping you. If you could migrate us as well, that would be great!

ctrueden commented 3 years ago

@tferr Thanks, I added the secrets and pushed a commit switching to GitHub Actions. It might have issues due to the Jupyter notebooks, though. I won't have time to address the problems (by fixing ci-build.sh in scijava-scripts) until Monday; I hope that's OK. But once we iron that out, we can force-push the 4.0.0 tag so that the CI builds the 4.0.0 release (or simply release 4.0.1—whichever you prefer).

tferr commented 3 years ago

@ctrueden, thanks a lot! Perfectly fine. We could release 4.0.1. Looking at the build log, it seems that the errors are mostly associated with doclint when building javadocs? Turning off doclint would fix it? or is it something that you do not recommend?

ctrueden commented 3 years ago

@tferr Yeah, you could either add <doclint>none</doclint> to your <properties> if you don't care about the quality of the generated javadocs, or else go through and fix all the errors that are actually at error level (rather than warning). The command I typically use to find these easily is mvn javadoc:javadoc | grep error.

cyrilcros commented 3 years ago

Thanks for looking into this and fixing the Maven release! I am closing this issue, I will use the 4.0.1 version as soon as it is out.

tferr commented 3 years ago

Just to mention, that thanks to @ctrueden, 4.0.1 was released, this should now work as expected:

import imagej
ij = imagej.init(['sc.fiji:fiji:2.3.1', 'org.morphonets:SNT:4.0.1'])

Currently, the notebook instructions only mention initialization from a local install, it would be nice to update them to mention this. @cyrilcros, would be great if you could help us update the READMEs.

kephale commented 3 years ago

It is worth double checking that it does work. I have run into a couple of cases where the pyimagej dependency resolution wasn't exactly the same as in a Fiji installation.

cyrilcros commented 3 years ago

I am happy to help, but @ctrueden mentioned some dependency resolutions issues like @kephale noticed https://github.com/fiji/fiji/issues/292#issuecomment-920427578 The relevant issues are https://github.com/imagej/pyimagej/issues/140 and https://github.com/scijava/scyjava/issues/32 I do have some pictures of axons and synapses to score by Wednesday, I will try the pyimagej install for that.

kephale commented 3 years ago

If it is the same one that I mentioned before, then it is resolved in scyjava now

On Mon, Sep 20, 2021, 17:02 Cyril Cros @.***> wrote:

I am happy to help, but @ctrueden https://github.com/ctrueden mentioned some dependency resolutions issues like @kephale https://github.com/kephale noticed fiji/fiji#292 (comment) https://github.com/fiji/fiji/issues/292#issuecomment-920427578 The relevant issues are imagej/pyimagej#140 https://github.com/imagej/pyimagej/issues/140 and scijava/scyjava#32 https://github.com/scijava/scyjava/issues/32

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/morphonets/SNT/issues/60#issuecomment-923009151, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADBV2M4LHIKSDHCXSMFS6DUC5EHDANCNFSM5DMQ7XZA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

cyrilcros commented 3 years ago

So, here is what I see:

ctrueden commented 3 years ago

ij = imagej.init(['sc.fiji:fiji:2.3.1', 'org.morphonets:SNT:4.0.1'])

:point_up: This is the correct invocation. The Maven coordinate for the new SNT is org.morphonets:SNT. I edited @tferr's post above to minimize future confusion.

I tested on my system, and it also works for me (jgo==1.0.2, scyjava==1.2.0, pyimagej==1.0.1).

However, just to shine a light on the remaining dependency resolution issue: this invocation ends up with net.imagej:imagej:2.1.0, not net.imagej:imagej:2.3.0 as it should. And you will probably notice other out-of-date libraries in the mix, too—which might (or might not) cause issues with your workflows due to dependency version skew. @hinerm and I know what's wrong and how to fix it (the solution is to address imagej/pyimagej#140), but the work isn't done yet.

carshadi commented 3 years ago

@cyrilcros on starting the GUI from a notebook, doing this works on my machine

import imagej

ij = imagej.init(['sc.fiji:fiji:2.3.1', 'org.morphonets:SNT:4.0.1'], headless=False)

from scyjava import jimport

SNTUtils = jimport('sc.fiji.snt.SNTUtils')
print("We are running SNT %s" % SNTUtils.VERSION)

SNTService = jimport('sc.fiji.snt.SNTService')

snt = SNTService()
snt.setContext(ij.getContext())

snt.initialize(True) # start UI without image
carshadi commented 3 years ago

I am seeing some strangeness with certain gui commands from the notebook, e.g., Analyze > Color Coding > Color Code Path(s)... It seems to just run the command with whatever the previous input was from your desktop Fiji install, instead of prompting for input with a dialog. I have seen similar behavior in the past with Reconstruction Viewers opened within a notebook.

cyrilcros commented 3 years ago

@carshadi - on my end it's normal the GUI doesn't work, I wasn't super clear I am running in headless mode. I was using Jupyterhub to run an image from https://github.com/jupyter/docker-stacks and I have no X server or display. I use a separate desktop install to annotate axons and save traces...

ctrueden commented 3 years ago

@carshadi wrote:

It seems to just run the command with whatever the previous input was from your desktop Fiji install

Yep, because each time you run a command, the last-used inputs get persisted to the SciJava preferences area, which is shared across all copies of Fiji running on your system. However, it's weird that you don't see a dialog pop up... did you remember to do ij.ui().showUI() before starting to do other stuff in your notebook cells? If not, then there will be no active UI. But in that case, I'm surprised it runs at all, since those inputs—even though they get restored from the last-saved values—don't count as "resolved" and thus shouldn't allow the execution to continue without popping a dialog or (in headless mode) simply failing to run with an error. If you can make an MCVE, I'll look into it.

@carshadi wrote:

SNTService = jimport('sc.fiji.snt.SNTService')

snt = SNTService()
snt.setContext(ij.getContext())

snt.initialize(True) # start UI without image

You should not do it this way, because you will end up with the wrong instance of the SNTService, not the one associated with the main application context. Instead, do this:

SNTService = jimport('sc.fiji.snt.SNTService')
snt = ij.get(SNTService.class_)
carshadi commented 3 years ago

thanks @ctrueden, that seems to have fixed it. updated snippet

import imagej

ij = imagej.init(['sc.fiji:fiji:2.3.1', 'org.morphonets:SNT:4.0.1'], headless=False)
ij.ui().showUI()

from scyjava import jimport

SNTUtils = jimport('sc.fiji.snt.SNTUtils')
print("We are running SNT %s" % SNTUtils.VERSION)

SNTService = jimport('sc.fiji.snt.SNTService')
snt = ij.get(SNTService.class_)

snt.initialize(True) # start UI without image
ctrueden commented 3 years ago

As an aside: the method initialize(boolean) is confusing because the Service interface has a method initialize() with no arguments, which is called when the service is first instantiated and added to the SciJava context. Maybe it's too late now, but I would suggest to name this initialize(boolean) method something else, to avoid confusion with the SciJava application container mechanism.

carshadi commented 3 years ago

that's a good point, maybe snt.startApp()? I'll defer to @tferr on that one

tferr commented 2 years ago

(15 days later :cry: ) these are valid points. @carshadi, agree let's deprecate the initialize(boolean) call, in favor of a startApp() or equivalent. Unfortunately, I don't think we can remove it altogether.

@ctrueden, thanks for the correction. Our maven ID is org.morphonets.snt, but our java packages are defined under sc.fiji.snt, i always find it confusing, and inevitably end up mixing them when using pyimagej.