Open xp1632 opened 7 months ago
imagej.init(ij_dir_or_version_or_endpoint=None, mode: Mode| str = Mode.HEADLESS, add_legacy=True, headless=None)
ij_dir_or_version_or_endpoint
: defines the source of ImageJ functions, could be from
Maven
local_installation
net.imagej:imagej
mode
: defines how the environment will behave
HEADLESS
: this is the default mode, to use ImageJ as a libraryGUI
: to start ImageJ2 as a GUI applicationINTERACTIVE
: to start ImageJ2 with GUI support but not displaying GUIadd_legacy
: whether to include support for original ImageJ1 functionality.imagej.ImageJPython
:Dataset
, ImagePlus
, xarray
These functions have some built-in converters:
image.shape
provide shape information of imagedtype
of all types of imageJ or numpy array input are in format of numpy.dtype
dtype
are image data types as: jargs
: Convert Python arguments into a Java Object[]from_java
: convert supported java data, objects into Python equivalents
to_java
converts backwards:
- to specific image type of ImageJ:
RandomAccessibleInterval--> numpy array
:
Run an ImageJ macro by providing the macro code/script in a string and the arguments in a dictionary.
macro = """
#@ String name
#@ int age
output = name + " is " + age " years old."
"""
args = {
"name": "Sean",
"age": 26
}
macro_result = ij.py.run_macro(macro, args)
print(macro_result.getOutput("output"))
run an ImageJ 1.x plugin
ImageJ 1.x plugin by specifying the plugin name as a string, and the plugin arguments as a dictionary.
plugin = "Mean"
args = {
"block_radius_x": 10,
"block_radius_y": 10
}
ij.py.run_plugin(plugin, args)
language = "ijm"
script = """
#@ String name
#@ int age
output = name + " is " + age " years old."
"""
args = {
"name": "Sean",
"age": 26
}
script_result = ij.py.run_script(language, script, args)
print(script_result.getOutput("output"))
add
, squeeze
, transpose
, teccheck_legacy_active
Operating in headless mode - the {class_name} class will not be fully functional.
dims
and shape
methods of get the dimensional axis labels and shape of the imageshape
method to get the shape of the interval ndim
method to get the number of dimensionsdims
to get the axis labels of the dimensional spacedim axes
to get the axes of the dimensional space.The dims
utility functions are for manipulating dimensional axis metadata.
Because the dimension order is different in imageJ's data type and some other data type in python
We need dims.reorganize
and dims.prioritize_rai_axes_order
to change the dimension order as we need
stack_rai_slice
to slice ImageLib2
images in desired slice rangedoctor.checkup
for diagnosing the environment and offer advice for correcting problems
This is a complex case we could test, this code snippet requires:
ij_load_image
ij_dataset->numpy
show_image
As first step, we could consider putting the
show_image
and theprocess_image
into one node