MorpholibJ region adjacency measure error in Jython script: cannot import name RegionAdjacencyGraph

Hello everyone,

I am trying to exclude labels from measurements which touch each other and for this, I am trying to use the RegionAdjacencyGraph in a jython script. However, I get an error at the import itself which goes:

ImportError: cannot import name RegionAdjacencyGraph

Just to be sure I ran:
from inra.ijpb.measure import IntensityMeasures and this works without any issues.

I do not know what is causing this problem. Both Fiji and the plugin are up-to-date.

1 Like

Hi @gayaJ,

Short answer:

You may need to add:

from inra.ijpb.label import RegionAdjacencyGraph

It will be tough to give more detailed advice without seeing your jython script.
If the above doesn’t solve it, consider posting your script here.

John

2 Likes

Hey!
I should have been more clearer.

I have two imports. from inra.ijpb.measure import RegionAdjacencyGraph and from inra.ijpb.measure import IntensityMeasures. The IntensityMeasures works and the other does not.

The API lists RegionAdjacencyGraph under the class inra.ijpb.measure and not inra.ijpb.label.

1 Like

Got it.

Your import is probably not working because RegionAdjacencyGraph is in inra.ijpb.label not in the package inra.ijpb.measure.

John

2 Likes

Indeed, as @bogovicj says, RegionAdjacencyGraph lives in the inra.ijpb.label package, because it was moved there by @dlegland quite a while ago:

The problem seems to be that the javadoc on https://javadoc.scijava.org/MorphoLibJ/ (which I assume you used, and which redirects to http://ijpb.github.io/MorphoLibJ/javadoc/) is outdated. The latest commit on the gh-pages branch is by @iarganda from 2017:

So, I suggest @dlegland or @iarganda update the javadoc to reflect what is shipped on the update site. I assume the current way hosting the javadoc via the gh-pages branch can also be automatically built using continuous integration (Travis CI), but you might want to adapt it to the way SciJava projects assemble their javadoc, via a separate MorphoLibJ-javadoc GitHub project that inherits all necessary component versions from the current pom-scijava.


Finally, @gayaJ, when you need to find out if a given class is on the class path in Fiji, you can use the Plugins > Utilities > Find Jar For Class command, which would have told you:

The class inra.ijpb.measure.RegionAdjacencyGraph was not found in ImageJ’s class path

However, I have no good idea of finding the correct package name quickly, other than looking at the source code of the current version (or using an IDE such as Eclipse which provides the actual javadoc of your classpath). :worried:

4 Likes

Hi,
sure, we need to update the javadoc! Sorry for the inconvenience.
I am not very sure how we can integrate it, but at least a manual update will clarify some questions.

2 Likes

Hi @imagejan! Thank you so much for the detailed explanation! I was indeed using the Javadoc here https://javadoc.scijava.org/MorphoLibJ/ which has been the source of all this confusion. And thank you for the tip on finding the classpath on FIJI. This should come in handy :smiley:

1 Like

Hi,

The javadoc for MorphoLibJ was updated to correspond to the 1.4.1 version.
http://ijpb.github.io/MorphoLibJ/javadoc/

Information for the RegionAdjacencyGraph can be found here: http://ijpb.github.io/MorphoLibJ/javadoc/inra/ijpb/label/RegionAdjacencyGraph.html

Best,
David

4 Likes

@dlegland thank you for the clarification. An update would indeed be helpful :slight_smile:

1 Like

Hello @dlegland thank you so much for the quick response! :smiley: I checked the pages and now the script also works!
Best,
Gayathri

2 Likes

Hello @imagejan! Thanks for pointing this out. Can you please send us a reference or an example of such a project?