Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ziw-liu committed Sep 2, 2024
1 parent cc4e236 commit 0fd9df5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/napari_iohub/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging
import os

from ._reader import napari_get_reader
from ._widget import MainWidget
from ._edit_labels import EditLabelsWidget
from ._reader import napari_get_reader
from ._view_tracks import open_image_and_tracks
from ._widget import MainWidget

__all__ = (
"napari_get_reader",
Expand Down
2 changes: 1 addition & 1 deletion src/napari_iohub/_edit_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from pathlib import Path
from typing import TYPE_CHECKING

from napari import Viewer
import numpy as np
from iohub.ngff import Plate, Position, Row, Well, open_ome_zarr
from napari import Viewer
from qtpy.QtWidgets import (
QFileDialog,
QFormLayout,
Expand Down
30 changes: 8 additions & 22 deletions src/napari_iohub/_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
MultiScaleMeta,
NGFFNode,
OMEROMeta,
Plate,
Position,
Well,
Plate,
_open_store,
open_ome_zarr,
)
Expand Down Expand Up @@ -69,9 +69,7 @@ def _get_node(path: StrOrBytesPath):
zgroup.store.close()
node = open_ome_zarr(store_path=path, layout="hcs", mode="r")
else:
raise KeyError(
f"NGFF plate or well metadata not found under '{zgroup.name}'"
)
raise KeyError(f"NGFF plate or well metadata not found under '{zgroup.name}'")
return node


Expand Down Expand Up @@ -118,9 +116,7 @@ def _get_multiscales(pos: Position):
try:
multiscales.append(da.from_zarr(pos[im]))
except Exception as e:
logging.warning(
f"Skipped array '{im}' at position {pos.zgroup.name}: {e}"
)
logging.warning(f"Skipped array '{im}' at position {pos.zgroup.name}: {e}")
return len(multiscales), multiscales


Expand Down Expand Up @@ -202,13 +198,9 @@ def fov_to_layers(fov: Position, layer_type: str = "image"):
)


def well_to_layers(
well: Well, mode: Literal["stitch", "stack"], layer_type: str
):
def well_to_layers(well: Well, mode: Literal["stitch", "stack"], layer_type: str):
if mode == "stitch":
layers_kwargs, ch_axis, arrays = stitch_well_by_channel(
well, row_wrap=4
)
layers_kwargs, ch_axis, arrays = stitch_well_by_channel(well, row_wrap=4)
elif mode == "stack":
layers_kwargs, ch_axis, arrays = stack_well_by_position(well)
return layers_from_arrays(
Expand Down Expand Up @@ -239,9 +231,7 @@ def make_bbox(bbox_extents):
maxr = bbox_extents[2]
maxc = bbox_extents[3]

bbox_rect = np.array(
[[minr, minc], [maxr, minc], [maxr, maxc], [minr, maxc]]
)
bbox_rect = np.array([[minr, minc], [maxr, minc], [maxr, maxc], [minr, maxc]])
bbox_rect = np.moveaxis(bbox_rect, 2, 0)

return bbox_rect
Expand Down Expand Up @@ -281,9 +271,7 @@ def plate_to_layers(
]
for k in range(len(boxes)):
boxes[k].append(box_extents[k] - 0.5)
properties["fov"].append(
well_path + "/" + next(well.positions())[0]
)
properties["fov"].append(well_path + "/" + next(well.positions())[0])
else:
row_arrays.append(None)
plate_arrays.append(row_arrays)
Expand All @@ -296,9 +284,7 @@ def plate_to_layers(
row_level = []
for c in r:
if c is None:
arr = da.zeros(
shape=fill_args[level][0], dtype=fill_args[level][1]
)
arr = da.zeros(shape=fill_args[level][0], dtype=fill_args[level][1])
else:
arr = c[level]
row_level.append(arr)
Expand Down

0 comments on commit 0fd9df5

Please sign in to comment.