Skip to main content

Nifti-Zarr conversion tools in Python

Project description

nifti-zarr-py: Implementation of the NIfTI-Zarr specification in Python

Installation

pip install nifti-zarr

Python API

Convert a nifti file to a nifti-zarr storage.

from niizarr import nii2zarr
nii2zarr("path/to/nifti.nii.gz", "s3://path/to/bucket")

Convert a nifti-zarr storage to a nifti file. The pyramid level can be selected with level=L, where 0 is the base/finest level.

from niizarr import zarr2nii
zarr2nii("s3://path/to/bucket", "path/to/nifti.nii.gz", level=0)

Load a nifti-zarr into a nibabel.Nifti1Image object.

from niizarr import zarr2nii
nivol = zarr2nii("s3://path/to/bucket", level=0)

Command Line Interface

NIfTI to NIfTI-Zarr

usage: nii2zarr [-h]
                [--chunk CHUNK]
                [--unchunk-channels]
                [--unchunk-time]
                [--levels LEVELS]
                [--method {gaussian,laplacian}]
                [--fill FILL]
                [--compressor {blosc,zlib}]
                [--label]
                [--no-label]
                [--no-time]
                [--no-pyramid-axis {x,y,z}]
                [--zarr-version {2,3}]
                [--ome-version {0.4,0.5}]
                [--validate]
                input [output]

Convert nifti to nifti-zarr.

positional arguments:
  input                         Input nifti file.
  output                        Output zarr directory.
                                When not specified, write to input directory.

optional arguments:
  -h, --help                    Show this help message and exit.
  --chunk CHUNK                 Spatial chunk size.
  --unchunk-channels            Save all chanels in a single chunk.
                                Unchunk if you want to display all channels
                                as a single RGB layer in neuroglancer.
                                Chunked by default, unless datatype is RGB.
  --unchunk-time                Save all timepoints in a single chunk.
                                Unchunk if you want to display all timepoints
                                as a single RGB layer in neuroglancer.
                                Chunked by default.
  --levels LEVELS               Number of levels in the pyramid.
                                If -1 (default), use as many levels as possible.
  --method {gaussian,laplacian} Pyramid method.
  --fill FILL                   Missing value.
  --compressor {blosc,zlib}     Compressor.
  --label                       Segmentation volume.
  --no-label                    Not a segmentation volume.
  --no-time                     No time dimension.
  --no-pyramid-axis {x,y,z}     Thick slice axis that should not be downsampled.
  --zarr-version {2,3}          Zarr format version.
  --ome-version {0.4,0.5}       OME-Zarr specification version.
  --validate                    Validate the Zarr with the `ome-zarr-models` package.

NIfTI-Zarr to NIfTI

usage: zarr2nii [-h] [--level LEVEL] input [output]

Convert nifti-zarr to nifti.

positional arguments:
  input          Input zarr directory
  output         Output nifti file.
                 When not provided, write to the same directory as input

optional arguments:
  -h, --help     Show this help message and exit.
  --level LEVEL  Pyramid level to extract (default: 0 = finest).

Citation

If your project utilizes the nifti-zarr-py package, please cite the following DOI:

zenodo

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

nifti_zarr-1.0.0rc6.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

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

nifti_zarr-1.0.0rc6-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file nifti_zarr-1.0.0rc6.tar.gz.

File metadata

  • Download URL: nifti_zarr-1.0.0rc6.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nifti_zarr-1.0.0rc6.tar.gz
Algorithm Hash digest
SHA256 2a51cd3b54668c1dcad8432f1471f0c4e790387f94dbfc2642da45abdf3a7d08
MD5 5b9d221c74d26e5dbcd03946ad7fc86b
BLAKE2b-256 b4279680e7009fb70136f1906f5fdb2d924a42c26347ac6d84bf2b726a34c08b

See more details on using hashes here.

Provenance

The following attestation bundles were made for nifti_zarr-1.0.0rc6.tar.gz:

Publisher: publish_on_release.yml on neuroscales/nifti-zarr-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nifti_zarr-1.0.0rc6-py3-none-any.whl.

File metadata

  • Download URL: nifti_zarr-1.0.0rc6-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nifti_zarr-1.0.0rc6-py3-none-any.whl
Algorithm Hash digest
SHA256 3ae19d48a9dd421842ed14f5eae1569abe368358b88e85a49b543e38689bcdfd
MD5 cbdfd687540a82284ca59239ff760e22
BLAKE2b-256 beba0ee8af97cf5e9424c5f348a4aab1470d9220734e5ed9222055716a5e2cd5

See more details on using hashes here.

Provenance

The following attestation bundles were made for nifti_zarr-1.0.0rc6-py3-none-any.whl:

Publisher: publish_on_release.yml on neuroscales/nifti-zarr-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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