Skip to content

Commit

Permalink
Merge pull request #87 from blowekamp/fix_range_window_swap
Browse files Browse the repository at this point in the history
Swap the range and window values
  • Loading branch information
blowekamp authored Oct 4, 2023
2 parents 9df62a1 + 27551c5 commit 926f45d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions pytools/HedwigZarrImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/test_HedwigZarrImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", {}),
Expand Down

0 comments on commit 926f45d

Please sign in to comment.