itk montage tiff without ome-tiff header

hello, i use the itk montage stitching tiles and get a tiff file, but it is not standard tiff format i think, which can not be opened in openslide
image
is there a way to get a OME-XML metadata to the tiff file of itk montage output, or any other fomat supported by openslide above
the itk montage has a warning message dealing with an unsuported image format, but its hard to figure out the exact format by the ImageIO name

itk::ImageFileWriterException (000000E7A472EFC0)
Location: "unknown" 
File: D:\projects\ITK\Modules\IO\ImageBase\include\itkImageFileWriter.hxx
Line: 117
Description:  Could not create IO object for writing file F:\projects\ITKMontage\examples\output_micro/montage.ngff
  Tried to create one of the following:
    BMPImageIO
    BioRadImageIO
    Bruker2dseqImageIO
    GDCMImageIO
    GE4ImageIO
    GE5ImageIO
    GiplImageIO
    HDF5ImageIO
    JPEGImageIO
    JPEG2000ImageIO
    LSMImageIO
    MINCImageIO
    MRCImageIO
    MetaImageIO
    NiftiImageIO
    NrrdImageIO
    PNGImageIO
    StimulateImageIO
    TIFFImageIO
    VTKImageIO
  You probably failed to set a file suffix, or
    set the suffix to an unsupported type.

No file IO in ITK knows about .ngff file format extension. But ITK can read and write TIFF (probably generic variant) files. Support for ZarrNGFF is a work in progress.

It is possible to add whatever metadata you want to the tiff file of ITK montage output, including OME-XML metadata, but that is not implemented. You are the first person to ask for it, so if you want it you will probably have to implement it yourself.

1 Like

Could the ITK remote module SCIFIO be helpful here?

2 Likes

Hi,

We should add OME-TIFF metadata input / output support into ITK TIFF’s ImageIO. Tracking issue.

An OME-TIFF could be generated in Python with tifffile with something like:

import itk
import tifffile
import numpy as np

image = itk.imread('montage.mha')
with tifffile.TiffWriter('montage.ome.tif', ometiff=True) as tiff:
    options = dict(photometric='minisblack', tile=(128, 128), compression='zlib')
    axes = 'YX'
    metadata={'axes': axes}
    metadata['PhysicalSizeX'] = image.GetSpacing()[0]
    metadata['PhysicalSizeY'] = image.GetSpacing()[1]
    tiff.write(np.asarray(image), **options, metadata=metadata)

itk.Image Origin and z-spacing could be set with per-Plane: PositionX, PositionY, PositionZ.

2 Likes