Skip to content

Commit

Permalink
Change locations for zarr image in single image workflows
Browse files Browse the repository at this point in the history
Adds nesting for zarr file locations for single image workflows (Closes #343)
Previously, zarr directory structure was affected by `scale-format-string`
argument in bf2raw command which has been removed.

Update SEM neuroglancer metadata to new format (Closes #342)
  • Loading branch information
annshress committed Oct 5, 2023
1 parent eea099d commit 46ee92d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
10 changes: 5 additions & 5 deletions em_workflows/brt/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,16 +503,16 @@ def gen_zarr(fp_in: FilePath):
def gen_ng_metadata(fp_in: FilePath) -> Dict:
file_path = fp_in
asset_fp = Path(f"{file_path.assets_dir}/{file_path.base}.zarr")
zarr_fp = Path(f"{file_path.working_dir}/{file_path.base}.zarr")
hw_images = HedwigZarrImages(zarr_fp)
hw_images = HedwigZarrImages(asset_fp)
_, hw_image = next(hw_images.series())

first_zarr_arr = Path(asset_fp.as_posix() + "/0/0")
ng_asset = file_path.gen_asset(
asset_type=AssetType.NEUROGLANCER_ZARR, asset_fp=asset_fp
asset_type=AssetType.NEUROGLANCER_ZARR, asset_fp=first_zarr_arr
)
metadata = {
"shader": "Grayscale",
"dimensions": "XYZ",
"shader": hw_image.shader_type,
"dimensions": hw_image.dimensions,
"shaderParameters": hw_image.neuroglancer_shader_parameters(),
}
ng_asset["metadata"] = metadata
Expand Down
13 changes: 7 additions & 6 deletions em_workflows/lrg_2d_rgb/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ def gen_zarr(file_path: FilePath) -> None:

@task
def generate_ng_asset(file_path: FilePath) -> Dict:
output_zarr = Path(f"{file_path.assets_dir}/{file_path.base}.zarr")
zarr_images = HedwigZarrImages(zarr_path=output_zarr, read_only=False)
zarr_image = zarr_images[list(zarr_images.get_series_keys())[0]]
asset_fp = Path(f"{file_path.assets_dir}/{file_path.base}.zarr")
hw_images = HedwigZarrImages(zarr_path=asset_fp, read_only=False)
hw_image = hw_images[list(hw_images.get_series_keys())[0]]
first_zarr_arr = Path(asset_fp.as_posix() + "/0/0")
ng_asset = file_path.gen_asset(
asset_type=AssetType.NEUROGLANCER_ZARR, asset_fp=output_zarr
asset_type=AssetType.NEUROGLANCER_ZARR, asset_fp=first_zarr_arr
)
ng_asset["metadata"] = dict(
shader=zarr_image.shader_type,
dimensions=zarr_image.dims,
shader=hw_image.shader_type,
dimensions=hw_image.dims,
# shaderParameters=zarr_image.neuroglancer_shader_parameters()
)
return ng_asset
Expand Down
14 changes: 10 additions & 4 deletions em_workflows/sem_tomo/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Dict
from prefect import Flow, task, Parameter, unmapped
from prefect.run_configs import LocalRun
from pytools.workflow_functions import visual_min_max
from pytools.HedwigZarrImages import HedwigZarrImages

from em_workflows.utils import utils
from em_workflows.utils import neuroglancer as ng
Expand Down Expand Up @@ -234,13 +234,19 @@ def gen_zarr(fp_in: FilePath) -> None:
def gen_ng_metadata(fp_in: FilePath) -> Dict:
file_path = fp_in
asset_fp = Path(f"{file_path.assets_dir}/{file_path.base}.zarr")
output_zarr = Path(f"{file_path.assets_dir}/{file_path.base}.zarr")
hw_images = HedwigZarrImages(zarr_path=output_zarr, read_only=False)
hw_image = hw_images[list(hw_images.get_series_keys())[0]]

first_zarr_arr = Path(asset_fp.as_posix() + "/0/0")

ng_asset = file_path.gen_asset(
asset_type=AssetType.NEUROGLANCER_ZARR, asset_fp=asset_fp
asset_type=AssetType.NEUROGLANCER_ZARR, asset_fp=first_zarr_arr
)
ng_asset["metadata"] = dict(
shader=hw_image.shader_type,
dimensions=hw_image.dims,
shaderParameters=hw_image.neuroglancer_shader_parameters(),
)
ng_asset["metadata"] = visual_min_max(mad_scale=5, input_image=first_zarr_arr)
return ng_asset


Expand Down

0 comments on commit 46ee92d

Please sign in to comment.