Skip to content
Snippets Groups Projects

Resolve "ilastik models do not validate dimensionality of input data"

1 file
+ 8
6
Compare changes
  • Side-by-side
  • Inline
@@ -97,7 +97,7 @@ class TestIlastikPixelClassification(unittest.TestCase):
objmap,
)
)
self.assertEqual(objmap.data.max(), 3)
self.assertEqual(objmap.data.max(), 2)
def test_run_object_classifier_from_segmentation(self):
self.test_run_pixel_classifier()
@@ -269,16 +269,18 @@ class TestIlastikObjectClassification(unittest.TestCase):
)
)
self.object_classifier = ilm.PatchStackObjectClassifier(
self.object_classifier = ilm.IlastikObjectClassifierFromSegmentationModel(
params={'project_file': ilastik_classifiers['seg_to_obj']}
)
def test_classify_patches(self):
raw_patches = self.roiset.get_raw_patches()
patch_masks = self.roiset.get_patch_masks()
res_patches, _ = self.object_classifier.infer(raw_patches, patch_masks)
res_patches = self.object_classifier.label_instance_class(raw_patches, patch_masks)
self.assertEqual(res_patches.count, self.roiset.count)
res_patches.export_pyxcz(output_path / 'res_patches.tif')
for pi in range(0, res_patches.count): # assert that there is only one nonzero label per patch
unique = np.unique(res_patches.iat(pi).data)
self.assertEqual(len(unique), 2)
self.assertEqual(unique[0], 0)
la, ct = np.unique(res_patches.iat(pi).data, return_counts=True)
self.assertEqual(np.sum(ct > 1), 2) # exclude single-pixel anomaly
self.assertEqual(la[0], 0)
Loading