Skip to content

Commit

Permalink
Modify ambiguous naming of well_size (ref #113)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcompa committed Jul 21, 2022
1 parent 12e267e commit d5ed1c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions fractal/tasks/create_zarr_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ def create_zarr_structure(
mrf_path, mlf_path
)
# FIXME: hardcoded
well_size = {"x": 2560, "y": 2160, "z": 10}
image_size = {"x": 2560, "y": 2160}
well_size_z = 10

# Extract pixel sizes
pixel_size_z = site_metadata["pixel_size_z"][0]
Expand Down Expand Up @@ -347,7 +348,8 @@ def create_zarr_structure(
# Prepare and write anndata table of FOV ROIs
FOV_ROIs_table = prepare_FOV_ROI_table(
site_metadata.loc[f"{row+column}"],
well_size=well_size,
image_size=image_size,
well_size_z=well_size_z,
)
group_tables = group_FOV.create_group("tables/") # noqa: F841
write_elem(group_tables, "FOV_ROI_table", FOV_ROIs_table)
Expand Down
16 changes: 10 additions & 6 deletions fractal/tasks/lib_regions_of_interest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@

def prepare_FOV_ROI_table(
df: pd.DataFrame,
well_size: Union[Dict, None] = None,
image_size: Union[Dict, None] = None,
well_size_z: int = None,
) -> ad.AnnData:
if well_size is None:
raise Exception("Missing well_size arg in prepare_ROIs_table")

if image_size is None:
raise Exception("Missing image_size arg in prepare_ROIs_table")
if well_size_z is None:
raise Exception("Missing well_size_z arg in prepare_ROIs_table")

# Reset reference values for coordinates
df["x_micrometer"] -= df["x_micrometer"].min()
df["y_micrometer"] -= df["y_micrometer"].min()
df["z_micrometer"] -= df["z_micrometer"].min()

# Obtain box size in physical units
df["len_x_micrometer"] = well_size["x"] * df["pixel_size_x"]
df["len_y_micrometer"] = well_size["y"] * df["pixel_size_y"]
df["len_z_micrometer"] = well_size["z"] * df["pixel_size_z"]
df["len_x_micrometer"] = image_size["x"] * df["pixel_size_x"]
df["len_y_micrometer"] = image_size["y"] * df["pixel_size_y"]
df["len_z_micrometer"] = well_size_z * df["pixel_size_z"]

# Remove unused column
df.drop("bit_depth", inplace=True, axis=1)
Expand Down

0 comments on commit d5ed1c5

Please sign in to comment.