Skip to main content

A tiny Python 3 library for writing multi-channel TIFF stacks

Project description

xtiff

A tiny Python 3 library for writing multi-channel TIFF stacks.

The aim of this library is to provide an easy way to write multi-channel image stacks for external visualization and analysis. It acts as an interface to the popular tifffile package and supports xarray DataArrays as well as numpy-compatible data structures.

To maximize compatibility with third-party software, the images are written in standard-compliant fashion, with minimal metadata and in TZCYX channel order. In particular, a minimal (but extensible) subset of the OME-TIFF standard is supported, enabling the naming of channels.

Installation

Install from pypi:

pip install xtiff

Usage

The package provides the following main function for writing TIFF files:

to_tiff(img, file, image_name=None, channel_names=None, image_date=None,
        write_mode=WriteMode.OME_TIFF, big_tiff=None, big_tiff_size_threshold=4294967246, 
        byte_order=None, compression_type=None, compression_level=0, pixel_size=None,
        pixel_depth=None, ome_xml=get_ome_xml, ome_xml_template=OME_XML_TEMPLATE_201606V2
        **ome_xml_kwargs)

Documentation of the function parameters is available via Python's internal help system: help(xtiff.to_tiff)

In addition, the function get_ome_xml() is provided as the default OME-XML-generating function.

FAQ

Why should I care about TIFF? I use Zarr/NetCDF/whatever.

That's good! TIFF is an old and complex file format, has many disadvantages and is impractical for storing large images. However, it also remains one of the most widely used scientific image formats and is (at least partially) supported by many popular tools, such as ImageJ. With xtiff, you can continue to store your images in your favorite file format, while having the opportunity to easily convert them to a format that can be read by (almost) any tool.

Why can't I use the tifffile package directly?

Of course you can! Christoph Gohlke's tifffile package provides a very powerful and feature-complete interface for writing TIFF files and is the backend for xtiff. Essentially, the xtiff package is just a wrapper for tifffile. While you can in principle write any image directly with tifffile, in many cases, the flexibility of the TIFF format can be daunting. The xtiff package reduces the configuration burden and metadata to an essential minimum.

Change log

2019-12-12 v0.1.2 - Initial release
2019-12-12 v0.2.1 - Expose OME-XML to user
2019-12-12 v0.2.2 - Support for ome_xml_kwargs

License

This project is licensed under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xtiff-0.2.2.tar.gz (7.8 kB view details)

Uploaded Source

File details

Details for the file xtiff-0.2.2.tar.gz.

File metadata

  • Download URL: xtiff-0.2.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0.post20191030 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for xtiff-0.2.2.tar.gz
Algorithm Hash digest
SHA256 d17f86df9396378734fc661fd06d7d06794300c75bca65b2a090696cc02980dd
MD5 ef4bf7c4b28c07061c56ffaac7dd1e1b
BLAKE2b-256 86f6e8d48958e95a2276165e052beb0bcf4d7768d535541c6d6f1549d0cfd1ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page