Skip to content
Snippets Groups Projects
Commit e2b759e4 authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Disabled generation of ilastik object model that receives segmentation masks...

Disabled generation of ilastik object model that receives segmentation masks from one that receives pixel probabilities; this was causing inaccurate results
parent 635a2926
No related branches found
No related tags found
3 merge requests!37Release 2024.04.19,!34Revert "Temporary error-handling for debug...",!33Enforce distinct ilastik object model workflows
......@@ -266,26 +266,6 @@ class IlastikObjectClassifierFromPixelPredictionsModel(IlastikModel, ImageToImag
obmap, _ = self.infer(img, mask)
return obmap
def make_instance_segmentation_model(self, px_ch: int):
"""
Generate an instance segmentation model, i.e. one that takes binary masks instead of pixel probabilities as a
second input.
:param px_ch: channel of pixel probability map to use
:return:
InstanceSegmentationModel object
"""
class _Mod(self.__class__, InstanceSegmentationModel):
def label_instance_class(
self, img: GenericImageDataAccessor, mask: GenericImageDataAccessor, **kwargs
) -> GenericImageDataAccessor:
if mask.dtype == 'bool':
norm_mask = 1.0 * mask.data
else:
norm_mask = mask.data / np.iinfo(mask.dtype).max
norm_mask_acc = InMemoryDataAccessor(norm_mask.astype('float32'))
return super().label_instance_class(img, norm_mask_acc, pixel_classification_channel=px_ch)
return _Mod(params={'project_file': self.project_file})
class Error(Exception):
......
......@@ -163,22 +163,6 @@ class TestIlastikPixelClassification(unittest.TestCase):
)
self.assertEqual(objmap.data.max(), 2)
def test_make_seg_obj_model_from_pxmap_obj(self):
self.test_run_pixel_classifier()
fp = czifile['path']
pxmap_model = ilm.IlastikObjectClassifierFromPixelPredictionsModel(
{'project_file': ilastik_classifiers['pxmap_to_obj']}
)
seg_model = pxmap_model.make_instance_segmentation_model(px_ch=0)
objmap = seg_model.label_instance_class(self.mono_image, self.mask)
self.assertTrue(
write_accessor_data_to_file(
output_path / f'obmap_seg_from_pxmap_{fp.stem}.tif',
objmap,
)
)
self.assertEqual(objmap.data.max(), 2)
def test_run_object_classifier_from_segmentation(self):
self.test_run_pixel_classifier()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment