Yet another nd2 (Nikon NIS Elements) file reader.
Project description
nd2
Yet another .nd2
(Nikon NIS Elements) file reader.
This reader provides a Cython wrapper for the official Nikon SDK (currently version 1.7.0.0, released Jun 23, 2021).
Features good metadata retrieval, and direct to_dask
and to_xarray
options for lazy and/or annotated arrays.
It does not currently support legacy format nd2 files (JPEG_XL files starting with bytes 0x0000000c
)
install
pip install nd2
(linux support coming but not yet ready)
usage
import nd2
# directly read file to numpy array:
my_array = nd2.imread('some_file.nd2')
# or open a file with ND2File
f = nd2.ND2File('some_file.nd2')
# attributes: # example output
f.shape # (10, 2, 256, 256)
f.ndim # 4
f.dtype # np.dtype('uint16')
f.axes # 'TCYX'
# methods
f.pixel_size() # (0.1, 0.1, 0.5) (x,y,z)
f.asarray() # np.ndarray, greedy reader
f.to_dask() # dask.array.Array, lazy reader
f.to_xarray() # xr.DataArray, with labeled axes/coords
# metadata # returns instance of ...
f.attributes() # nd2.structures.Attributes
f.metadata() # nd2.structures.Metadata
f.metadata(frame=3) # nd2.structures.FrameMetadata
f.experiment() # List[nd2.structures.ExpLoop]
f.text_info() # dict of misc info
f.close() # don't forget to close when done!
# ... or you can use it as a context manager
with nd2.ND2File('some_file.nd2') as ndfile:
print(ndfile.metadata())
xarr = ndfile.to_xarray(delayed=False)
issues
This is a work in progress (though working pretty well for most files!). If you have an nd2 file that errors or otherwise provides unexpected results, please open an issue and link to the file. I'd love to add it to the growing list of test files. (Note, if nd2._util.is_old_format('your.nd2')
returns True
, this is a legacy format that is not yet supported.)
alternatives
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for nd2-0.0.1rc5-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a97fccd71d80bef39c3b359a39e6fd98bfcb5b997205e8772044711eb799a01 |
|
MD5 | cec6e7e749892577ab072d4282b907cf |
|
BLAKE2b-256 | a844d5a2cb341724f6382276d80fd04739f93a8db38c078525f1c00f83c54fbd |
Hashes for nd2-0.0.1rc5-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8032a19f0bbffe088bf720cabcf7d1251f31b0f5b9e5053e0d46aef3bc0c73d8 |
|
MD5 | ac6f466aafb7168b095484340e0b2c56 |
|
BLAKE2b-256 | c605a7fe69064509099dd8b06ce75e08cbc353e4f183f294c27a015fde701f05 |
Hashes for nd2-0.0.1rc5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b6a357f16e510e5e0253f5b77d5528e9ac9d2159eab08e4bc9f086adbd2b561 |
|
MD5 | dd1b18adf0c9a4339d6a30c181e58d02 |
|
BLAKE2b-256 | b91a6e0fa5ba774905914d273afad47567bdd8b138d4c4d865aa3b4dbf5ae968 |
Hashes for nd2-0.0.1rc5-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dca6a3d6f3cc74205c715401485b50f54539f0cc0a7f84f8432f222e6c2516e3 |
|
MD5 | 778b715e422aadf43c0177afce474639 |
|
BLAKE2b-256 | 034c79a903f18396b4b29565c1364580925adb633507981ed83ee58215bc4085 |
Hashes for nd2-0.0.1rc5-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b4dc0e833e2fea068faffad82311a266fbdd6695a50d6025ca6d51bf11cccac |
|
MD5 | a705b6cd47cd6bceeb2e497678ebed04 |
|
BLAKE2b-256 | 2e713673b2fcf7b3f6b479daf8200f1c077adcea061447aba22b482627fa1085 |
Hashes for nd2-0.0.1rc5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5b8f712285c46abb0ce2cc43544932c5398d06f1678cdc2c0237fa2f6252e22 |
|
MD5 | 0a39aea788cb66df8d6f883fad8804a2 |
|
BLAKE2b-256 | f579ba3ace50940ab47b15f0128f8a443c8201f4759510707ff7d4dd420206aa |
Hashes for nd2-0.0.1rc5-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c20a2c8c2be8c7307704e1074431a5583ece04d865bf197249a12a7b5d8f871e |
|
MD5 | 8977cbcc816a8e28e27abcfeceb446fe |
|
BLAKE2b-256 | c47efda5165096cf0cacd9d7b2b8af085d32f881b979ce6a3f9a40bf9577fb89 |
Hashes for nd2-0.0.1rc5-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69b30edf9181788efef526a0fceb32358fd9a209ee2bfba6819514a3124c5db6 |
|
MD5 | 58c98af8f645768ae0c8971500e22f69 |
|
BLAKE2b-256 | 05ca0895aed3d597206abc14187c2b943c321774496207e865a1dff972c7c291 |
Hashes for nd2-0.0.1rc5-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02877ffd0d2585d4735b43151dfeaff747fe05fa61d1d72b8fa5182357748014 |
|
MD5 | 06cf51785f36cee70d111651bd02e1a1 |
|
BLAKE2b-256 | f9b5e37d1d9e9af75c915fcb01405f3e2397baa11e8ec8a6c82c6a8f085790b8 |