Understanding Ops

Hi,
I’m trying to understand Ops. After watching this video and the previous one given by @ctrueden :

I looked at templates, tutorials, Crop Confocal Series, and I was wondering - how would I know which ops are available? (for example, how would I find the cropping Op that is shown in this tutorial)

Also, how would I know which arguments to pass the Op? I see that @bnorthan used the Op like this:

c0=ops.image().crop(img, Intervals.createMinMax(0, 0, 0,0,xLen-1, yLen-1, 0, zLen-1))

Is there a place in which I can look to see how to use Ops, which arguments to pass them, and how I would understand what Intervals.createMinMax and things like that are?

Thanks,
Avital

1 Like

Hi @Avital_Steinberg,

documentation for ImageJ-Ops is still incomplete, see the FAQ list on the ImageJ Ops wiki page.

  • There is ops.help() which returns a list of Ops and their signatures (i.e. its arguments).

  • @hinerm made a Browse Ops command that’s hopefully being included soon:

1 Like

Hi Avital

As @imagejan mentioned, @hinerm is making progress on some tools to explore ops. If they are ready for people to test you could try those out.

You could look at the ops namespace in the ImageJ javadoc

I saw on another thread that you program in java and imglib. Do you use eclipse??

If not, and if you are making a long term investment in imglib/imagej-ops you might consider it. It is a pretty powerful tool to explore code. @ctrueden often gives useful tutorials on it at the beginning of Hackathons. (if they haven’t allready LOCI should make a video of one of these). Even if I am writing a macro or script in the Fijji editor I usually have a copy of eclipse open with the core imglib and imagej projects loaded.

For example, if I wanted to find info about the crop op using Eclipse, I’d use ctrl+shift+T to open up the type search box. I’d search for crop (you can define a ‘working set’ if you wanted to only explore ops). I’d then take a look at the various crop ops and their parameters. I’d use the F3 to open up parameter types if I needed to know more. (for example what an Interval is)

That may be overly complicated for someone just starting, but learning more about eclipse has been a good long term investment for me. I can explore code reasonably fast now using shortcuts

2 Likes

This command (Plugins > Browse Ops...) is available now in an up-to-date Fiji.

Right now it lets you see each Op available, sorted by namespace, with all implementations available (and thus what parameters can be used to call said Op)

I also started an issue to discuss future directions for this command.

3 Likes

Oh, great, I missed that it’s already available! :smile:

Hi Brian,
I’ve used Eclipse before, but I haven’t used Maven yet. So I guess the complicated part would be to figure out how to set up Eclipse with Maven and which dependencies I need. Would I need the core ImageJ and imgLib2 to use Ops? Or something else?

Thanks,
Avital

There is a fiji help page on maven with Eclipse

Maven should take care of all the dependencies for you, so you can get by with only imagej-ops.

Maven is really easy to use with existing projects. You just type ‘mvn’ on the command line, and it goes through the entire build lifecycle, downloads all the dependencies and builds and tests the project.

I found the Maven in 5 minutes a handy way to learn the basics about the maven build cycle.

1 Like

Thanks a lot for the links and tutorials - I will try it out,

Avital

Thanks a lot, @hinerm and @imagejan ! If I look at an example command from one of the Python tutorials,
it goes like this:

psf=ops.create().kernelGauss([5, 5, 5])

And in the documentation, it goes like this:

Documentation:

(Img output) = net.imagej.ops.create.kernelGauss.CreateKernelGaussSymmetric(
     Type outType?,ImgFactory fac?,int numDimensions,double sigma,double[] calibration?)

or:

(Img output) = net.imagej.ops.create.kernelGauss.CreateKernelGauss(Type outType?,
    ImgFactory fac?,double[] sigma,double[] calibration?)

So what is [5,5,5]? I would guess it’s numDimensions, but it seems as if double sigma is also supposed to be specified.

Thanks,
Avital

You are running ops.create().kernelGauss() with a single parameter, an array: [5, 5, 5]

The correct signature will automatically be used, in this case it is:

(Img output) = net.imagej.ops.create.kernelGauss.CreateKernelGauss(double[] sigma)

since all other parameters of that signature are optional. The array [5, 5, 5] will be treated as an array of doubles ([5.0, 5.0, 5.0]), meaning that sigma = 5.0 for each of the three dimensions.

Thanks, Jan! Now I understand how to read the help. I still have to learn about the new data structures such as: ImgFactory, Img, Interval, etc. in order to understand how to use ops.

Yep, at least until the high-level documentation and tutorials improve. Check out the ImgLib2 resources for more details on those classes.