def test_load_label_counts_from_ilastik(self): img_path = os.path.join(base_path, '../test_data/ilastik') lbl_path = os.path.join(base_path, '../test_data/ilastik/ilastik-1.2.ilp') c = io_connector(img_path, lbl_path) d = Dataset(c) actual_counts = c.label_count_for_image(0) print(actual_counts) label_counts = d.load_label_counts() print(label_counts) assert_array_equal(label_counts[1], np.array([1])) assert_array_equal(label_counts[2], np.array([1])) assert_array_equal(label_counts[3], np.array([1]))
def test_load_label_counts(self): img_path = os.path.join(base_path, '../test_data/tiffconnector_1/im/') label_path = os.path.join(base_path, '../test_data/tiffconnector_1/labels/') c = TiffConnector(img_path, label_path) d = Dataset(c) t = d.load_label_counts() # labelcounts for each image for labelvalue 1 expected_1 = np.array([4, 0, 0]) # labelcounts for each image for labelvalue 2 expected_2 = np.array([3, 0, 11]) # labelcounts for each image for labelvalue 3 expected_3 = np.array([3, 0, 3]) assert_array_equal(expected_1, t[1]) assert_array_equal(expected_2, t[2]) assert_array_equal(expected_3, t[3]) self.assertTrue(sorted(list(t.keys())), [1, 2, 3])