Compressed ImageJ hyperstacks / Python



I am currently trying to create compressed hyperstacks from python (via Christoph Gohlke’s tifffile), but am having issues with ImageJ not flipping through the pages with the expected behavior.

Here is a minimum working example:

import numpy as np
import tifffile.tifffile as tiff # usually used from anaconda

shape = 2, 15, 3, 256, 256, 1
volume = np.random.randint(0, 2**10-1, shape, 'uint16')
tiff.imsave('temp1.tif', volume, compress=6)
tiff.imsave('temp2.tif', volume, imagej=True,
           ijmetadata={'Info':'this is a working test'})
tiff.imsave('temp3.tif', volume, imagej=True, compress=6,
           ijmetadata={'Info':'this test remains stuck on first page in ImageJ'})

The behavior I am seeing when directly opening the files in ImageJ is:

  • temp1.tif is compressed, shows correctly, but doesn’t slice the hyperstack (just loops through pages, as expected);
  • temp2.tif is uncompressed, and slices as expected (three working sliders);
  • temp3.tif is compressed, contains correct data, but the first image remains frozen on ImageJ irrespective of slider position.

I can import temp3.tif as a slice-able hyperstack via Bio-Formats (three working sliders, information is displayed correctly), but am losing ImageJ’s Metadata. Not sure whether I am missing something or this is the expected behavior?

PS: I am using Fiji / 1.52h, and had similar behavior on ImageJ 1.50 (Linux 64-bit)