I am using BioFormats to read and write to an image file.
When reading an image, I noticed that it is possible to calculate the plane that I want to read by using
Z, like this:
int C = ...; int T = ...; int Z = ...; ImageReader reader = new ImageReader(); reader.setId("some_image.tiff"); int planeNumber = reader.getIndex(Z, C, T); reader.openBytes(planeNumber, [...]);
However, I do not have the same luxury when writing an image.
Currently, the only way to do it is to manually input the information about
Z, C, T:
int totalZ = ...; int totalC = ...; int totalT = ...; String dimensionOrder = ...; int planeNumber = FormatTools.getIndex(dimensionOrder, totalZ, totalC, totalT, Z, C, T); ImageWriter writer = new ImageWriter(); // Populate necessary metadata, have some bytes to write to image... writer.setId("output_image.tiff"); writer.saveBytes(planeNumber, [...]);
In order to write bytes into an image, it is required anyways to insert the minimum required metadata, so the information about
ZCT should already be available.
Given this, it is not clear to me why the
getIndex method is not directly available to the ImageWriter interface, which would be both convenient and consistent.