Skip to main content

napari-compressed-labels-io

License PyPI Python Version tests codecov

Description

This napari plugin provides readers and writers for labels and their corresponding image layers into zarr format for compression and portability. Each reader/writer pair supports a round trip of saving and loading image and labels layers.

Writers

Two writers are provided by this plugin, each with its own reader.

labels_to_zarr

This writer is an alternative to napari's default label writer and will write an entire labels layer, regardless of its dimensions, into a single zarr file. This writer provides the best compression option and its associated reader get_zarr_labels will read the layer back into napari.

This writer will be called when the user tries to save a selected labels layer into a path ending with .zarr

label_image_pairs_to_zarr

This writer will save 3-dimensional labels and image layers from the viewer into individual zarrs for portability and convenience. For example, given one labels and one image layer of the shape (10, 200, 200) saved to my_stacks.zarr, 10 subdirectories will be created, each with two zarrs inside of shape (200, 200) corresponding to the labels and image layer.

This writer allows users to load stacks of associated images, label them, and then quickly save these stacks out into individual slices for easy loading, viewing and interaction. Its associated reader supports the loading into napari of the whole stack, all layers at one slice of the stack, and an individual layer of a given slice of the stack.

The writer currently supports only 3D layers, with the exception of RGB images of the form (z, y, x, 3), which are also supported.

Readers

Two readers are provided by this plugin for loading the formats saved by each writer. These are detailed below.

get_zarr_labels

This reader will open any zarr file with a .zarray at the top level in path as a labels layer. This is to be used in conjunction with labels_to_zarr.

get_label_image_stack

This reader will open any zarr containing a .zmeta file as layers into napari. Depending on what is being opened, the reader will either load a full stack of labels and images, one slice of a stack of images and labels or an individual layer within a slice. This is to be used in conjunction with label_image_pairs_to_zarr.

.zmeta

This metadata file contains information about the layer types in the stack and in each individual slice, as well as the number of image/label slices. This allows the reader plugin to load the correct layer types with appropriate names both at a stack level and at the individual slice level.

An example .zmeta specification

{
    "meta": {
        "stack": 7                               # number of slices in the entire stack (1 for an individual slice, 0 for a layer within a slice)
    },
    "data": {
        "image" : [                              # all image layers must be listed here
            {
                "name": "leaves_example_data",
                "shape": [790, 790, 3],
                "dtype": "uint8",
                "rgb": true                      # where rgb is false the image will be loaded as greyscale (colormap support has not yet been implemented)
            }
        ],
        "labels" : [
            {
                "name": "oak",
                "shape": [790, 790],
                "dtype": "int64"
            },
            {
                "name": "bg",
                "shape": [790, 790],
                "dtype": "int64"
            }
        ]
    }
}

This napari plugin was generated with Cookiecutter using with @napari's cookiecutter-napari-plugin template.

Installation

You can install napari-compressed-labels-io via pip:

pip install napari-compressed-labels-io

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT license, "napari-compressed-labels-io" is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

Metadata

Release files for napari-compressed-labels-io 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for napari-compressed-labels-io 0.0.2
File Size Uploaded
napari-compressed-labels-io-0.0.2.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for napari-compressed-labels-io 0.0.2
File Interpreter ABI Platform
napari_compressed_labels_io-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 21.4 kB

Release files / napari-compressed-labels-io-0.0.2.tar.gz

Download URL napari-compressed-labels-io-0.0.2.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
be1d70b163a1928090d345190709ca9a2e4a3cdb33fa5d48625988ee411e61bb
BLAKE2b-256 checksum
How to use checksums
747f3d606c6d30e5bed9aa8b5c4414521e580856f492803af8215fd884205c92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1

Release files / napari_compressed_labels_io-0.0.2-py3-none-any.whl

Download URL napari_compressed_labels_io-0.0.2-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
132476d8c9e537752c91f64bb28ad546c7ad5b7f5d90382e7602f8614ae34ab8
BLAKE2b-256 checksum
How to use checksums
0310752f87feb2524caa8e24fa754d72a616d0527d7167b01d7e3236562db61f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release 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