Correct way to add a new series to a TIFF

I’m trying to copy certain series from one file to another. I’m setting the the series when I write each image and the OME metadata looks good on the written file, but the written file just shows one series with multiple images. What is the correct way to add a new series to a file?

Hi @Erich_Bremer, do you have some sample code showing the process?

I suspect it is most likely due to missing metadata. For each series you will need to ensure the below values are populated (replace the index 0 with the index for your new series):

omexml.setImageID("Image:0", 0);
omexml.setPixelsID("Pixels:0", 0);

// specify that the pixel data is stored in big-endian order
// replace 'TRUE' with 'FALSE' to specify little-endian order
omexml.setPixelsBinDataBigEndian(Boolean.TRUE, 0, 0);

omexml.setPixelsDimensionOrder(DimensionOrder.XYCZT, 0);
omexml.setPixelsType(PixelType.UINT16, 0);
omexml.setPixelsSizeX(new PositiveInteger(width), 0);
omexml.setPixelsSizeY(new PositiveInteger(height), 0);
omexml.setPixelsSizeZ(new PositiveInteger(zSectionCount), 0);
omexml.setPixelsSizeC(new PositiveInteger(channelCount *
samplesPerChannel), 0);
omexml.setPixelsSizeT(new PositiveInteger(timepointCount), 0);

for (int channel=0; channel<channelCount; channel++) {
  omexml.setChannelID("Channel:0:" + channel, 0, channel);
  omexml.setChannelSamplesPerPixel(new PositiveInteger(samplesPerChannel),
    0, channel);
}

Unit<Length> unit = UNITS.MICROMETER;
Length physicalSizeX = new Length(1.0, unit);
Length physicalSizeY = new Length(1.5, unit);
Length physicalSizeZ = new Length(2, unit);
omexml.setPixelsPhysicalSizeX(physicalSizeX, 0);
omexml.setPixelsPhysicalSizeY(physicalSizeY, 0);
omexml.setPixelsPhysicalSizeZ(physicalSizeZ, 0);

Thanks, this did the trick! I did have to add a .meta.setPixelsSizeT(new PositiveInteger(1), 0); for it to work though. But your sample code help me clear it up.