1414
1515def main (
1616 input_path : str ,
17- output_folder : str ,
17+ output_dir : str = None ,
1818 scale : float = 0.38 ,
1919 input_key : str = "setup0/timepoint0/s0" ,
2020 interpolation_order : int = 3
@@ -23,7 +23,7 @@ def main(
2323
2424 Args:
2525 input_path: Input path to tif file or n5 folder.
26- output_folder : Output folder for rescaled data in n5 format.
26+ output_dir : Output folder for rescaled data in n5 format.
2727 scale: Scale of output data.
2828 input_key: The key / internal path of the image data.
2929 interpolation_order: Interpolation order for resizing function.
@@ -36,8 +36,13 @@ def main(
3636 input_chunks = input_ .chunks
3737
3838 abs_path = os .path .abspath (input_path )
39- basename = "" .join (os .path .basename (abs_path ).split ("." )[:- 1 ])
40- output_path = os .path .join (output_folder , basename + "_resized.n5" )
39+ basename = "." .join (os .path .basename (abs_path ).split ("." )[:- 1 ])
40+ input_dir = os .path .abspath (input_path ).split (basename )[0 ]
41+
42+ if output_dir is None :
43+ output_path = os .path .join (input_dir , basename + "_resized.n5" )
44+ else :
45+ output_path = os .path .abspath (output_dir )
4146
4247 shape = input_ .shape
4348 ndim = len (shape )
@@ -78,15 +83,14 @@ def copy_chunk(block_index):
7883 parser = argparse .ArgumentParser (
7984 description = "Script for resizing microscoopy data in n5 format." )
8085
81- parser .add_argument ("input_file" , type = str , required = True , help = "Input tif file or n5 folder." )
82- parser .add_argument (
83- "output_folder" , type = str , help = "Output folder. Default resized output is '<basename>_resized.n5'."
84- )
86+ parser .add_argument ("-i" , "--input" , required = True , type = str , help = "Input tif file or n5 folder." )
87+ parser .add_argument ("-o" , "--output" , type = str ,
88+ help = "Output n5 folder. Default resized output is '<basename>_resized.n5'." )
8589
8690 parser .add_argument ("-s" , "--scale" , type = float , default = 0.38 , help = "Scale of input. Re-scaled to 1." )
8791 parser .add_argument ("-k" , "--input_key" , type = str , default = "setup0/timepoint0/s0" , help = "Input key for n5 file." )
88- parser .add_argument ("-i" , "- -interpolation_order" , type = float , default = 3 , help = "Interpolation order." )
92+ parser .add_argument ("--interpolation_order" , type = float , default = 3 , help = "Interpolation order." )
8993
9094 args = parser .parse_args ()
9195
92- main (args .input_file , args .output_folder , args .scale , args .input_key , args .interpolation_order )
96+ main (args .input , args .output , args .scale , args .input_key , args .interpolation_order )
0 commit comments