22import json
33import math
44import os
5+ import numpy as np
56
67from deepem .utils .py_utils import vec3 , vec3f
78
@@ -28,7 +29,7 @@ def initialize(self):
2829 self .parser .add_argument ('--no_eval' , action = 'store_true' )
2930 self .parser .add_argument ('--inputsz' , type = vec3 , default = None )
3031 self .parser .add_argument ('--outputsz' , type = vec3 , default = None )
31- self .parser .add_argument ('--cropsz ' , type = vec3 , default = None )
32+ self .parser .add_argument ('--force_crop ' , type = vec3 , default = None )
3233 self .parser .add_argument ('--fov' , type = vec3 , default = None )
3334 self .parser .add_argument ('--depth' , type = int , default = 4 )
3435 self .parser .add_argument ('--width' , type = int , default = None , nargs = '+' )
@@ -115,9 +116,17 @@ def parse(self):
115116 opt .fov = tuple (opt .fov )
116117 opt .inputsz = opt .fov if opt .inputsz is None else opt .inputsz
117118 opt .outputsz = opt .fov if opt .outputsz is None else opt .outputsz
118- opt .cropsz = opt .cropsz
119119 opt .in_spec = dict (input = (1 ,) + opt .inputsz )
120120 opt .out_spec = dict ()
121+
122+ # Crop output
123+ diff = np .array (opt .fov ) - np .array (opt .outputsz )
124+ assert all (diff >= 0 )
125+ if any (diff > 0 ):
126+ opt .cropsz = opt .outputsz
127+ else :
128+ opt .cropsz = None
129+
121130 if opt .aff :
122131 opt .out_spec ['affinity' ] = (3 ,) + opt .outputsz
123132 if opt .bdr :
@@ -154,6 +163,8 @@ def parse(self):
154163 opt .scan_spec ['blood_vessel' ] = (opt .blv_num_channels ,) + opt .outputsz
155164 if opt .glia :
156165 opt .scan_spec ['glia' ] = (1 ,) + opt .outputsz
166+
167+ # Overlap & stride
157168 opt .overlap = self .get_overlap (opt .outputsz , opt .overlap )
158169 opt .stride = tuple (int (f - o ) for f ,o in zip (opt .outputsz , opt .overlap ))
159170 opt .scan_params = dict (stride = opt .stride , blend = opt .blend )
0 commit comments