Skip to content

Commit

Permalink
style fixes by ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
balbasty authored and github-actions[bot] committed Nov 22, 2024
1 parent 7ecfc08 commit 3611911
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions linc_convert/modalities/psoct/single_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ def _mapmat(fname: str, key: str = None) -> None:
if not len(f.keys()):
raise Exception(f"{fname} is empty")
for key in f.keys():
if key[:1] != '_':
if key[:1] != "_":
break
if len(f.keys()) > 1:
warn(f'More than one key in .mat file {fname}, '
f'arbitrarily loading "{key}"')
warn(
f"More than one key in .mat file {fname}, "
f'arbitrarily loading "{key}"'
)

if key not in f.keys():
raise Exception(f"Key {key} not found in file {fname}")
Expand Down Expand Up @@ -174,9 +176,7 @@ def convert(
ni = ceildiv(inp.shape[2], inp_chunk[2])

nblevels = min(
[int(math.ceil(math.log2(x)))
for i, x in enumerate(inp.shape)
if i != no_pool]
[int(math.ceil(math.log2(x))) for i, x in enumerate(inp.shape) if i != no_pool]
)
nblevels = min(nblevels, int(math.ceil(math.log2(max_load))))
nblevels = min(nblevels, max_levels)
Expand All @@ -188,9 +188,9 @@ def convert(
# iterate across input chunks
for i, j, k in product(range(ni), range(nj), range(nk)):
loaded_chunk = inp[
k * inp_chunk[0]: (k + 1) * inp_chunk[0],
j * inp_chunk[1]: (j + 1) * inp_chunk[1],
i * inp_chunk[2]: (i + 1) * inp_chunk[2],
k * inp_chunk[0] : (k + 1) * inp_chunk[0],
j * inp_chunk[1] : (j + 1) * inp_chunk[1],
i * inp_chunk[2] : (i + 1) * inp_chunk[2],
]

print(
Expand All @@ -203,9 +203,9 @@ def convert(

# save current chunk
omz["0"][
k * inp_chunk[0]: k * inp_chunk[0] + loaded_chunk.shape[0],
j * inp_chunk[1]: j * inp_chunk[1] + loaded_chunk.shape[1],
i * inp_chunk[2]: i * inp_chunk[2] + loaded_chunk.shape[2],
k * inp_chunk[0] : k * inp_chunk[0] + loaded_chunk.shape[0],
j * inp_chunk[1] : j * inp_chunk[1] + loaded_chunk.shape[1],
i * inp_chunk[2] : i * inp_chunk[2] + loaded_chunk.shape[2],
] = loaded_chunk

generate_pyramid(omz, nblevels - 1, mode="mean")
Expand All @@ -222,9 +222,7 @@ def convert(
no_pool=no_pool,
space_unit=ome_unit,
space_scale=vx,
multiscales_type=(
("2x2x2" if no_pool is None else "2x2") + "mean window"
),
multiscales_type=(("2x2x2" if no_pool is None else "2x2") + "mean window"),
)

if not nii:
Expand All @@ -240,6 +238,5 @@ def convert(
if center:
affine = center_affine(affine, shape[:3])
niftizarr_write_header(
omz, shape, affine, omz["0"].dtype, to_nifti_unit(unit),
nifti_version=2
omz, shape, affine, omz["0"].dtype, to_nifti_unit(unit), nifti_version=2
)

0 comments on commit 3611911

Please sign in to comment.