Skip to content

Commit

Permalink
remove fused toplevel group
Browse files Browse the repository at this point in the history
  • Loading branch information
akhanf committed Feb 14, 2024
1 parent cb08829 commit 521db82
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions workflow/scripts/ome_zarr_to_nii.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

zi = zarr.open(in_zarr)

attrs=zi['fused'].attrs.asdict()
attrs=zi['/'].attrs.asdict()

level=int(snakemake.wildcards.level)

Expand All @@ -25,7 +25,7 @@
affine[1,1]=-transforms[0]['scale'][1] #y
affine[2,2]=-transforms[0]['scale'][0] #x

darr = da.from_zarr(in_zarr,component=f'fused/{level}')
darr = da.from_zarr(in_zarr,component=f'/{level}')

#input array axes are ZYX
#writing to nifti we want XYZ
Expand Down
6 changes: 4 additions & 2 deletions workflow/scripts/resample_labels_to_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
in_template_dseg=snakemake.input.dseg
out_zarr=snakemake.output.zarr

level=0

#load dask array from zarr reference image
darr = da.from_zarr(in_zarr,component='fused/0')
darr = da.from_zarr(in_zarr,component=f'/{level}')

#load template dseg
dseg_nib = nib.load(in_template_dseg)
Expand All @@ -30,7 +32,7 @@

#read coordinate transform from ome-zarr
zi = zarr.open(in_zarr)
attrs=zi['fused'].attrs.asdict()
attrs=zi['/'].attrs.asdict()
level=0
transforms = attrs['multiscales'][0]['datasets'][level]['coordinateTransformations']

Expand Down
5 changes: 4 additions & 1 deletion workflow/scripts/zarr_to_ome_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import zarr
import dask.array as da
from ome_zarr.writer import write_image
from ome_zarr.format import format_from_version
from ome_zarr.scale import Scaler
from dask.diagnostics import ProgressBar

Expand Down Expand Up @@ -45,7 +46,7 @@


store = zarr.DirectoryStore(out_zarr)
root = zarr.group(store,path='/fused',overwrite=True)
root = zarr.group(store,path='/',overwrite=True)
scaler = Scaler(max_layer=max_layer,method=scaling_method)


Expand All @@ -55,6 +56,8 @@
group=root,
scaler=scaler,
coordinate_transformations=coordinate_transformations,
#fmt=format_from_version(0.1),
# fmt=format_from_version(0.4),
axes=axes)


0 comments on commit 521db82

Please sign in to comment.