Skip to content

Commit

Permalink
Automatic detection of XZ pixel-size anisotropy, for per-FOV labeling…
Browse files Browse the repository at this point in the history
… (ref #64 #112)
  • Loading branch information
tcompa committed Jul 21, 2022
1 parent 6e7eee6 commit 51739e7
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions fractal/tasks/image_labeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import time
from concurrent.futures import ThreadPoolExecutor

import anndata as ad
import dask
import dask.array as da
import numpy as np
Expand Down Expand Up @@ -126,8 +127,23 @@ def image_labeling(
do_3D = data_zyx.shape[0] > 1
if do_3D:
if anisotropy is None:
# Reasonable value for level 0 (for some of our UZH datasets)
anisotropy = 1.0 / 0.1625

adata = ad.read_zarr(f"{zarrurl}tables/FOV_ROI_table")
pixel_size_x = adata["pixel_size_x"][0]
pixel_size_y = adata["pixel_size_y"][0]
pixel_size_z = adata["pixel_size_z"][0]
if not np.allclose(pixel_size_x, pixel_size_y):
raise Exception(
"ERROR: XY anisotropy detected\n"
f"pixel_size_x={pixel_size_x}\n"
f"pixel_size_y={pixel_size_y}"
)
anisotropy = pixel_size_z / pixel_size_x
if labeling_level > 0:
raise NotImplementedError(
"TODO: fix automatic anisotropy "
"detection for higher levels"
)

# Check model_type
if model_type not in ["nuclei", "cyto2", "cyto"]:
Expand Down

0 comments on commit 51739e7

Please sign in to comment.