Ejemplo n.º 1
0
 def disabled_test_series_data_ordering(self):
     s = "/Users/cmeyer/Downloads/NEW_7FocalSeriesImages_Def_50000nm.dm3"
     data_out, dimensional_calibrations_out, intensity_calibration_out, title_out, metadata_out = dm3_image_utils.load_image(s)
     import pprint
     pprint.pprint(metadata_out)
     print(data_out.shape)
Ejemplo n.º 2
0
 def test_metadata_difficult_types_write_read_round_trip(self):
     s = io.BytesIO()
     data_in = numpy.ones((6, 4), numpy.float32)
     dimensional_calibrations_in = [Calibration.Calibration(1, 2, "nm"), Calibration.Calibration(2, 3, u"µm")]
     intensity_calibration_in = Calibration.Calibration(4, 5, "six")
     metadata_in = {"abc": None, "": "", "one": [], "two": {}, "three": [1, None, 2]}
     dm3_image_utils.save_image(data_in, dimensional_calibrations_in, intensity_calibration_in, metadata_in, s)
     s.seek(0)
     data_out, dimensional_calibrations_out, intensity_calibration_out, title_out, metadata_out = dm3_image_utils.load_image(s)
     metadata_expected = {"one": [], "two": {}, "three": [1, 2]}
     self.assertEqual(metadata_out, metadata_expected)
Ejemplo n.º 3
0
 def test_metadata_write_read_round_trip(self):
     s = io.BytesIO()
     data_in = numpy.ones((6, 4), numpy.float32)
     dimensional_calibrations_in = [Calibration.Calibration(1, 2, "nm"), Calibration.Calibration(2, 3, u"µm")]
     intensity_calibration_in = Calibration.Calibration(4, 5, "six")
     metadata_in = {"abc": 1, "def": "abc", "efg": { "one": 1, "two": "TWO", "three": [3, 4, 5] }}
     dm3_image_utils.save_image(data_in, dimensional_calibrations_in, intensity_calibration_in, metadata_in, s)
     s.seek(0)
     data_out, dimensional_calibrations_out, intensity_calibration_out, title_out, metadata_out = dm3_image_utils.load_image(s)
     self.assertEqual(metadata_in, metadata_out)
Ejemplo n.º 4
0
 def test_calibrations_write_read_round_trip(self):
     s = io.BytesIO()
     data_in = numpy.ones((6, 4), numpy.float32)
     dimensional_calibrations_in = [Calibration.Calibration(1.1, 2.1, "nm"), Calibration.Calibration(2, 3, u"µm")]
     intensity_calibration_in = Calibration.Calibration(4.4, 5.5, "six")
     metadata_in = dict()
     dm3_image_utils.save_image(data_in, dimensional_calibrations_in, intensity_calibration_in, metadata_in, s)
     s.seek(0)
     data_out, dimensional_calibrations_out, intensity_calibration_out, title_out, metadata_out = dm3_image_utils.load_image(s)
     dimensional_calibrations_out = [Calibration.Calibration(*d) for d in dimensional_calibrations_out]
     self.assertEqual(dimensional_calibrations_in, dimensional_calibrations_out)
     intensity_calibration_out = Calibration.Calibration(*intensity_calibration_out)
     self.assertEqual(intensity_calibration_in, intensity_calibration_out)
Ejemplo n.º 5
0
 def test_rgb_data_write_read_round_trip(self):
     s = io.BytesIO()
     data_in = (numpy.random.randn(6, 4, 3) * 255).astype(numpy.uint8)
     dimensional_calibrations_in = [Calibration.Calibration(1, 2, "nm"), Calibration.Calibration(2, 3, u"µm")]
     intensity_calibration_in = Calibration.Calibration(4, 5, "six")
     metadata_in = {"abc": None, "": "", "one": [], "two": {}, "three": [1, None, 2]}
     dm3_image_utils.save_image(data_in, dimensional_calibrations_in, intensity_calibration_in, metadata_in, s)
     s.seek(0)
     data_out, dimensional_calibrations_out, intensity_calibration_out, title_out, metadata_out = dm3_image_utils.load_image(s)
     self.assertTrue(numpy.array_equal(data_in, data_out))
Ejemplo n.º 6
0
 def test_data_write_read_round_trip(self):
     dtypes = (numpy.float32, numpy.float64, numpy.complex64, numpy.complex128, numpy.int16, numpy.uint16, numpy.int32, numpy.uint32)
     shapes = ((6, 4), (6, ), (6, 4, 2))
     for dtype in dtypes:
         for shape in shapes:
             s = io.BytesIO()
             data_in = numpy.ones(shape, dtype)
             dimensional_calibrations_in = list()
             for index, dimension in enumerate(shape):
                 dimensional_calibrations_in.append(Calibration.Calibration(1.0 + 0.1 * index, 2.0 + 0.2 * index, "µ" + "n" * index))
             intensity_calibration_in = Calibration.Calibration(4, 5, "six")
             metadata_in = dict()
             dm3_image_utils.save_image(data_in, dimensional_calibrations_in, intensity_calibration_in, metadata_in, s)
             s.seek(0)
             data_out, dimensional_calibrations_out, intensity_calibration_out, _, _ = dm3_image_utils.load_image(s)
             self.assertTrue(numpy.array_equal(data_in, data_out))
             dimensional_calibrations_out = [Calibration.Calibration(*d) for d in dimensional_calibrations_out]
             self.assertEqual(dimensional_calibrations_in, dimensional_calibrations_out)
             self.assertEqual(intensity_calibration_in, Calibration.Calibration(*intensity_calibration_out))