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.

106 lines
2.5 KiB

9 years ago
9 years ago
9 years ago
  1. class Metadata(object):
  2. """ A simple container for ND2 metadata. """
  3. def __init__(self, height, width, channels, date, fields_of_view, frames, z_levels, total_images_per_channel, pixel_microns):
  4. self._height = height
  5. self._width = width
  6. self._channels = channels
  7. self._date = date
  8. self._fields_of_view = fields_of_view
  9. self._frames = frames
  10. self._z_levels = z_levels
  11. self._total_images_per_channel = total_images_per_channel
  12. self._pixel_microns = pixel_microns
  13. @property
  14. def height(self):
  15. """
  16. The image height in pixels.
  17. :rtype: int
  18. """
  19. return self._height
  20. @property
  21. def width(self):
  22. """
  23. The image width in pixels.
  24. :rtype: int
  25. """
  26. return self._width
  27. @property
  28. def date(self):
  29. """
  30. The date and time when acquisition began.
  31. :rtype: datetime.datetime() or None
  32. """
  33. return self._date
  34. @property
  35. def channels(self):
  36. """
  37. These are labels created by the NIS Elements user. Typically they may a short description of the filter cube
  38. used (e.g. "bright field", "GFP", etc.)
  39. :rtype: list
  40. """
  41. return self._channels
  42. @property
  43. def fields_of_view(self):
  44. """
  45. The metadata contains information about fields of view, but it contains it even if some fields
  46. of view were cropped. We can't find anything that states which fields of view are actually
  47. in the image data, so we have to calculate it. There probably is something somewhere, since
  48. NIS Elements can figure it out, but we haven't found it yet.
  49. :rtype: list
  50. """
  51. return self._fields_of_view
  52. @property
  53. def frames(self):
  54. """
  55. The number of cycles.
  56. :rtype: list
  57. """
  58. return self._frames
  59. @property
  60. def z_levels(self):
  61. """
  62. The different levels in the Z-plane. Just a sequence from 0 to n.
  63. :rtype: list
  64. """
  65. return self._z_levels
  66. @property
  67. def total_images_per_channel(self):
  68. """
  69. The total number of images of a particular channel (wavelength, filter, etc) in the entire ND2.
  70. :rtype: int
  71. """
  72. return self._total_images_per_channel
  73. @property
  74. def pixel_microns(self):
  75. """
  76. The width of a pixel in microns.
  77. :rtype: float
  78. """
  79. return self._pixel_microns