Skip to main content

A tiny Python library for writing multi-channel TIFF stacks

Project description

xtiff

PyPI PyPI - Python Version PyPI - License Codecov GitHub Workflow Status (branch) GitHub issues GitHub pull requests

A tiny Python 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 customizable) subset of the OME-TIFF standard is supported, enabling the naming of channels.

Requirements

This package requires Python 3.7 or later.

Python package dependencies are listed in requirements.txt.

Using virtual environments is strongly recommended.

Installation

Install xtiff and its dependencies with:

pip install xtiff

Usage

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

to_tiff(img, file, image_name=None, image_date=None, channel_names=None, description=None,
        profile=TiffProfile.OME_TIFF, big_endian=None, big_tiff=None, big_tiff_threshold=4261412864,
        compression_type=None, compression_level=0, pixel_size=None, pixel_depth=None,
        software='xtiff', ome_xml_fun=get_ome_xml, **ome_xml_kwargs):

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

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

FAQ

What metadata is included in the written images?

In general, written metadata is kept at a minimum and only information that can be inferred from the raw image data is included (image dimensions, data type, number of channels, channel names for xarrays). Additional metadata natively supported by the tifffile package can be specified using function parameters. For OME-TIFF files, the OME-XML "Description" tag contents can be further refined by specifying custom OME-XML-generating functions.

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.

Authors

Created and maintained by Jonas Windhager jonas.windhager@uzh.ch

Contributing

Contributing

Changelog

Changelog

License

MIT

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.7.1.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xtiff-0.7.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xtiff-0.7.1.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for xtiff-0.7.1.tar.gz
Algorithm Hash digest
SHA256 c7041f29bebc2af912563fae4d3fec5e4a5978669f20e7f3498da9b151a316c9
MD5 01ffda05a48ee0a75d665e70f7b39a27
BLAKE2b-256 b9a7c701bcd38946f27be133ec0ddc253ab2aba8b4ccdb953f51c9e8c8d2426a

See more details on using hashes here.

File details

Details for the file xtiff-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: xtiff-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for xtiff-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9217e047fa26592b1c0610cb8ac437de1c5af267df4f272102f6a3747d0daa69
MD5 91f5cac4b11baa6f30159db14dc27319
BLAKE2b-256 2f3bb624c2d253389a683011bd226fb4009c30286740e98e81c9f239c17e5eaa

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