You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.3 KiB

8 years ago
8 years ago
  1. # Tutorial
  2. ### Installation
  3. The package is available on PyPi. Install it using:
  4. ```
  5. pip install nd2reader
  6. ```
  7. If you don't already have the packages `numpy`, `pims`, `six` and `xmltodict`, they will be installed automatically if you use the `setup.py` script.
  8. `nd2reader` is an order of magnitude faster in Python 3. I recommend using it unless you have no other choice. Python 2.7 and Python >= 3.4 are supported.
  9. #### Installation via Conda Forge
  10. Installing `nd2reader` from the `conda-forge` channel can be achieved by adding `conda-forge` to your channels with:
  11. ```
  12. conda config --add channels conda-forge
  13. ```
  14. Once the `conda-forge` channel has been enabled, `nd2reader` can be installed with:
  15. ```
  16. conda install nd2reader
  17. ```
  18. It is possible to list all of the versions of `nd2reader` available on your platform with:
  19. ```
  20. conda search nd2reader --channel conda-forge
  21. ```
  22. ### Opening ND2s
  23. `nd2reader` follows the [pims](https://github.com/soft-matter/pims) framework. To open a file and show the first frame:
  24. ```python
  25. from nd2reader import ND2Reader
  26. import matplotlib.pyplot as plt
  27. with ND2Reader('my_directory/example.nd2') as images:
  28. plt.imshow(images[0])
  29. ```
  30. After opening the file, all `pims` features are supported. Please refer to the [pims documentation](http://soft-matter.github.io/pims/).
  31. ### ND2 metadata
  32. The ND2 file contains various metadata, such as acquisition information,
  33. regions of interest and custom user comments. Most of this metadata is parsed
  34. and available in dictionary form. For example:
  35. ```python
  36. from nd2reader import ND2Reader
  37. with ND2Reader('my_directory/example.nd2') as images:
  38. # width and height of the image
  39. print('%d x %d px' % (images.metadata['width'], images.metadata['height']))
  40. ```
  41. All metadata properties are:
  42. * `width`: the width of the image in pixels
  43. * `height`: the height of the image in pixels
  44. * `date`: the date the image was taken
  45. * `fields_of_view`: the fields of view in the image
  46. * `frames`: a list of all frame numbers
  47. * `z_levels`: the z levels in the image
  48. * `total_images_per_channel`: the number of images per color channel
  49. * `channels`: the color channels
  50. * `pixel_microns`: the amount of microns per pixel
  51. * `rois`: the regions of interest (ROIs) defined by the user
  52. * `experiment`: information about the nature and timings of the ND experiment