Op Finder

Revision as of 11:51, 3 May 2016 by Hinerm (talk | contribs)
Op Finder (ImageJ)
Author Mark Hiner
Maintainer Mark Hiner, Ctrueden
File net.imagej:op-finder
Source on GitHub
Initial release April 2016
Latest version April 2016
Development status beta
Category Plugins


The Op Finder is a utility for browsing, learning about and running all available Ops. Because Ops are plugins and can be dynamically extended and specialized for particular inputs, it is not practical to have static documentation on a given Op. By using the Op Finder, you explore the actual list of Ops available in your installation. The purpose of this guide is to familiarize you with the basic capabilities of the Op Finder, to enable you to learn and experiment with Ops.

Getting started

There are two ways to start up the Op Finder:

  1. Using the shortcut: Shift+L
  2. Using the menu path: Plugins › Utilities › Find Ops...

Parts of the Op Finder

LabeledOpFinder.png

Labeled components

  1. Search bar for filtering the list of Ops.
  2. Toggle button to change between a user and developer view.
  3. Play button for running the selected Op.
  4. Copy button to copy the selected cell contents.
  5. Help button to open up the Wiki reference page in your browser.
  6. Status area showing success/failure notifications e.g., for copying or running Ops.
  7. Namespaces and Op types: these can be expanded to explore the tree-based organization of Ops.
  8. Op implementation: the leaves of this tree tell us what parameter options are available for each Op type. We interpret this particular example as "There is an Add Op in the Math namespace, that operates on an image and a numeric value".
  9. Progress area showing progress when performing lengthy operations, such as filtering the Ops.
  10. Details pane toggle. Click this button to show/hide a pane containing additional information about the currently selected Op.

Additional features

  • Hover your mouse over any part of the Op Finder to get a descriptive tool-tip.
  • Double-click any cell to copy its contents to your clipboard.

Views

There is a lot of information surrounding Ops. One goal of the Op Finder is to present this information in a way that can be easily understood. To facilitate this, multiple views are available, tailoring the content of the Op Finder to a particular audience.

For Users



Ops in this view are focused on answering the question "What can I do right now with Ops?" The following guidelines are used to create this list:

  • Only Ops directly involving images are displayed
  • Parameter types are generalized
  • Optional parameters are hidden

For Developers

  • Details pane open by default
  • Precise Op signature
  • Optional parameters are shown
  • Referring class is shown

Things to do

Filtering

TODO fuzzy, no namespaces

Running Ops

TODO how does the play button work?

Code Snippets

TODO take a code snippet and turn it into a script, step-by-step

1. The first thing to do is find an Op of interest. In this case, we start from the User view and see that there is a Convolve Op we want to try:

1-select-op.png

2. In the Script Editor, we need to add a reference to the OpService which will be our entry point for Op usage:

# @OpService ops
Note: this guide is written in Python but any scripting language will work

3. Now we need the code call for our Convolve Op, so we switch to the Developer view. The code is long, but remember we can copy:

2-op-snippet.png
and paste:
# @OpService ops

ops.run("filter.convolve", Img, Img, RandomAccessibleInterval, long[], OutOfBoundsFactory, OutOfBoundsFactory, RealType, ImgFactory)

4. Looking at the Op call, we see that there are a lot of parameters. To get a better idea of what these are, we look at the Op Signature column of the Op Finder:

3-op-signature.png
All of the parameters with a ? are optional. For our purposes, let's just work with the input image, kernel, and returned image:
# @OpService ops

out = ops.run("filter.convolve", Img, RandomAccessibleInterval)

5. Now we need to get inputs for our Op, and ensure the output is displayed. These tasks can all be handled with additional @Parameters to the script:

# @OpService ops
# @Dataset input
# @Dataset kernel
# @OUTPUT ImgPlus out

out = ops.run("filter.convolve", input, kernel)
Note: the types we copied and pasted just represent a minimum requirement. Open images will almost always be Datasets, which themselves have an ImgPlus, which has an Img which is a RandomAccessibleInterval. If you want multiple input images you should use Dataset. A safe alternative for single inputs is ImgPlus. Both of these classes contain additional metadata which can be useful in your script.

6. Our script is done! If we open a base image and kernel in ImageJ we can run our script. The OpService is populated automatically by the ImageJ framework, and an input window is automatically created to select the images:

border"1200px