Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update .zattrs file and test result #20

Merged
merged 4 commits into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 37 additions & 39 deletions linc_convert/modalities/df/multi_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def convert(
inp: list[str],
out: str | None = None,
*,
chunk: int = 4096,
chunk: int = 1024,
compressor: str = "blosc",
compressor_opt: str = "{}",
max_load: int = 16384,
Expand Down Expand Up @@ -131,7 +131,7 @@ def convert(
new_width = jp2.shape[1]
new_size = (new_height, new_width)
if has_channel:
new_size += (3.0,)
new_size += (3,)
print(len(inp), new_size, nblevel, has_channel)

# Prepare chunking options
Expand Down Expand Up @@ -174,43 +174,41 @@ def convert(
x = floordiv(shape[-2] - subdat_size[-2], 2)
y = floordiv(shape[-1] - subdat_size[-1], 2)

if max_load is None or (shape[-2] < max_load and shape[-1] < max_load):
array[..., idx, x : x + subdat_size[1], y : y + subdat_size[2]] = (
subdat[...]
)

else:
ni = ceildiv(shape[-2], max_load)
nj = ceildiv(shape[-1], max_load)

for i in range(ni):
for j in range(nj):
print(f"\r{i+1}/{ni}, {j+1}/{nj}", end=" ")
start_x, end_x = (
i * max_load,
min((i + 1) * max_load, shape[-2]),
)
start_y, end_y = (
j * max_load,
min((j + 1) * max_load, shape[-1]),
)
if end_x <= x or end_y <= y:
continue

if start_x >= subdat_size[-2] or start_y >= subdat_size[-1]:
continue

array[
...,
idx,
x + start_x : x + min(end_x, subdat_size[-2]),
y + start_y : y + min(end_y, subdat_size[-1]),
] = subdat[
...,
start_x : min((i + 1) * max_load, subdat_size[-2]),
start_y : min((j + 1) * max_load, subdat_size[-1]),
]
print("")
for channel in range(3):
if max_load is None or (
subdat_size[-2] < max_load and subdat_size[-1] < max_load
):
array[
channel, idx, x : x + subdat_size[-2], y : y + subdat_size[-1]
] = subdat[channel : channel + 1, ...][0]
jingjingwu1225 marked this conversation as resolved.
Show resolved Hide resolved
else:
ni = ceildiv(subdat_size[-2], max_load)
nj = ceildiv(subdat_size[-1], max_load)

for i in range(ni):
for j in range(nj):
print(f"\r{i+1}/{ni}, {j+1}/{nj}", end=" ")
start_x, end_x = (
i * max_load,
min((i + 1) * max_load, subdat_size[-2]),
)
start_y, end_y = (
j * max_load,
min((j + 1) * max_load, subdat_size[-1]),
)

array[
channel,
idx,
x + start_x : x + end_x,
y + start_y : y + end_y,
] = subdat[
channel : channel + 1,
start_x:end_x,
start_y:end_y,
][0]

print("")

# Write OME-Zarr multiscale metadata
print("Write metadata")
Expand Down
Loading