Skip to content

Commit

Permalink
Refactor NGFF module and migrate to Pydantic v2 (#233)
Browse files Browse the repository at this point in the history
* unify comment format

* fix typing and docstring

* create ngff sub-package
and refactor display util file

* refactor ngff meta file

* refactor ngff

* export transformation model

* fix type hint

* bump ome-zarr target in docstring

* migrate to pydantic v2

* isort

* fix validators

* remove union type

* fix dependency

* update docstring

* typing improvements

* Update iohub/ngff/models.py

Co-authored-by: Jordão Bragantini <[email protected]>

* fix style

* update module docstring to specify their content

---------

Co-authored-by: Jordão Bragantini <[email protected]>
  • Loading branch information
2 people authored and edyoshikun committed Jul 31, 2024
1 parent 6edd790 commit ee502b2
Show file tree
Hide file tree
Showing 12 changed files with 290 additions and 268 deletions.
3 changes: 2 additions & 1 deletion iohub/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from tqdm.contrib.logging import logging_redirect_tqdm

from iohub._version import version as iohub_version
from iohub.ngff import Position, TransformationMeta, open_ome_zarr
from iohub.ngff.models import TransformationMeta
from iohub.ngff.nodes import Position, open_ome_zarr
from iohub.reader import MMStack, NDTiffDataset, read_images

__all__ = ["TIFFConverter"]
Expand Down
4 changes: 4 additions & 0 deletions iohub/ngff/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from iohub.ngff.models import TransformationMeta
from iohub.ngff.nodes import Plate, Position, open_ome_zarr

__all__ = ["open_ome_zarr", "Plate", "Position", "TransformationMeta"]
20 changes: 11 additions & 9 deletions iohub/display_utils.py → iohub/ngff/display.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
""" Utility functions for displaying data """
"""OME-Zarr display settings (OMERO metadata)"""

import numpy as np
from PIL.ImageColor import colormap

from iohub.ngff_meta import ChannelMeta, WindowDict
from iohub.ngff.models import ChannelMeta, WindowDict

""" Dictionary with key works and most popular fluorescent probes """
CHANNEL_COLORS = {
Expand All @@ -25,8 +25,10 @@
# emission around 440 - 460 nmm
"blue": ["Blue", "DAPI", "BFP", "Hoechst"],
"red": ["Red"],
"yellow": ["Yellow", "Cy3"], # Emission around 540-570 nm
"orange": ["Orange", "Cy5", "Y5"], # emission around 650-680 nm
# Emission around 540-570 nm
"yellow": ["Yellow", "Cy3"],
# emission around 650-680 nm
"orange": ["Orange", "Cy5", "Y5"],
}


Expand All @@ -49,12 +51,12 @@ def color_to_hex(color: str) -> str:

def channel_display_settings(
chan_name: str,
clim: tuple[float, float, float, float] = None,
clim: tuple[float, float, float, float] | None = None,
first_chan: bool = False,
):
"""This will create a dictionary used for OME-zarr metadata.
Allows custom contrast limits and channel.
names for display. Defaults everything to grayscale.
"""This will create a dictionary used for OME-Zarr metadata.
Allows custom contrast limits and channel names for display.
Defaults everything to grayscale.
Parameters
----------
Expand Down Expand Up @@ -85,7 +87,7 @@ def channel_display_settings(
"S3": (-1.0, 1.0, -10.0, -10.0),
"Other": (0, U16_FMAX, 0.0, U16_FMAX),
}
if not clim:
if clim is None:
if chan_name in channel_settings.keys():
clim = channel_settings[chan_name]
else:
Expand Down
Loading

0 comments on commit ee502b2

Please sign in to comment.