Ejemplo n.º 1
0
    def _build_label_map(self):
        """
        Every label ends with an exclamation point, however, we can't directly search for those to find all the labels
        as some of the bytes contain the value 33, which is the ASCII code for "!". So we iteratively find each label,
        grab the subsequent data (always 16 bytes long), advance to the next label and repeat.

        Returns:
            LabelMap: the computed label map

        """
        # go 8 bytes back from file end
        self._fh.seek(-8, 2)
        chunk_map_start_location = struct.unpack("Q", self._fh.read(8))[0]
        self._fh.seek(chunk_map_start_location)
        raw_text = self._fh.read(-1)
        return LabelMap(raw_text)
Ejemplo n.º 2
0
 def setUp(self):
     self.nd2 = ArtificialND2('test_data/test_nd2_raw_metadata001.nd2')
     self.raw_text, self.locations, self.file_data = self.nd2.raw_text, self.nd2.locations, self.nd2.data
     self.label_map = LabelMap(self.raw_text)
     self.metadata = RawMetadata(self.nd2.file_handle, self.label_map)
 def setUp(self):
     self.nd2 = ArtificialND2('test_data/test_nd2_label_map001.nd2')
     self.raw_text, self.locations = self.nd2.raw_text, self.nd2.locations
     self.label_map = LabelMap(self.raw_text)
class TestLabelMap(unittest.TestCase):
    def setUp(self):
        self.nd2 = ArtificialND2('test_data/test_nd2_label_map001.nd2')
        self.raw_text, self.locations = self.nd2.raw_text, self.nd2.locations
        self.label_map = LabelMap(self.raw_text)

    def test_image_data_location(self):
        self.assertEqual(self.locations['image_frame_0'][0],
                         self.label_map.get_image_data_location(0))

    def test_image_text_info(self):
        self.assertEqual(self.locations['image_text_info'][0],
                         self.label_map.image_text_info)

    def test_image_metadata(self):
        self.assertEqual(self.locations['image_metadata'][0],
                         self.label_map.image_metadata)

    def test_image_attributes(self):
        self.assertEqual(self.locations['image_attributes'][0],
                         self.label_map.image_attributes)

    def test_image_metadata_sequence(self):
        self.assertEqual(self.locations['image_metadata_sequence'][0],
                         self.label_map.image_metadata_sequence)

    def test_image_calibration(self):
        self.assertEqual(self.locations['image_calibration'][0],
                         self.label_map.image_calibration)

    def test_x_data(self):
        self.assertEqual(self.locations['x_data'][0], self.label_map.x_data)

    def test_y_data(self):
        self.assertEqual(self.locations['y_data'][0], self.label_map.y_data)

    def test_z_data(self):
        self.assertEqual(self.locations['z_data'][0], self.label_map.z_data)

    def test_roi_metadata(self):
        self.assertEqual(self.locations['roi_metadata'][0],
                         self.label_map.roi_metadata)

    def test_pfs_status(self):
        self.assertEqual(self.locations['pfs_status'][0],
                         self.label_map.pfs_status)

    def test_pfs_offset(self):
        self.assertEqual(self.locations['pfs_offset'][0],
                         self.label_map.pfs_offset)

    def test_guid(self):
        self.assertEqual(self.locations['guid'][0], self.label_map.guid)

    def test_description(self):
        self.assertEqual(self.locations['description'][0],
                         self.label_map.description)

    def test_camera_exposure_time(self):
        self.assertEqual(self.locations['camera_exposure_time'][0],
                         self.label_map.camera_exposure_time)

    def test_camera_temp(self):
        self.assertEqual(self.locations['camera_temp'][0],
                         self.label_map.camera_temp)

    def test_acquisition_times(self):
        self.assertEqual(self.locations['acquisition_times'][0],
                         self.label_map.acquisition_times)

    def test_acquisition_times_2(self):
        self.assertEqual(self.locations['acquisition_times_2'][0],
                         self.label_map.acquisition_times_2)

    def test_acquisition_frames(self):
        self.assertEqual(self.locations['acquisition_frames'][0],
                         self.label_map.acquisition_frames)

    def test_lut_data(self):
        self.assertEqual(self.locations['lut_data'][0],
                         self.label_map.lut_data)

    def test_grabber_settings(self):
        self.assertEqual(self.locations['grabber_settings'][0],
                         self.label_map.grabber_settings)

    def test_custom_data(self):
        self.assertEqual(self.locations['custom_data'][0],
                         self.label_map.custom_data)

    def test_app_info(self):
        self.assertEqual(self.locations['app_info'][0],
                         self.label_map.app_info)