-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First version of metadata parsing in create_zarr_structure (ref #112)
- Loading branch information
Showing
2 changed files
with
82 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import anndata as ad | ||
import numpy as np | ||
|
||
|
||
def prepare_ROIs_table(df, image_size=None): | ||
if image_size is None: | ||
raise Exception("Missing image_size arg in prepare_ROIs_table") | ||
|
||
df["x_micrometer"] -= df["x_micrometer"].min() | ||
df["y_micrometer"] -= df["y_micrometer"].min() | ||
df["z_micrometer"] -= df["z_micrometer"].min() | ||
|
||
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"] = df["pixel_size_z"] | ||
|
||
df.drop("bit_depth", inplace=True, axis=1) | ||
|
||
df = df.astype(np.float32) | ||
|
||
adata = ad.AnnData(X=df, dtype=np.float32) | ||
adata.obs_names = [f"FOV_{i+1:d}" for i in range(len(df.index))] | ||
adata.var_names = df.columns | ||
|
||
return adata |