diff --git a/pytools/HedwigZarrImage.py b/pytools/HedwigZarrImage.py index 3b4ba9c..19efec7 100644 --- a/pytools/HedwigZarrImage.py +++ b/pytools/HedwigZarrImage.py @@ -216,11 +216,11 @@ def neuroglancer_shader_parameters(self, mad_scale=3) -> dict: return {} if _shader_type == "Grayscale": stats = self._image_statistics(channel=None) - window = (stats["median"] - stats["mad"] * mad_scale, stats["median"] + stats["mad"] * mad_scale) - window = (max(window[0], stats["min"]), min(window[1], stats["max"])) + range = (stats["median"] - stats["mad"] * mad_scale, stats["median"] + stats["mad"] * mad_scale) + range = (max(range[0], stats["min"]), min(range[1], stats["max"])) return { - "window": [math.floor(window[0]), math.ceil(window[1])], - "range": [math.floor(stats["min"]), math.ceil(stats["max"])], + "range": [math.floor(range[0]), math.ceil(range[1])], + "window": [math.floor(stats["min"]), math.ceil(stats["max"])], } if _shader_type == "MultiChannel": @@ -249,13 +249,13 @@ def neuroglancer_shader_parameters(self, mad_scale=3) -> dict: name = re.sub(r"[^a-zA-Z0-9]+", "_", c_name.lower()) stats = self._image_statistics(channel=c) - window = (stats["median"] - stats["mad"] * mad_scale, stats["median"] + stats["mad"] * mad_scale) - window = (max(window[0], stats["min"]), min(window[1], stats["max"])) + range = (stats["median"] - stats["mad"] * mad_scale, stats["median"] + stats["mad"] * mad_scale) + range = (max(range[0], stats["min"]), min(range[1], stats["max"])) json_channel_array.append( { - "window": [math.floor(window[0]), math.ceil(window[1])], - "range": [math.floor(stats["min"]), math.ceil(stats["max"])], + "range": [math.floor(range[0]), math.ceil(range[1])], + "window": [math.floor(stats["min"]), math.ceil(stats["max"])], "name": name, "color": color_sequence[c], "channel": c, diff --git a/test/test_HedwigZarrImages.py b/test/test_HedwigZarrImages.py index b63e0a9..99e109e 100644 --- a/test/test_HedwigZarrImages.py +++ b/test/test_HedwigZarrImages.py @@ -41,7 +41,7 @@ def temp_zarr_path(request, tmp_path_factory, data_path): "XYZ", "Grayscale", "TCZYX", - {"window": [263, 413], "range": [-2664, 1677]}, + {"window": [-2664, 1677], "range": [263, 413]}, ), ("OM_P1_S1_ScanOnly_1k.zarr", "png", (1, 3, 1, 1024, 521), "XYC", "RGB", "TCZYX", {}), ("OM_P1_S1_ScanOnly_1k_tiff.zarr", "tiff", (1, 3, 1, 1024, 521), "XYC", "RGB", "TCZYX", {}),