Skip to main content

Utility for converting Nikon ND2 files to tiled pyramidal OME TIFF files.

Project description

nis2pyr

License PyPI Python Version Test codecov

nis2pyr converts Nikon .nd2 files to tiled pyramidal OME TIFF files. The conversion is straightforward and can be performed via the nis2pyr command line tool, or via a simple one-liner in Python using the nis2pyr package.

System Requirements

nis2pyr was tested on these platforms:

  • Windows 10
  • Windows Server 2019
  • Ubuntu 18.04
  • Ubuntu 20.04
  • macOS 10.15
  • macOS 11

Installation

Installation is straightforward:

pip install nis2pyr

This installs the nis2pyr Python package which provides an easy to use function to convert ND2 files to OME TIFF. It also installs the nis2pyr program to convert ND2 files to OME TIFF from the command line.

Using nis2pyr in a Python program

Converting an ND2 file to pyramidal OME TIFF in Python is easy:

from nis2pyr.convertor import convert_nd2_to_pyramidal_ome_tiff

convert_nd2_to_pyramidal_ome_tiff('original.nd2', 'pyramidal.ome.tif', compression='zlib')

The number of pyramid levels and the tile size can be specified as well (see the convert_nd2_to_pyramidal_ome_tiff docstring) but there is typically no need to do so.

Running nis2pyr on the command line

To generate an uncompressed pyramidal file with the default options, run nis2pyr on the command line, specifying the .nd2 input image file and the name of the pyramidal OME TIFF to which it needs to be converted:

nis2pyr input.nd2 pyramid.ome.tif

It is also possible to specify the compression algorithm, number of pyramid levels and the tile size of the output pyramidal OME TIFF.

usage: nis2pyr [-h] [--version] [--compression COMPRESSION] 
               [--pyramid-levels PYRAMID_LEVELS] [--tile-size TILE_SIZE]
               input_file_pattern [pyramid_filename]

Convert Nikon ND2 image files to tiled pyramidal OME TIFF files.

positional arguments:
  input_file_pattern    either the filename of a single ND2 file that needs to 
                        be converted, or a filename pattern ('glob') to convert 
                        multiple files. This filename pattern can be used for
                        example to convert all ND2 files in a given directory.
  pyramid_filename      if only a single filename is specified as input file 
                        pattern, pyramid_filename is the full filename of the
                        resulting pyramidal OME TIFF file; if no pyramid filename
                        is provided, or if multiple files are converted, the 
                        pyramidal OME TIFF(s) will be written to the same directory 
                        as the original ND2 and with the same filename but 
                        with an .ome.tif extension

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --compression COMPRESSION
                        the algorithm used for compressing the image data; currently
                        'zlib' is the only supported compression algorithm
                        (default: no compression)
  --pyramid-levels PYRAMID_LEVELS
                        the maximum number of resolution levels in the pyramidal OME TIFF,
                        including the full resolution image; successive pyramid
                        levels are downsampled by a factor 2
                        (default: 6)
  --tile-size TILE_SIZE
                        width in pixels of the tiles in the pyramidal OME TIFF;
                        the tiles are square; tile size must be a multiple of 16
                        (default: 256)

Limitations

Known limitations of the current version of nis2pyr:

  • ND2 metadata is lost, except for pixel size and channel names and colors.

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

nis2pyr-0.6.2.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

nis2pyr-0.6.2-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file nis2pyr-0.6.2.tar.gz.

File metadata

  • Download URL: nis2pyr-0.6.2.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for nis2pyr-0.6.2.tar.gz
Algorithm Hash digest
SHA256 713f3ad73c89900621be095e9b89f7120a9c429be5b3b24f792c0ce5d436cdb2
MD5 7eafdd60b8806a754d51d45fe6010a20
BLAKE2b-256 a1639b5466e89ee29cb59e2f63a4aac31f4afc4b707c0b3a6382a45e6d7e7f50

See more details on using hashes here.

File details

Details for the file nis2pyr-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: nis2pyr-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for nis2pyr-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b5fec67cae61d0c9734b0fde547ca2e6fe4599bfdaa10f2c0cc3f1ccf57e9b59
MD5 42486f15fb1969f50804b562ce1cb45f
BLAKE2b-256 aa1ab1a694847b7623f1d87fae8cfc1bd3a5290df40b9cdf023ec574370b2760

See more details on using hashes here.

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