Commit 1b1c9ca0 authored by Christoph Sommer's avatar Christoph Sommer

added handling of 2D and 3D at the same time

Old .json config file need to changed (or re-converted)

* add: "axes": "YX" or "axes": "ZYX"
* make sure "patch_size": [...] has len 2  or 3
parent d5e2f266
......@@ -42,11 +42,9 @@ class BifCareInputConverter(object):
if loci_pixel_type == 1:
# uint8
dtype = numpy.uint8
print(" -- Pixel-type 8-bit")
elif loci_pixel_type == 3:
# uint16
dtype = numpy.uint16
print(" -- Pixel-type 16-bit")
else:
print(" -- Error: Pixel-type not supported. Pixel type must be 8- or 16-bit")
return
......@@ -107,12 +105,12 @@ class BifCareTrainer(object):
basepath = pathlib.Path(self.out_dir) / "train_data" / "raw" / "CH_{}".format(ch),
source_dirs = ['low'],
target_dir = 'GT',
axes = 'YX',
axes = self.axes,
)
X, Y, XY_axes = create_patches (
raw_data = raw_data,
patch_size = self.patch_size[1:],
patch_size = self.patch_size,
n_patches_per_image = self.n_patches_per_image,
save_file = self.get_training_patch_path() / 'CH_{}_training_patches.npz'.format(ch),
verbose = False,
......
......@@ -40,6 +40,7 @@ class GuiParams(dict):
self["out_dir"] = "."
self["low_wc"] = ""
self["high_wc"] = ""
self["axes"] = "ZYX"
self['patch_size'] = [16, 64, 64]
self['n_patches_per_image'] = 128
self["train_channels"] = [0]
......@@ -159,6 +160,17 @@ def select_input():
else:
params["low_scaling"] = get_upscale_factors(params["in_dir"], params["low_wc"], params["high_wc"])
z_dim = get_pixel_dimensions(get_file_list(params["in_dir"], params["low_wc"])[0]).z
if z_dim == 1:
print("2d")
params["axes"] = "YX"
else:
print("3d")
params["axes"] = "ZYX"
if (numpy.array(params["low_scaling"]) == 1).all():
text_convert_repy.value = "Low quality images match high quality resolution"
else:
......@@ -209,8 +221,9 @@ def select_patch_parameter():
####################
patch_size_select = []
patch_options = [8, 16, 32, 64, 128, 256]
for j, a in enumerate(['Z', 'Y', 'X']):
for j, a in enumerate(list(params["axes"])):
wi = widgets.Dropdown(options=list(map(str, patch_options)),
value=str(params['patch_size'][j]),
desciption=a,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment