Ops filter gauss gives a wrong output

I have not been using the ops since a while and now I try to use the gauss filter for a XYZCT image. The gaussian filter should only be used for XY. here is a python code snippet. I also attach a strongly downsampled image for testing img_downsampled.tif (108.7 KB)

#@ File (label = "Image file", style = "file") imgfile
#@ DatasetIOService ds
#@ UIService ui
#@ OpService ops

import ij
from ij  import IJ
IJ.run("Close All")
dataset1 = ds.open(imgfile.getAbsolutePath());
results = ops.filter().gauss(dataset1,  [1.0, 1.0, 0.0, 0.0, 0.0]);

The output should be processing in XY in the 2 channel, but I get all images messed up and cut instead.

For instance Channel 2, Z = 14 before processing


after processing


Linked to issue:


The problem seems to be linked with the dimensions of the image. A XYZT is processed correctly. A XYZC image is processed in both channels which makes sense.
When the image is 5D the output is cut away. The expected behavior should be filtering along the XY dimensions for all time points and all channels.

1 Like

Hi @apoliti,

AFAIK the op has no awareness of what the image dimensions are, i.e. it sees a XYCZT as a single 5D space. To get around this you could try creating 2D views of the hyperstack with Views.interval(RAI, long[], long[]), and then pass those individually to to the op. For example:

dataset = ds.open(imgfile.getAbsolutePath());
// Create a view of the XY slice at Z=0, C=0, T=0
xySlice = Views.interval(dataset, new long[]{0, 0, 0, 0, 0}, new long[]{width-1, height-1, 0, 0, 0})
result = ops.filter().gauss(xySlice, kernel)

Best regards,

P.S. Is your image XYZCT or XYCZT? I’ve had display issues in the past with images that don’t follow the canonical order of dimensions XYCZT.

Hello Richard @rimadoma,
thank you for your answer. As a workaround I use hyperSlice or ViewInterval and it works

#@ File (label = "Image file", style = "file") imgfile
#@ Integer (label = "channel DNA") iCh
#@ DatasetIOService ds
#@ UIService ui
#@ OpService ops

import ij.*
import ij.IJ

IJ.run("Close All")
dataset1 = ds.open(imgfile.getAbsolutePath());
ch1 = ops.run("hyperSliceView", dataset1, 2, iCh); // to process only channel iCh
double[] sigmas = [4.0, 4.0, 0.0, 0.0];
gf = ops.filter().gauss(ch1, sigmas);

On the other hand the ops should process a 5D image correctly. If sigma is 0 in all dimensions it should perform no filtering, also it should not cut an image in half when sigma > 0. I don’t think that the behavior I described in my original post is what it should be.




I agree. Thanks for filing the issue, @apoliti!