Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
philipmac committed Sep 7, 2023
1 parent 1fb997c commit c681f3b
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions em_workflows/czi/flow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from typing import List
from typing import List, Dict
import SimpleITK as sitk
from prefect import Flow, Parameter, task
from pytools.HedwigZarrImage import HedwigZarrImage
Expand Down Expand Up @@ -46,10 +46,6 @@ def gen_imageSet(file_path: FilePath) -> List:
# we don't care about the macro image
continue
assets.append(gen_thumb(image=image, file_path=file_path))
# TODO this might be no longer needed
# if image_name == "":
# image_elt["imageName"] = f"Scene {image.ome_idx}"
# else:
image_elt["imageName"] = image_name

if image_name != "label image":
Expand Down Expand Up @@ -99,13 +95,21 @@ def bioformats_gen_zarr(file_path: FilePath):
]
FilePath.run(cmd, log_fp)
rechunk_zarr(zarr_fp=Path(output_zarr))
asset_fp = file_path.copy_to_assets_dir(fp_to_cp=Path(output_zarr))
print(asset_fp)
file_path.copy_to_assets_dir(fp_to_cp=Path(output_zarr))
imageSet = gen_imageSet(file_path=file_path)
# extract images from input file, used to create imageSet elements
return imageSet


@task
def find_thumb_idx(callback: List[Dict]) -> List[Dict]:
for elt in callback:
for i, image_elt in enumerate(elt["imageSet"]):
if image_elt["imageName"] == "label image":
elt["thumbnailIndex"] = i
return callback


with Flow(
"czi_to_zarr",
state_handlers=[utils.notify_api_completion, utils.notify_api_running],
Expand All @@ -129,9 +133,10 @@ def bioformats_gen_zarr(file_path: FilePath):
)
fps = utils.gen_fps(input_dir=input_dir_fp, fps_in=input_fps)
prim_fps = utils.gen_prim_fps.map(fp_in=fps)
zarrs = bioformats_gen_zarr.map(file_path=fps)
callback_with_zarr = utils.add_asset.map(prim_fp=prim_fps, asset=zarrs)
filtered_callback = utils.filter_results(callback_with_zarr)
imageSets = bioformats_gen_zarr.map(file_path=fps)
callback_with_zarrs = utils.add_asset.map(prim_fp=prim_fps, asset=imageSets)
callback_with_zarrs = find_thumb_idx(callback=callback_with_zarrs)
filtered_callback = utils.filter_results(callback_with_zarrs)
cb = utils.send_callback_body(
token=token, callback_url=callback_url, files_elts=filtered_callback
)
Expand Down

0 comments on commit c681f3b

Please sign in to comment.