xtiff


Namextiff JSON
Version 0.7.9 PyPI version JSON
download
home_pagehttps://github.com/BodenmillerGroup/xtiff
SummaryA tiny Python library for writing multi-channel TIFF stacks
upload_time2023-01-31 22:26:48
maintainer
docs_urlNone
authorJonas Windhager
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # xtiff

![PyPI](https://img.shields.io/pypi/v/xtiff)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/xtiff)
![PyPI - License](https://img.shields.io/pypi/l/xtiff)
![Codecov](https://img.shields.io/codecov/c/github/BodenmillerGroup/xtiff)
![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/BodenmillerGroup/xtiff/build.yml)
![GitHub issues](https://img.shields.io/github/issues/BodenmillerGroup/xtiff)
![GitHub pull requests](https://img.shields.io/github/issues-pr/BodenmillerGroup/xtiff)

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](https://www.lfd.uci.edu/~gohlke/) package and supports
[xarray](http://xarray.pydata.org) DataArrays as well as [numpy](https://www.numpy.org)-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.8 or newer.

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,
            interleaved=True, software='xtiff', ome_xml_fun=get_ome_xml, **ome_xml_kwargs)


    img: The image to write, as xarray DataArray or numpy-compatible data structure.
        Supported shapes:
        - (y, x),
        - (c, y, x)
        - (z, c, y, x)
        - (t, z, c, y, x)
        - (t, z, c, y, x, s)
        Supported data types:
        - any numpy data type when using TiffProfile.TIFF
        - uint8, uint16, float32 when using TiffProfile.IMAGEJ (uint8 for RGB images)
        - bool, int8, int16, int32, uint8, uint16, uint32, float32, float64 when using TiffProfile.OME_TIFF

    file: File target supported by tifffile TiffWriter, e.g. path to file (str, pathlib.Path) or binary stream.

    image_name: Image name for OME-TIFF images. If True, the image name is determined using the DataArray name or
        the file name (in that order); if False, the image name is not set. If None, defaults to the behavior for True
        for named DataArrays and when the file path is provided, and to the behavior of False otherwise. Only relevant
        when writing OME-TIFF files, any value other than None or False will raise a warning for other TIFF profiles.

    image_date: Date and time of image creation in '%Y:%m:%d %H:%M:%S' format or as datetime object. Defaults to
        the current date and time if None. Note: this does not determine the OME-XML AcquisitionDate element value.

    channel_names: A list of channel names. If True, channel names are determined using the DataArray channel
        coordinate; if False, channel names are not set. If None, defaults to the behavior for True for DataArrays when
        writing multi-channel OME-TIFFs, and to the behavior for False otherwise. Only relevant when writing
        multi-channel OME-TIFF files, any value other than None or False will raise a warning for other TIFF profiles.

    description: TIFF description tag. Will default to the OME-XML header when writing OME-TIFF files. Any value
        other than None will raise a warning in this case.

    profile: TIFF specification of the written file.
        Supported TIFF profiles:
        - TIFF (no restrictions apply)
        - ImageJ (undocumented file format that is supported by the ImageJ software)
        - OME-TIFF (Open Microscopy Environment TIFF standard-compliant file format with minimal OME-XML header)

    big_endian: If true, stores data in big endian format, otherwise uses little endian byte order. If None, the
        byte order is set to True for the ImageJ TIFF profile and defaults to the system default otherwise.

    big_tiff: If True, enables support for writing files larger than 4GB. Not supported for TiffProfile.IMAGEJ.

    big_tiff_threshold: Threshold for enabling BigTIFF support when big_tiff is set to None, in bytes. Defaults
        to 4GB, minus 32MB for metadata.

    compression_type: Compression algorithm, see tifffile.TIFF.COMPRESSION() for available values. Compression is
        not supported for TiffProfile.IMAGEJ. Note: Compression prevents from memory-mapping images and should therefore
        be avoided when images are compressed externally, e.g. when they are stored in compressed archives.

    compression_level: Compression level, between 0 and 9. Compression is not supported for TiffProfile.IMAGEJ.
        Note: Compression prevents from memory-mapping images and should therefore be avoided when images are compressed
        externally, e.g. when they are stored in compressed archives.

    pixel_size: Planar (x/y) size of one pixel, in micrometer.

    pixel_depth: Depth (z size) of one pixel, in micrometer. Only relevant when writing OME-TIFF files, any value
        other than None will raise a warning for other TIFF profiles.

    interleaved: If True, OME-TIFF images are saved as interleaved (this only affects OME-XML metadata). Always
        True for RGB(A) images (i.e., S=3 or 4) - a warning will be raised if explicitly set to False for RGB(A) images.

    software: Name of the software used to create the file. Must be 7-bit ASCII. Saved with the first page only.

    ome_xml_fun: Function that will be used for generating the OME-XML header. See the default implementation for
        reference of the required signature. Only relevant when writing OME-TIFF files, ignored otherwise.

    ome_xml_kwargs: Optional arguments that are passed to the ome_xml_fun function. Only relevant when writing
        OME-TIFF files, will raise a warning if provided for other TIFF profiles.

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

## 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](https://www.lfd.uci.edu/~gohlke/) 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](mailto:jonas.windhager@uzh.ch)

## Contributing

[Contributing](https://github.com/BodenmillerGroup/xtiff/blob/master/CONTRIBUTING.md)

## Changelog

[Changelog](https://github.com/BodenmillerGroup/xtiff/blob/master/CHANGELOG.md)

## License

[MIT](https://github.com/BodenmillerGroup/xtiff/blob/master/LICENSE.md)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/BodenmillerGroup/xtiff",
    "name": "xtiff",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Jonas Windhager",
    "author_email": "jonas.windhager@uzh.ch",
    "download_url": "https://files.pythonhosted.org/packages/10/7e/14b378c876fe7721bd2aad642e1412b1fda3447e70168bc4d37f5c6d8e3d/xtiff-0.7.9.tar.gz",
    "platform": null,
    "description": "# xtiff\n\n![PyPI](https://img.shields.io/pypi/v/xtiff)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/xtiff)\n![PyPI - License](https://img.shields.io/pypi/l/xtiff)\n![Codecov](https://img.shields.io/codecov/c/github/BodenmillerGroup/xtiff)\n![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/BodenmillerGroup/xtiff/build.yml)\n![GitHub issues](https://img.shields.io/github/issues/BodenmillerGroup/xtiff)\n![GitHub pull requests](https://img.shields.io/github/issues-pr/BodenmillerGroup/xtiff)\n\nA tiny Python library for writing multi-channel TIFF stacks.\n\nThe aim of this library is to provide an easy way to write multi-channel image stacks for external visualization and\nanalysis. It acts as an interface to the popular [tifffile](https://www.lfd.uci.edu/~gohlke/) package and supports\n[xarray](http://xarray.pydata.org) DataArrays as well as [numpy](https://www.numpy.org)-compatible data structures.\n\nTo maximize compatibility with third-party software, the images are written in standard-compliant fashion, with minimal\nmetadata and in TZCYX channel order. In particular, a minimal (but customizable) subset of the OME-TIFF standard is\nsupported, enabling the naming of channels.\n\n## Requirements\n\nThis package requires Python 3.8 or newer.\n\nUsing virtual environments is strongly recommended.\n\n## Installation\n\nInstall xtiff and its dependencies with:\n\n    pip install xtiff\n\n\n## Usage\n\nThe package provides the following main function for writing TIFF files:\n\n    to_tiff(img, file, image_name=None, image_date=None, channel_names=None, description=None,\n            profile=TiffProfile.OME_TIFF, big_endian=None, big_tiff=None, big_tiff_threshold=4261412864,\n            compression_type=None, compression_level=0, pixel_size=None, pixel_depth=None,\n            interleaved=True, software='xtiff', ome_xml_fun=get_ome_xml, **ome_xml_kwargs)\n\n\n    img: The image to write, as xarray DataArray or numpy-compatible data structure.\n        Supported shapes:\n        - (y, x),\n        - (c, y, x)\n        - (z, c, y, x)\n        - (t, z, c, y, x)\n        - (t, z, c, y, x, s)\n        Supported data types:\n        - any numpy data type when using TiffProfile.TIFF\n        - uint8, uint16, float32 when using TiffProfile.IMAGEJ (uint8 for RGB images)\n        - bool, int8, int16, int32, uint8, uint16, uint32, float32, float64 when using TiffProfile.OME_TIFF\n\n    file: File target supported by tifffile TiffWriter, e.g. path to file (str, pathlib.Path) or binary stream.\n\n    image_name: Image name for OME-TIFF images. If True, the image name is determined using the DataArray name or\n        the file name (in that order); if False, the image name is not set. If None, defaults to the behavior for True\n        for named DataArrays and when the file path is provided, and to the behavior of False otherwise. Only relevant\n        when writing OME-TIFF files, any value other than None or False will raise a warning for other TIFF profiles.\n\n    image_date: Date and time of image creation in '%Y:%m:%d %H:%M:%S' format or as datetime object. Defaults to\n        the current date and time if None. Note: this does not determine the OME-XML AcquisitionDate element value.\n\n    channel_names: A list of channel names. If True, channel names are determined using the DataArray channel\n        coordinate; if False, channel names are not set. If None, defaults to the behavior for True for DataArrays when\n        writing multi-channel OME-TIFFs, and to the behavior for False otherwise. Only relevant when writing\n        multi-channel OME-TIFF files, any value other than None or False will raise a warning for other TIFF profiles.\n\n    description: TIFF description tag. Will default to the OME-XML header when writing OME-TIFF files. Any value\n        other than None will raise a warning in this case.\n\n    profile: TIFF specification of the written file.\n        Supported TIFF profiles:\n        - TIFF (no restrictions apply)\n        - ImageJ (undocumented file format that is supported by the ImageJ software)\n        - OME-TIFF (Open Microscopy Environment TIFF standard-compliant file format with minimal OME-XML header)\n\n    big_endian: If true, stores data in big endian format, otherwise uses little endian byte order. If None, the\n        byte order is set to True for the ImageJ TIFF profile and defaults to the system default otherwise.\n\n    big_tiff: If True, enables support for writing files larger than 4GB. Not supported for TiffProfile.IMAGEJ.\n\n    big_tiff_threshold: Threshold for enabling BigTIFF support when big_tiff is set to None, in bytes. Defaults\n        to 4GB, minus 32MB for metadata.\n\n    compression_type: Compression algorithm, see tifffile.TIFF.COMPRESSION() for available values. Compression is\n        not supported for TiffProfile.IMAGEJ. Note: Compression prevents from memory-mapping images and should therefore\n        be avoided when images are compressed externally, e.g. when they are stored in compressed archives.\n\n    compression_level: Compression level, between 0 and 9. Compression is not supported for TiffProfile.IMAGEJ.\n        Note: Compression prevents from memory-mapping images and should therefore be avoided when images are compressed\n        externally, e.g. when they are stored in compressed archives.\n\n    pixel_size: Planar (x/y) size of one pixel, in micrometer.\n\n    pixel_depth: Depth (z size) of one pixel, in micrometer. Only relevant when writing OME-TIFF files, any value\n        other than None will raise a warning for other TIFF profiles.\n\n    interleaved: If True, OME-TIFF images are saved as interleaved (this only affects OME-XML metadata). Always\n        True for RGB(A) images (i.e., S=3 or 4) - a warning will be raised if explicitly set to False for RGB(A) images.\n\n    software: Name of the software used to create the file. Must be 7-bit ASCII. Saved with the first page only.\n\n    ome_xml_fun: Function that will be used for generating the OME-XML header. See the default implementation for\n        reference of the required signature. Only relevant when writing OME-TIFF files, ignored otherwise.\n\n    ome_xml_kwargs: Optional arguments that are passed to the ome_xml_fun function. Only relevant when writing\n        OME-TIFF files, will raise a warning if provided for other TIFF profiles.\n\nIn addition, `get_ome_xml()` is provided as the default OME-XML-generating function.\n\n## FAQ\n\n**What metadata is included in the written images?**\n\nIn general, written metadata is kept at a minimum and only information that can be inferred from the raw image data is\nincluded (image dimensions, data type, number of channels, channel names for xarrays). Additional metadata natively supported by the\ntifffile package can be specified using function parameters. For OME-TIFF files, the OME-XML \"Description\" tag contents\ncan be further refined by specifying custom OME-XML-generating functions.\n\n**Why should I care about TIFF? I use Zarr/NetCDF/whatever.**\n\nThat's good! TIFF is an old and complex file format, has many disadvantages and is impractical for storing large images.\nHowever, it also remains one of the most widely used scientific image formats and is (at least partially) supported by\nmany popular tools, such as ImageJ. With xtiff, you can continue to store your images in your favorite file format,\nwhile having the opportunity to easily convert them to a format that can be read by (almost) any tool.\n\n**Why can't I use the tifffile package directly?**\n\nOf course you can! Christoph Gohlke's [tifffile](https://www.lfd.uci.edu/~gohlke/) package provides a very powerful and\nfeature-complete interface for writing TIFF files and is the backend for xtiff. Essentially, the xtiff package is just a\nwrapper for tifffile. While you can in principle write any image directly with tifffile, in many cases, the flexibility\nof the TIFF format can be daunting. The xtiff package reduces the configuration burden and metadata to an essential\nminimum.\n\n## Authors\n\nCreated and maintained by Jonas Windhager [jonas.windhager@uzh.ch](mailto:jonas.windhager@uzh.ch)\n\n## Contributing\n\n[Contributing](https://github.com/BodenmillerGroup/xtiff/blob/master/CONTRIBUTING.md)\n\n## Changelog\n\n[Changelog](https://github.com/BodenmillerGroup/xtiff/blob/master/CHANGELOG.md)\n\n## License\n\n[MIT](https://github.com/BodenmillerGroup/xtiff/blob/master/LICENSE.md)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A tiny Python library for writing multi-channel TIFF stacks",
    "version": "0.7.9",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3df31aa514962d3667008436b670ea3e2b913c2430b7500661d8c1ed74e8e9d4",
                "md5": "c2cc1598eb64fad31d562b5d9b9c3444",
                "sha256": "d147764a1c44270a5aeba46b28efd2955cf0c7fd264590040a87cd980d86b702"
            },
            "downloads": -1,
            "filename": "xtiff-0.7.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c2cc1598eb64fad31d562b5d9b9c3444",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11682,
            "upload_time": "2023-01-31T22:26:46",
            "upload_time_iso_8601": "2023-01-31T22:26:46.671984Z",
            "url": "https://files.pythonhosted.org/packages/3d/f3/1aa514962d3667008436b670ea3e2b913c2430b7500661d8c1ed74e8e9d4/xtiff-0.7.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "107e14b378c876fe7721bd2aad642e1412b1fda3447e70168bc4d37f5c6d8e3d",
                "md5": "e21d0187ad2b17c454be23a484f5df6d",
                "sha256": "a77a30686fded43645b748be9a8cef9a6316b079e59b3163f7b52e2e294881d2"
            },
            "downloads": -1,
            "filename": "xtiff-0.7.9.tar.gz",
            "has_sig": false,
            "md5_digest": "e21d0187ad2b17c454be23a484f5df6d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 17443,
            "upload_time": "2023-01-31T22:26:48",
            "upload_time_iso_8601": "2023-01-31T22:26:48.339503Z",
            "url": "https://files.pythonhosted.org/packages/10/7e/14b378c876fe7721bd2aad642e1412b1fda3447e70168bc4d37f5c6d8e3d/xtiff-0.7.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-31 22:26:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "BodenmillerGroup",
    "github_project": "xtiff",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "xtiff"
}
        
Elapsed time: 0.27968s