Skip to main content

CFT Zarr Custom Codecs

Custom codecs for Zarr v3 optimized for CFT (Cryo-Fluorescence Tomography) data storage.

Codecs

This package provides custom Zarr v3 codecs:

  • cft_zarr.jpeg_compressor: JPEG compressor for RGB images (BytesBytesCodec - supports incremental updates)
  • cft_zarr.shift12jls_compressor: JPEG-LS compressor for 12-bit fluorescent data (BytesBytesCodec - supports incremental updates)
  • cft_zarr.jpeg: JPEG codec for RGB images (ArrayBytesCodec)
  • cft_zarr.shift12jls: JPEG-LS codec for 12-bit fluorescent data (ArrayBytesCodec)
  • cft_zarr.jls16: JPEG-LS codec for uint16 data without shifting; can also store scaled uint32 stack sums
  • cft_zarr.jpegxl: JPEG XL codec (ArrayBytesCodec)

Installation

pip install cft-zarr

Usage

Reading Zarr Files

Important: You must import cft_zarr before opening Zarr files that use these codecs. This registers the codecs with Zarr.

import cft_zarr  # This registers the codecs
import zarr

# Now you can open Zarr files that use custom codecs
arr = zarr.open('rgb.zarr', mode='r')

Using with napari

When opening Zarr files in napari, cft_zarr can be auto-registered via the napari plugin system (installed in the same environment as napari). If you still have trouble, import cft_zarr first:

import cft_zarr  # Register codecs before opening files
import napari

# Now napari can read Zarr files with custom codecs
viewer = napari.Viewer()
viewer.open('path/to/file.zarr')  # Will work with custom codecs

Or in a Python script before launching napari:

import cft_zarr  # Must import before opening Zarr files
import napari

viewer = napari.Viewer()
viewer.open('rgb.zarr')
napari.run()

Creating Zarr Arrays with Custom Codecs

import cft_zarr
from cft_zarr import JPEGCompressor, JLS16Codec, Shift12JLSCompressor
import zarr

# Create RGB array with JPEG compression
rgb_array = zarr.create(
    shape=(100, 512, 512, 3),
    chunks=(4, 512, 512, 3),
    dtype='uint8',
    compressors=[JPEGCompressor(level=85)]
)

# Create fluorescent array with Shift12JLS compression
fl_array = zarr.create(
    shape=(100, 512, 512),
    chunks=(4, 512, 512),
    dtype='uint16',
    compressors=[Shift12JLSCompressor()]
)

# Create a uint16 fluorescent array with direct JPEG-LS compression
jls16_array = zarr.create(
    shape=(100, 512, 512),
    chunks=(4, 512, 512),
    dtype='uint16',
    serializer=JLS16Codec(),
    compressors=[]
)

# Store 32x 12-bit stack sums as uint32 with scale=2.
# The encoded stream stores round(value / 2) as uint16 JPEG-LS and decodes
# back to value * 2, giving at most +/-1 count error from the scaling step.
stack32_array = zarr.create(
    shape=(100, 512, 512),
    chunks=(4, 512, 512),
    dtype='uint32',
    serializer=JLS16Codec(scale=2),
    compressors=[]
)

Download files

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

Source Distribution

cft_zarr-0.1.0.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

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

cft_zarr-0.1.0-py3-none-any.whl (41.9 kB view details)

Uploaded Python 3

File details

Details for the file cft_zarr-0.1.0.tar.gz.

File metadata

  • Download URL: cft_zarr-0.1.0.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/25.0.0

File hashes

Hashes for cft_zarr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4e3f226cd8ea283fa7810106454e2bbcf79645b0c8e36d8cab538cbc9ed5e978
MD5 466fc3349854b608fc903b47d4230e30
BLAKE2b-256 426d7534d31b48ea2bfba253448408aea2c431f1f794f44018a6492491276e2c

See more details on using hashes here.

File details

Details for the file cft_zarr-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cft_zarr-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 41.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/25.0.0

File hashes

Hashes for cft_zarr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c736940bcdab4f008a14e77dcff7fecffb982203351fd49082979b8922ffb69d
MD5 50c9c60abc181073491d51a13a3d5779
BLAKE2b-256 761e9cf790f9f3f5b914405f939da78ae9da212b298c194604faf5915dbf6420

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page