def test_03_02_load_using_bioformats(self): path = os.path.join(example_images_directory(), 'ExampleSBSImages', 'Channel1-01-A-01.tif') data = F.load_using_bioformats(path, rescale=False) expected_0_10_0_10 = np.array( [[ 0, 7, 7, 6, 5, 8, 4, 2, 1, 2], [ 0, 8, 8, 7, 6, 10, 4, 2, 2, 2], [ 0, 9, 9, 7, 8, 8, 2, 1, 3, 2], [ 0, 10, 9, 8, 10, 6, 2, 2, 3, 2], [ 0, 10, 10, 10, 9, 4, 2, 2, 2, 2], [ 0, 9, 9, 10, 8, 3, 2, 4, 2, 2], [ 0, 9, 9, 10, 8, 2, 2, 4, 3, 2], [ 0, 9, 8, 9, 7, 4, 2, 2, 2, 2], [ 0, 10, 11, 9, 9, 4, 2, 2, 2, 2], [ 0, 12, 13, 12, 9, 4, 2, 2, 2, 2]], dtype=np.uint8) expected_n10_n10 = np.array( [[2, 1, 1, 1, 2, 2, 1, 2, 1, 2], [1, 2, 2, 2, 2, 1, 1, 1, 2, 1], [1, 1, 1, 2, 1, 2, 2, 2, 2, 1], [2, 2, 2, 2, 3, 2, 2, 2, 2, 1], [1, 2, 2, 1, 1, 1, 1, 1, 2, 2], [2, 1, 2, 2, 2, 1, 1, 2, 2, 2], [2, 2, 3, 2, 2, 1, 2, 2, 2, 1], [3, 3, 1, 2, 2, 2, 2, 3, 2, 2], [3, 2, 2, 2, 2, 2, 2, 2, 3, 3], [5, 2, 3, 3, 2, 2, 2, 3, 2, 2]], dtype=np.uint8) self.assertTrue(np.all(expected_0_10_0_10 == data[:10,:10])) self.assertTrue(np.all(expected_n10_n10 == data[-10:,-10:]))
def test_03_02_load_using_bioformats(self): path = os.path.join(os.path.dirname(__file__), "Channel1-01-A-01.tif") data = F.load_using_bioformats(path, rescale=False) expected_0_10_0_10 = np.array( [ [0, 7, 7, 6, 5, 8, 4, 2, 1, 2], [0, 8, 8, 7, 6, 10, 4, 2, 2, 2], [0, 9, 9, 7, 8, 8, 2, 1, 3, 2], [0, 10, 9, 8, 10, 6, 2, 2, 3, 2], [0, 10, 10, 10, 9, 4, 2, 2, 2, 2], [0, 9, 9, 10, 8, 3, 2, 4, 2, 2], [0, 9, 9, 10, 8, 2, 2, 4, 3, 2], [0, 9, 8, 9, 7, 4, 2, 2, 2, 2], [0, 10, 11, 9, 9, 4, 2, 2, 2, 2], [0, 12, 13, 12, 9, 4, 2, 2, 2, 2], ], dtype=np.uint8, ) expected_n10_n10 = np.array( [ [2, 1, 1, 1, 2, 2, 1, 2, 1, 2], [1, 2, 2, 2, 2, 1, 1, 1, 2, 1], [1, 1, 1, 2, 1, 2, 2, 2, 2, 1], [2, 2, 2, 2, 3, 2, 2, 2, 2, 1], [1, 2, 2, 1, 1, 1, 1, 1, 2, 2], [2, 1, 2, 2, 2, 1, 1, 2, 2, 2], [2, 2, 3, 2, 2, 1, 2, 2, 2, 1], [3, 3, 1, 2, 2, 2, 2, 3, 2, 2], [3, 2, 2, 2, 2, 2, 2, 2, 3, 3], [5, 2, 3, 3, 2, 2, 2, 3, 2, 2], ], dtype=np.uint8, ) self.assertTrue(np.all(expected_0_10_0_10 == data[:10, :10])) self.assertTrue(np.all(expected_n10_n10 == data[-10:, -10:]))
def test_01_03_write_color_tiff(self): r = np.random.RandomState() r.seed(103) img = r.randint(0, 256, (9, 11, 3)) path = self.get_tempfilename(".tif") W.write_image(path, img, OME.PT_UINT8) result = load_using_bioformats(path, rescale = False) np.testing.assert_array_equal(img, result)
def test_01_02_write_monchrome_16_bit__tiff(self): r = np.random.RandomState() r.seed(102) img = r.randint(0, 4096, size=(21, 24)) path = self.get_tempfilename(".tif") W.write_image(path, img, OME.PT_UINT16) result = load_using_bioformats(path, rescale=False) np.testing.assert_array_equal(img, result)
def test_01_01_write_monochrome_8_bit_tif(self): r = np.random.RandomState() r.seed(101) img = r.randint(0, 256, (11, 33)).astype(np.uint8) path = self.get_tempfilename(".tif") W.write_image(path, img, OME.PT_UINT8) result = load_using_bioformats(path, rescale=False) np.testing.assert_array_equal(img, result)
def test_01_03_write_color_tiff(self): r = np.random.RandomState() r.seed(103) img = r.randint(0, 256, (9, 11, 3)) path = self.get_tempfilename(".tif") W.write_image(path, img, OME.PT_UINT8) result = load_using_bioformats(path, rescale=False) np.testing.assert_array_equal(img, result)
def test_02_01_write_movie(self): r = np.random.RandomState() r.seed(103) img = r.randint(0, 256, (7, 23, 11)) path = self.get_tempfilename(".tif") for i in range(img.shape[0]): W.write_image(path, img[i], OME.PT_UINT8, t=i, size_t = img.shape[0]) for i in range(img.shape[0]): result = load_using_bioformats(path, t=i, rescale = False) np.testing.assert_array_equal(img[i], result)
def test_02_01_write_movie(self): r = np.random.RandomState() r.seed(103) img = r.randint(0, 256, (7, 23, 11)) path = self.get_tempfilename(".tif") for i in range(img.shape[0]): W.write_image(path, img[i], OME.PT_UINT8, t=i, size_t=img.shape[0]) for i in range(img.shape[0]): result = load_using_bioformats(path, t=i, rescale=False) np.testing.assert_array_equal(img[i], result)