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.

38 lines
1.7 KiB

  1. import unittest
  2. from nd2reader.artificial import ArtificialND2
  3. from nd2reader.label_map import LabelMap
  4. from nd2reader.raw_metadata import RawMetadata
  5. class TestRawMetadata(unittest.TestCase):
  6. def setUp(self):
  7. self.nd2 = ArtificialND2('test_data/test_nd2_raw_metadata001.nd2')
  8. self.raw_text, self.locations, self.file_data = self.nd2.raw_text, self.nd2.locations, self.nd2.data
  9. self.label_map = LabelMap(self.raw_text)
  10. self.metadata = RawMetadata(self.nd2.file_handle, self.label_map)
  11. def test_parse_roi_shape(self):
  12. self.assertEqual(self.metadata._parse_roi_shape(3), 'rectangle')
  13. self.assertEqual(self.metadata._parse_roi_shape(9), 'circle')
  14. self.assertIsNone(self.metadata._parse_roi_shape(-1))
  15. def test_parse_roi_type(self):
  16. self.assertEqual(self.metadata._parse_roi_type(3), 'reference')
  17. self.assertEqual(self.metadata._parse_roi_type(2), 'background')
  18. self.assertEqual(self.metadata._parse_roi_type(4), 'stimulation')
  19. self.assertIsNone(self.metadata._parse_roi_type(-1))
  20. def test_dict(self):
  21. self.assertTrue(type(self.metadata.__dict__) is dict)
  22. def test_parsed_metadata_has_all_keys(self):
  23. metadata = self.metadata.get_parsed_metadata()
  24. self.assertTrue(type(metadata) is dict)
  25. required_keys = ["height", "width", "date", "fields_of_view", "frames", "z_levels", "total_images_per_channel",
  26. "channels", "pixel_microns"]
  27. for required in required_keys:
  28. self.assertTrue(required in metadata)
  29. def test_pfs_status(self):
  30. self.assertEqual(self.file_data['pfs_status'], self.metadata.pfs_status[0])