Reputation:
I want to save an stack of arrays in a tiff file, so a microscopy software can read it in channels and z planes, as images. So this is a 4 dimensions array: (21,32,1024,1024). But I do not find a way.
For example using: io.imsave(os.path.join(outpath), stack2)
, this is saved as a stack of individual images but not in grups of 32 channels representing the 21 z planes.
do you know any way to achieve that?
Upvotes: 3
Views: 2079
Reputation: 9437
Since the TIFF specification does not handle multi-channel Z stacks, additional metadata needs to be saved with the image data. There are two common metadata formats for saving ZCYX images in TIFF for bio-imaging: OME-TIFF and ImageJ hyperstacks. OME-TIFF is supported by more software. Tifffile can read and write both formats:
import numpy
from tifffile import imwrite
image = numpy.zeros((21, 32, 1024, 1024), dtype='uint16')
# write OME-TIFF
imwrite('zcyx.ome.tif', image)
# write ImageJ hyperstack
imwrite('zcyx.tif', image, imagej=True)
Upvotes: 4