Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4D zarr datasets not loaded correctly in FIJI #44

Open
ptbrown1729 opened this issue May 17, 2022 · 2 comments
Open

4D zarr datasets not loaded correctly in FIJI #44

ptbrown1729 opened this issue May 17, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ptbrown1729
Copy link

I am using FIJI with ImageJ 1.53q. Looking in the installation direction jars subfolder I find n5-ij-3.2.2.jar and n5-zarr-0.0.7.jar

When I use File -> Import -> N5 to load a 4D zarr dataset, the resulting imagej hyperstack that is produced is not correct. This hyperstack has two sliders, "c" and "z". However, the data from the zarr is not put in the correct place. The data from the "c" and "z" dimensions in the zarr are mixed up in the imagej hyperstack.

A minimal example:
I create a zarr using the following python code

import zarr
import numpy as np

# zarr dimensions
nc = 5
nz = 30
nx = 256
ny = 256

# create zarr
fname = "test.zarr"
data = zarr.open(fname, "w")
data.create_dataset("test", shape=(nc, nz, ny, nx),
                    chunks=(1, nz, ny, nx), dtype='float32', compressor="none")

# zarr values are z-slice coordinates
for ii in range(nc):
    for jj in range(nz):
        data.test[ii, jj] = np.ones((ny, nx)) * jj

Next I open it in FIJI with File -> Import -> N5. Now I expect when I scroll through the "c" channel in the hyperstack that I will not see the value of the image change, since the image value only depends on the z-index. But I do see it change. For example, if I keep the z-index at value 1/30 and scroll the c index I see image values of 0, 1, 2, 3, and 4. If I increment the z-index to 2/30 and scoll c I see 5, 6, 7, 8, and 9.

@bogovicj
Copy link
Contributor

bogovicj commented May 18, 2022

@ptbrown1729

Thanks for reporting, I'll address this. Longer term, I'd like to give users control about axis/dimension order. (see issue #45).

For the time being, you can work around it with a macro:

run("Properties...", "channels=1 slices=30 frames=5 pixel_width=1.0000 pixel_height=1.0000 voxel_depth=1.0000");
run("Re-order Hyperstack ...", "channels=[Frames (t)] slices=[Slices (z)] frames=[Channels (c)]");	

Short explanation + caveat:
Since imageJ's dimensions have meaning (XYCZT) and zarr's don't, the current plugin doesn't promise the dimensions will be ordered "correctly" in imageJ unless using a supported metadata format (and there are not many of them); otherwise it makes a guess. In your case, it actually guessed correctly, but in the process messed up the interleaving of slices - causing the problem you observed. and that is a bug. I.e. correct behavior using this version would be for your image to open with 30 channels and 5 slices, but without the interleaving problem.

Note to self: look here.

@bogovicj bogovicj self-assigned this May 18, 2022
@bogovicj bogovicj added the bug Something isn't working label May 18, 2022
@jingxuanlim
Copy link

I believe this is what I'm experiencing with my 4D dataset too. Moving either the c and z sliders change both the c and z values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants