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
1 change: 1 addition & 0 deletions ngff_zarr/from_ngff_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def from_ngff_zarr(
channels=[
OmeroChannel(
color=channel["color"],
label=channel.get("label", None),
window=OmeroWindow(
min=channel["window"]["min"],
max=channel["window"]["max"],
Expand Down
1 change: 1 addition & 0 deletions ngff_zarr/v04/zarr_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class OmeroWindow:
class OmeroChannel:
color: str
window: OmeroWindow
label: Optional[str] = None

def validate_color(self):
if not re.fullmatch(r"[0-9A-Fa-f]{6}", self.color):
Expand Down
10 changes: 10 additions & 0 deletions test/test_omero.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,47 @@ def test_read_omero(input_images): # noqa: ARG001
assert omero.channels[0].window.max == 65535.0
assert omero.channels[0].window.start == 0.0
assert omero.channels[0].window.end == 1200.0
assert omero.channels[0].label == "cy 1"

# Channel 1
assert omero.channels[1].color == "FFFFFF"
assert omero.channels[1].window.min == 0.0
assert omero.channels[1].window.max == 65535.0
assert omero.channels[1].window.start == 0.0
assert omero.channels[1].window.end == 1200.0
assert omero.channels[1].label == "cy 2"

# Channel 2
assert omero.channels[2].color == "FFFFFF"
assert omero.channels[2].window.min == 0.0
assert omero.channels[2].window.max == 65535.0
assert omero.channels[2].window.start == 0.0
assert omero.channels[2].window.end == 1200.0
assert omero.channels[2].label == "cy 3"

# Channel 3
assert omero.channels[3].color == "FFFFFF"
assert omero.channels[3].window.min == 0.0
assert omero.channels[3].window.max == 65535.0
assert omero.channels[3].window.start == 0.0
assert omero.channels[3].window.end == 1200.0
assert omero.channels[3].label == "cy 4"

# Channel 4
assert omero.channels[4].color == "0000FF"
assert omero.channels[4].window.min == 0.0
assert omero.channels[4].window.max == 65535.0
assert omero.channels[4].window.start == 0.0
assert omero.channels[4].window.end == 5000.0
assert omero.channels[4].label == "DAPI"

# Channel 5
assert omero.channels[5].color == "FF0000"
assert omero.channels[5].window.min == 0.0
assert omero.channels[5].window.max == 65535.0
assert omero.channels[5].window.start == 0.0
assert omero.channels[5].window.end == 100.0
assert omero.channels[5].label == "Hyb probe"


def test_write_omero():
Expand All @@ -76,10 +82,12 @@ def test_write_omero():
OmeroChannel(
color="008000",
window=OmeroWindow(min=0.0, max=255.0, start=10.0, end=150.0),
label="Phalloidin",
),
OmeroChannel(
color="0000FF",
window=OmeroWindow(min=0.0, max=255.0, start=30.0, end=200.0),
label="",
),
]
)
Expand All @@ -97,9 +105,11 @@ def test_write_omero():
assert read_omero.channels[0].color == "008000"
assert read_omero.channels[0].window.start == 10.0
assert read_omero.channels[0].window.end == 150.0
assert read_omero.channels[0].label == "Phalloidin"
assert read_omero.channels[1].color == "0000FF"
assert read_omero.channels[1].window.start == 30.0
assert read_omero.channels[1].window.end == 200.0
assert read_omero.channels[1].label == ""


def test_validate_color():
Expand Down
Loading