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

Export table of z-stack patch files and annotations

parent a2ace075
No related branches found
No related tags found
No related merge requests found
......@@ -241,9 +241,11 @@ def transfer_ecotaxa_labels_to_patch_stacks(
# export patches as a single z-stack
zstack_keys = ['mask', 'label', 'raw']
zstacks = {k: np.zeros((*patch_size, 1, len(df_tr)), dtype='uint8') for k in zstack_keys}
stack_meta = []
for fi, pl in enumerate(df_tr.itertuples(name='PatchFile')):
fn = pl._asdict()['patch_filename']
ac = pl._asdict()['annotation_class_id']
stack_meta.append({'zi': fi, 'patch_filename': fn, 'annotation_class_id': ac})
acc_bm = generate_file_accessor(Path(where_masks) / fn)
assert acc_bm.hw == patch_size, f'Unexpected patch size {patch_size}'
assert acc_bm.chroma == 1
......@@ -258,4 +260,6 @@ def transfer_ecotaxa_labels_to_patch_stacks(
for k in zstack_keys:
write_accessor_data_to_file(Path(where_output) / f'zstack_{k}.tif', InMemoryDataAccessor(zstacks[k]))
pd.DataFrame(stack_meta).to_csv(Path(where_output) / 'training_stack.csv', index=False)
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