diff --git a/model_server/base/roiset.py b/model_server/base/roiset.py index ffb8418f9429be3160ab9ef3c701b216fd1e82d5..c44023db6622237b5fe40dd82b90d2f161187517 100644 --- a/model_server/base/roiset.py +++ b/model_server/base/roiset.py @@ -474,7 +474,15 @@ class RoiSet(object): dfe['patch'] = self._df.apply(lambda r: _make_patch(r), axis=1) return dfe - def run_exports(self, where, channel, prefix, params: RoiSetExportParams): + def run_exports(self, where: Path, channel, prefix, params: RoiSetExportParams) -> dict: + """ + Export various representations of ROIs, e.g. patches, annotated stacks, and object maps. + :param where: path of directory in which to write all export products + :param channel: color channel of products to export + :param prefix: prefix of the name of each product's file or subfolder + :param params: RoiSetExportParams object describing which products to export and with which parameters + :return: dict of Path objects describing the location of single-file export products + """ record = {} if not self.count: return @@ -506,11 +514,10 @@ class RoiSet(object): if k == 'annotated_zstacks': self.export_annotated_zstack(subdir, prefix=pr, **kp) if k == 'object_classes': - record[k] = {} for kc, acc in self.object_class_maps.items(): fp = subdir / kc / (pr + '.tif') write_accessor_data_to_file(fp, acc) - record[k][kc] = fp.__str__() + record[f'{k}_{kc}'] = fp if k == 'dataframe': dfpa = subdir / (pr + '.csv') dfpa.parent.mkdir(parents=True, exist_ok=True) diff --git a/tests/test_roiset.py b/tests/test_roiset.py index 4c95552848bcc334696e96ff8584c3bfbc03398b..3040e6d251305731d0c3dcad5b3727a1bb48b614 100644 --- a/tests/test_roiset.py +++ b/tests/test_roiset.py @@ -148,9 +148,9 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase): 'obmap', RoiSetExportParams(object_classes=True) ) - opa = record['object_classes']['dummy_class'] - acc = generate_file_accessor(opa) + opa = record['object_classes_dummy_class'] self.assertTrue(Path(opa).exists()) + acc = generate_file_accessor(opa) self.assertTrue(all(np.unique(acc.data) == [0, 1]))