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

Clean test showing that modified HDF5 isn't providing correct results

parent 4da7a119
No related branches found
No related tags found
No related merge requests found
......@@ -7,17 +7,22 @@ import numpy as np
from extensions.chaeo.accessors import MonoPatchStack, MonoPatchStackFromFile
from extensions.chaeo.models import PatchStackObjectClassifier
def modify_ilastik_object_classifier(template_ilp: Path, lane=0):
where = template_ilp.parent
def modify_ilastik_object_classifier(template_ilp: Path, lane: int = 0):
proj_dir = template_ilp.parent
proj_name = template_ilp.stem
new_ilp = shutil.copy(template_ilp, where / ('mod_' + proj_name + '.ilp'))
proj_new_ilp = shutil.copy(template_ilp, proj_dir / ('mod_' + proj_name + '.ilp'))
with h5py.File(where / new_ilp, 'r+') as h5:
with h5py.File(where / proj_new_ilp, 'r+') as h5:
# delete ObjectExtraction / RegionFeatures / 0000
# delete ObjectClassification/ClassifierForests
for key in [f'ObjectExtraction/RegionFeatures/{lane:04d}', 'ObjectExtraction/ClassifierForests']:
if (key) in h5.keys():
keys_to_delete = [
f'ObjectExtraction/RegionFeatures/{lane:04d}',
'ObjectExtraction/ClassifierForests'
]
for key in keys_to_delete:
if key in h5.keys():
del h5[key]
assert key not in h5.keys()
......@@ -33,7 +38,7 @@ def modify_ilastik_object_classifier(template_ilp: Path, lane=0):
h5[f'{key}/filePath'] = rel_pa
assert h5[f'{key}/filePath'][()] == rel_pa.encode()
return new_ilp
return proj_new_ilp
if __name__ == '__main__':
......
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