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.

29 lines
1.1 KiB

10 years ago
10 years ago
10 years ago
  1. import logging
  2. from nd2reader.service import BaseNd2
  3. from nd2reader.model import Image
  4. log = logging.getLogger("nd2reader")
  5. log.addHandler(logging.StreamHandler())
  6. log.setLevel(logging.DEBUG)
  7. class Nd2(BaseNd2):
  8. def __init__(self, filename):
  9. super(Nd2, self).__init__(filename)
  10. def get_image(self, timepoint, fov, channel_name, z_level):
  11. image_set_number = self._calculate_image_set_number(timepoint, fov, z_level)
  12. timestamp, raw_image_data = self._reader.get_raw_image_data(image_set_number, self.channel_offset[channel_name])
  13. return Image(timestamp, raw_image_data, self.height, self.width)
  14. def __iter__(self):
  15. """
  16. Just return every image.
  17. """
  18. for i in range(self._image_count):
  19. for fov in range(self._field_of_view_count):
  20. for z_level in range(self._z_level_count):
  21. for channel in self.channels:
  22. image = self.get_image(i, fov, channel.name, z_level)
  23. if image.is_valid:
  24. yield image