Advertisement
dachte

tiffstack_to_wkw

Jul 30th, 2024
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import argparse
  4. import code # for code.interact(local=dict(globals(), **locals()) ) debugging
  5. import glob
  6. import numpy as np
  7. import os
  8. import webknossos
  9. import webknossos.dataset
  10.  
  11. ######################
  12. # Make a wkw out of a tiff stack
  13.  
  14. def main():
  15.     cfg = handle_args()
  16.     files=sorted(glob.glob(os.path.join(cfg.src, "*.tiff")))
  17.    
  18.     dataset = webknossos.Dataset(dataset_path=cfg.dest, voxel_size=(8,8,8), name=cfg.dset_name, exist_ok=False)
  19.     dataset.add_layer_from_images(images=files, layer_name="seg", batch_size=cfg.batch_size, category=webknossos.dataset.SEGMENTATION_CATEGORY)
  20.  
  21.  
  22. def handle_args():
  23.     parser = argparse.ArgumentParser(description="This does a thing")
  24.     parser.add_argument("src",  help="Directory containing tiff stack")
  25.     parser.add_argument("dest", help="Target directory")
  26.     parser.add_argument("--dset_name", default="export_1720537802", help="Webknossos name for dataset")
  27.     parser.add_argument("--batch_size", default=32, type=int, help="Batch size for ingest")
  28.     parser.add_argument("--verbose",    help="Be noisier")
  29.     ret = parser.parse_args()
  30.     return ret
  31.  
  32. #####
  33. if __name__ == '__main__':
  34.     main()
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement