nd2reader is a pure-Python package originally written by Jim Rybarski that is able to read ND2 files that are produces by Nikon microscopes. Unfortunately, the package was no longer maintained because the original maintainers switched to different microscope software. Because I regularly have to process ND2 files for my PhD research, I decided to revive the project.

The ND2 format

The ND2 file format is a proprietary binary format that is developed by Nikon. As a result, it is hard to easily convert ND2 files to a format in which they can be further processed using scripting languages such as Python.

An official Nikon SDK exists that can be used to process these files and the pims_nd2 package uses this official SDK to make the ND2 files processable via Python. Unfortunately, the metadata that is available via the official SDK is rather limited.

Improved metadata support

This pure-Python implementation was the result of a reverse engineering effort using different binary ND2 files. As a result, a lot more metadata is made available in dictionary form. The structure used by Nikon is a bit confusing, therefore the metadata is parsed into a more easily structured dictionary. Not all metadata tags are supported yet, but support for new metadata is added regularly.

Now with user documentation

I have added documentation and a quick start tutorial to the project, explaining how to install the package and what metadata is currently available. This documentation will slowly be expanded as new metadata features are added.

Easier API using the pims framework

I have rewritten the nd2reader package to use the pims framework, enabling easy access to multidimensional files, lazy slicing, and nice display in IPython. The new version 3.0.0 is available for installation via pip:

pip install nd2reader 

In the coming months, I plan on doing additional code refactors and speedups. Also, I plan to expand the support for different metadata that is exposed in dictionary form. I would love to hear any feedback or bug reports via the project page.