Skip to main content

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

Project description

nis2pyr

License PyPI Python Version

The nis2pyr utility converts Nikon .nd2 files to tiled pyramidal OME TIFF files. These TIFF files can then be opened in QuPath for interactive viewing.

System Requirements

nis2pyr was tested on these platforms:

  • Windows 10
  • Ubuntu 18.04

It is however expected to run on a wider range of systems.

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]
               nd2_filename pyramid_filename

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

positional arguments:
  nd2_filename          full filename of the input ND2 file
  pyramid_filename      full filename of resulting pyramidal OME TIFF file; 
                        typically ends in .ome.tif

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; if this flag
                        is not specified the data will not be compressed; currently
                        'zlib' is the only useful algorithm, 'lzw' is not supported
  --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 files with multiple z-planes are not supported.
  • ND2 files with multiple timepoints are not supported.
  • 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.4.5.tar.gz (8.9 kB view hashes)

Uploaded Source

Built Distribution

nis2pyr-0.4.5-py3-none-any.whl (9.6 kB view hashes)

Uploaded Python 3

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