pyimagej icon indicating copy to clipboard operation
pyimagej copied to clipboard

Expand directory-based initialization options

Open hinerm opened this issue 3 years ago • 1 comments

Currently if you give imagej.init(...) a directory it assumes it's a Fiji/ImageJ installation and always looks in jars and plugins subdirctories. For completeness it may be useful to provide an option where the user completely configures their own environment.

This would be done through scyjava, adding jars to the classpath explicitly. We may want to add a public _search_for_jars to scyjava.

Most importantly we would need a mechanism to prevent the automatic endpoint and/or classpath modification.. perhaps a populate_classpath flag in the init() method that defaults to True, and if False skips the bulk of init().

hinerm avatar Oct 01 '21 19:10 hinerm

If someone wants complete control, can't they already just use scyjava directly?

import imagej
import scyjava
from scijava.config import add_classpath, find_jars
add_classpath('/path/to/my-library.jar')
add_classpath(*find_jars('/folder/containing/a-bunch-of-jars'))
ij = scyjava.jimport('net.imagej.ImageJ')()

The import imagej is important here, because it sets up the JPype extensions for the net.imagej.ImageJ object, even though imagej.init is not actually used. Without it, the ij will still be functional, but will be missing the ij.py member. It is also needed to add the imglib2-imglyb library and deps to the classpath, which is required for ij.py.from_java to be able to wrap NumPy arrays.

ctrueden avatar Jun 23 '23 17:06 ctrueden