Is there a more detailed tutorial for tifffile (specially for writing files with metadata)?

I have an image as numpy array. Let’s create one in python:

data = numpy.random.randn(10,57,128,256).astype('uint8')

It has time series, Z-frames followed by Y and X.
I want to save it as easy to read tiff file for Fiji/imageJ with or without OME-TIFF. For this I am using tifffile

For imageJ format following worked:
tifffile.imwrite('temp_imgJ.tif', data, imagej=True, resolution=(1./5.86, 1./5.86), metadata={'spacing': 0.56, 'unit': 'um', 'axes': 'TZYX'})

But I am unsure about some things:

  1. How to include time interval in metadata? Is it possible?

  2. To use compression I’ll have to go for bigtiff - how to save metadata in that case?

  3. With OME-TIFF I was not even sure of the order. Is it TZCYXS or XYCZT? Then I tried some metadata definitions but have not been successful with that.

*this is my first post here so let me know if I didn’t follow any guidelines.

Thank you,

The ImageJ format is essentially undocumented. I have seen some files using fps:

    'temp_imagej.tif', data, imagej=True, metadata={'axes': 'TZYX', 'fps': 10.0}

The OME metadata model is extensively documented. Try the TimeIncrement pixel attribute:

    'temp.ome.tif', data, metadata={'axes': 'TZYX', 'TimeIncrement': 1/10}

Compression does not require the BigTIFF format. ImageJ hyperstack files are not compatible with BigTIFF format or compression. You can save ImageJ metadata with compressed TIFF. Those files need to be imported via Bio-Formats into ImageJ/Fiji.

Tifffile uses the numpy convention of dimension/axes order and stores the image samples in row-major (C-contiguous) order in the TIFF file. The OME model doesn’t use that convention or storage order. In your example the numpy axes/dimension order is 'TZYX' and tifffile will create an OME-TIFF file with the DimensionOrder="XYCZT" pixel attribute.