Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = { file = "LICENSE" }
authors = [
{ name = "CZ Biohub SF and napari-iohub contributors", email = "[email protected]" },
]
dependencies = ["iohub>=0.1.0", "magicgui", "qtpy"]
dependencies = ["iohub>=0.1.0", "dask>=2024.12.0", "magicgui", "qtpy"]
dynamic = ["version"]
classifiers = [
"Development Status :: 2 - Pre-Alpha",
Expand Down
16 changes: 14 additions & 2 deletions src/napari_iohub/_cell_state_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,17 @@
_logger = logging.getLogger(__name__)

# Index columns for ultrack-compatible CSV output
INDEX_COLUMNS = ["fov_name", "track_id", "t", "z", "y", "x"]
ULTRACK_INDEX_COLUMNS = [
"fov_name",
"track_id",
"t",
"id",
"parent_track_id",
"parent_id",
"z",
"y",
"x",
]

# Annotation layer definitions
ANNOTATION_LAYERS = [
Expand Down Expand Up @@ -748,7 +758,9 @@ def _save_annotations(self) -> None:
)

# Reorder columns
index_cols = [col for col in INDEX_COLUMNS if col in merged_df.columns]
index_cols = [
col for col in ULTRACK_INDEX_COLUMNS if col in merged_df.columns
]
annotation_cols = [
"cell_division_state",
"infection_state",
Expand Down
33 changes: 8 additions & 25 deletions src/napari_iohub/_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ def _get_node(path: StrOrBytesPath):
zgroup.store.close()
node = open_ome_zarr(store_path=path, 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 @@ -121,9 +119,7 @@ def _get_multiscales(pos: Position):
try:
multiscales.append(pos[im].dask_array())
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 All @@ -144,13 +140,8 @@ def _ome_to_napari_by_channel(
):
if metadata.omero is None:
if num_channels is None:
raise ValueError(
"num_channels must be set when omero is not present"
)
return [
{"name": f"{i}", "blending": "additive"}
for i in range(num_channels)
]
raise ValueError("num_channels must be set when omero is not present")
return [{"name": f"{i}", "blending": "additive"} for i in range(num_channels)]
omero: OMEROMeta = metadata.omero
layers_kwargs = []
for channel in omero.channels:
Expand Down Expand Up @@ -221,13 +212,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 @@ -258,9 +245,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 @@ -300,9 +285,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 Down
6 changes: 3 additions & 3 deletions src/napari_iohub/_tests/test_cell_state_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from napari_iohub._cell_state_annotator import (
ANNOTATION_LAYERS,
INDEX_COLUMNS,
ULTRACK_INDEX_COLUMNS,
CellStateAnnotatorWidget,
)

Expand All @@ -30,8 +30,8 @@ def test_annotation_layers_constant():

def test_index_columns_constant():
"""Test that index columns match ultrack expectations."""
expected = ["fov_name", "track_id", "t", "z", "y", "x"]
assert INDEX_COLUMNS == expected
expected = ["fov_name", "track_id", "t", "id", "parent_track_id", "parent_id", "z", "y", "x"]
assert ULTRACK_INDEX_COLUMNS == expected


def test_state_expansion_logic():
Expand Down