clij / clijpy

GPU-accelerated image processing using CLIJ via pyimagej in python
https://clij.github.io/clijpy
BSD 3-Clause "New" or "Revised" License
10 stars 1 forks source link

dimensions reversing #3

Open guiwitz opened 4 years ago

guiwitz commented 4 years ago

Hi @haesleinhuepf,

when using clijx in Python at some point the array dimensions get reversed either by the ij.py.to_java() function or by the clijx.push function. See for example this notebook. Of course one can swap dimensions manually, but in interest of making this easy to use, it would be nice to be able to use the default dimension ordering. Cheers, Guillaume

haesleinhuepf commented 4 years ago

Hi @guiwitz ,

good point. Thanks for reporting. It's actually the same issue I had with matlab. Thus, a fix is on the way... I keep you posted!

Cheers, Robert

haesleinhuepf commented 4 years ago

Hey @guiwitz ,

I dived a bit into this. IMHO, dimensionality is techincally fine as it is.

I CC @jni - he may confirm or disprove what I'm reasoning:

When loading a 2D image via scikit-image, you get an image with dimensions [height, width]. ImageJ and CLIJ handle images with dimensions [width, height]. You can see that when comparing the dimensions between CLIJ (from withing jupyter) and ImageJ: image

Furthermore, CLIJ operations have named parameters such as sigmaX, sigmaY, sigmaZ (in that order) which should make things clear.

I see that matlab and python handle multi-dimensional matrices in reversed order compared to ImageJ and CLIJ, but I'm not sure how to circumvent confusion. Do you see any easy way of dealing with this?

Thanks for testing and feedback - the project couldn't live without!

Cheers, Robert

jni commented 4 years ago

Ah, the good old plane/row/column vs x/y/z coordinates. I hate this stuff. =P

I think technically @haesleinhuepf you are right that no reversing is happening, but the nomenclature is confusing. ij_image.dimensions does not correspond to numpy_image.shape but to numpy_image.shape[::-1]. But maybe there is a way to make this clearer in the pipeline somehow.

I've thought about this looking at your examples for about 10min so I wouldn't take my interpretation as authoritative, but that's what it seems like to me.