Skip to main content

No project description provided

Project description

pytest

Tiffwrite

Write BioFormats/ImageJ compatible tiffs with zstd compression in parallel using Rust.

Features

  • Writes bigtiff files that open in ImageJ as hyperstack with correct dimensions.
  • Parallel compression.
  • Write individual frames in random order.
  • Compresses even more by referencing tag or image data which otherwise would have been saved several times. For example empty frames, or a long string tag on every frame. Editing tiffs becomes mostly impossible, but compression makes that very hard anyway.
  • Enables memory efficient scripts by saving frames whenever they're ready to be saved, not waiting for the whole stack.
  • Colormaps
  • Extra tags, globally or frame dependent.

Installation

pip install tiffwrite

or

Usage

Write an image stack

tiffwrite(file, data, axes='TZCXY', dtype=None, bar=False, *args, **kwargs)
  • file: string; filename of the new tiff file.
  • data: 2 to 5D numpy array in one of these datatypes: (u)int8, (u)int16, float32.
  • axes: string; order of dimensions in data, default: TZCXY for 5D, ZCXY for 4D, CXY for 3D, XY for 2D data.
  • dtype: string; cast data to dtype before saving, only (u)int8, (u)int16 and float32 are supported.
  • bar: bool; whether or not to show a progress bar.
  • args, kwargs: arguments to be passed to IJTiffFile, see below.

Write one frame at a time

with IJTiffFile(file, shape, dtype='uint16', colors=None, colormap=None, pxsize=None, deltaz=None,
                timeinterval=None, **extratags) as tif:
some loop:
    tif.save(frame, c, z, t)
  • file: string; filename of the new tiff file.

  • shape: iterable; shape (C, Z, T) of data to be written in file.

  • dtype: string; cast data to dtype before saving, only (u)int8, (u)int16 and float32 are supported.

  • colors: iterable of strings; one color per channel, valid colors (also html) are defined in matplotlib.colors. Without colormap BioFormats will set the colors in this order: rgbwcmy. Note that the color green is dark, the usual green is named 'lime' here.

  • colormap: string; choose any colormap from the colorcet module. Colors and colormap cannot be used simultaneously.

  • pxsize: float; pixel size im um.

  • deltaz: float; z slice interval in um.

  • timeinterval: float; time between frames in seconds.

  • extratags: other tags to be saved, example: Artist='John Doe', Tag4567=[400, 500] or Copyright=Tag('ascii', 'Made by me'). See tiff_tag_registry.items().

  • frame: 2D numpy array with data.

  • c, z, t: int; channel, z, time coordinates of the frame.

Examples

Write an image stack

from tiffwrite import tiffwrite
import numpy as np

image = np.random.randint(0, 255, (5, 3, 64, 64), 'uint16')
tiffwrite('file.tif', image, 'TCXY')

Write one frame at a time

from tiffwrite import IJTiffFile
import numpy as np

with IJTiffFile('file.tif', pxsize=0.09707) as tif:
    for c in range(3):
        for z in range(5):
            for t in range(10):
                tif.save(np.random.randint(0, 10, (32, 32)), c, z, t)

Saving multiple tiffs simultaneously

from tiffwrite import IJTiffFile
import numpy as np

shape = (3, 5, 10)  # channels, z, time
with IJTiffFile('fileA.tif') as tif_a, IJTiffFile('fileB.tif') as tif_b:
    for c in range(shape[0]):
        for z in range(shape[1]):
            for t in range(shape[2]):
                tif_a.save(np.random.randint(0, 10, (32, 32)), c, z, t)
                tif_b.save(np.random.randint(0, 10, (32, 32)), c, z, t)

Tricks & tips

  • The order of feeding frames to IJTiffFile is unimportant, IJTiffFile will order the ifd's such that the file will be opened as a correctly ordered hyperstack.
  • Using the colormap parameter you can make ImageJ open the file and apply the colormap. colormap='glasbey' is very useful.

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

tiffwrite-2024.10.5.tar.gz (32.9 kB view details)

Uploaded Source

Built Distributions

tiffwrite-2024.10.5-cp310-abi3-win_amd64.whl (485.1 kB view details)

Uploaded CPython 3.10+ Windows x86-64

tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (738.6 kB view details)

Uploaded CPython 3.10+ manylinux: glibc 2.17+ x86-64

tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (818.4 kB view details)

Uploaded CPython 3.10+ manylinux: glibc 2.17+ s390x

tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (806.1 kB view details)

Uploaded CPython 3.10+ manylinux: glibc 2.17+ ppc64le

tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (757.1 kB view details)

Uploaded CPython 3.10+ manylinux: glibc 2.17+ i686

tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (753.5 kB view details)

Uploaded CPython 3.10+ manylinux: glibc 2.17+ ARMv7l

tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (739.4 kB view details)

Uploaded CPython 3.10+ manylinux: glibc 2.17+ ARM64

tiffwrite-2024.10.5-cp310-abi3-macosx_11_0_arm64.whl (601.9 kB view details)

Uploaded CPython 3.10+ macOS 11.0+ ARM64

tiffwrite-2024.10.5-cp310-abi3-macosx_10_12_x86_64.whl (661.1 kB view details)

Uploaded CPython 3.10+ macOS 10.12+ x86-64

File details

Details for the file tiffwrite-2024.10.5.tar.gz.

File metadata

  • Download URL: tiffwrite-2024.10.5.tar.gz
  • Upload date:
  • Size: 32.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.4

File hashes

Hashes for tiffwrite-2024.10.5.tar.gz
Algorithm Hash digest
SHA256 a3faca052934b6ab236f0c10fff885e6ccc3de1b67e2d52b6390fe59a8a632c1
MD5 e1a0f50d4f2a3118dd8022ec42569fd9
BLAKE2b-256 eb40459bc930b236141366d8a4cd6309c45792fa2bc9c5e40f7b045d54239b66

See more details on using hashes here.

File details

Details for the file tiffwrite-2024.10.5-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tiffwrite-2024.10.5-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 25b1d61185abc59f13a26da725817e1b5cfe11bee4a501825d4869b7deed747a
MD5 cc8a646cc2f519d5b910dd49bc4b531c
BLAKE2b-256 8f9634977b06556a6e3f0fadc439b4888fbf646c6eab6f85bc0c430071a9ebeb

See more details on using hashes here.

File details

Details for the file tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d42ad23c590056168ddc234568193a741ad439ac20633846ad9b77e4207976f2
MD5 8a8e8ebdfabb411bf70cc3b63a29c2b6
BLAKE2b-256 263fd23d2b7df8696928ca72ea0af4ae639400496abb5df061cbde06defd4412

See more details on using hashes here.

File details

Details for the file tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 fd422d602a585b88756c210c6143ccf57a29eb4e593d6345213555e3c5c397a5
MD5 8ed667e2de4f004c57357b712fcdfe54
BLAKE2b-256 c8e99d9b5d746726f14116f721b0856caa144b10a85a0fac6e2257e4313d5e22

See more details on using hashes here.

File details

Details for the file tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 ea1ace5b19cd31f8aaf18d25d1dc4b01fb322329c42dcf6fb5af54c08f44b977
MD5 9d5a0fc0c3582528bbaae52d65c06115
BLAKE2b-256 d0bfb255048e80668eb022007c5102e2f8a8946b6fcce419974e76d4c671dc47

See more details on using hashes here.

File details

Details for the file tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 1fc30010259c9a44b2f20a8c8e662a4ce0abdaadfc9f44f15518c1a86876736b
MD5 bb96fc02fd8ad7fe4f68b5f4ae10825f
BLAKE2b-256 bdbafc594ead94c70d1b4fc8759447792d08fbd65588283c3c66bbffa47a14c6

See more details on using hashes here.

File details

Details for the file tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 8af7cfbf750852ce426577f1ea984d52c5aff39cc087cdcd2686471a3b73d03b
MD5 ec8345009abf345b2da6783f53539503
BLAKE2b-256 4ed0603e9f1c2623559df83f8a45666b0075ff50b8a0c5563c565f8d90e34f3e

See more details on using hashes here.

File details

Details for the file tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tiffwrite-2024.10.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3aea61f73fe6b898b8f81ba9dc442597f80270533ad12479f62763045c634844
MD5 1282b4b458ea7cedd69880061e641c33
BLAKE2b-256 3dc8c5df8a11daf34149815be4d6e3fe4e5105e8d37e17859467b425ee54df61

See more details on using hashes here.

File details

Details for the file tiffwrite-2024.10.5-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tiffwrite-2024.10.5-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5decc95d22853901072b581f258ea1022d99c703ee009343f090ff5bbec27736
MD5 78c522548bf4928eedc6fe5dd6d6bf19
BLAKE2b-256 e429aa7e053643dfe3ddec1c13e4f8df57adf85e8678f976855f09436fd7e526

See more details on using hashes here.

File details

Details for the file tiffwrite-2024.10.5-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for tiffwrite-2024.10.5-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 bb031ee31371d6311a99f2dc216b0967ea7912b3a6a58c124ee9fc7b5dc43ec6
MD5 8823d129d8b24a03bc54f6dbcf705825
BLAKE2b-256 0179a43a186f95ce59f34133ca1cbda9f9a85df3def12523916dd35ff0e33e23

See more details on using hashes here.

Supported by

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