These are chat archives for fiji/fiji

9th
Nov 2016
Hadrien Mary
@hadim
Nov 09 2016 17:56
Hey guys, someone know an easy way to do z stack on a dataset in Python with IJ2 ? Using ops maybe ?
Hadrien Mary
@hadim
Nov 09 2016 18:04
I found this ops.transform().project(imp, ops.stats().max, 1) but IJ2 want the first argument to be out. Do I need to create an empty ImgPlus ? Can't I just get the out as the return object of the ops (the Python way) ?
Hadrien Mary
@hadim
Nov 09 2016 18:16

Got it with that

z_dim = data.dimensionIndex(Axes.Z)
projected_dimensions = [data.dimension(d) for d in range(0, data.numDimensions()) if d != z_dim]
z_projected = ops.create().img(projected_dimensions)
max_op = ops.op(Ops.Stats.Max, data)
ops.transform().project(z_projected, data, max_op, z_dim)
ij.ui().show("z_proj", z_projected)

If you know a quicker way to do it that would be cool (5 lines for a z projection seems pretty long...)

Curtis Rueden
@ctrueden
Nov 09 2016 19:36
@hadim in general using ops.create().something is the way to precreate the needed output image. Yes, we want the framework to do that automatically whenever possible, and have taken care to make many ops work this way. But not all of them do yet.
(This is called "hybrid CF" or computer/function op, BTW.)
It is absolutely vital to have the computer version that works on preallocated output buffers though, so that buffers can be reused.
I'm glad you managed to get it working, at the end.
If you like, file an issue at https://github.com/imagej/imagej-ops/issues asking for a transform.project function, rather than only a computer.
This would shorten your code above considerably.
Hadrien Mary
@hadim
Nov 09 2016 19:44
Thanks for the explanation.