Skip to content

Commit

Permalink
minor bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzocerrone committed Nov 14, 2024
1 parent e4c2bf0 commit 97e7682
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
18 changes: 9 additions & 9 deletions docs/notebooks/basic_usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"print(ngff_image)\n",
"image = ngff_image.get_image()\n",
"print(image)\n",
"nuclei = ngff_image.label.get_label(\"nuclei\")\n",
"nuclei = ngff_image.labels.get_label(\"nuclei\")\n",
"print(nuclei)\n"
]
},
Expand Down Expand Up @@ -106,9 +106,9 @@
"metadata": {},
"outputs": [],
"source": [
"print(\"List of Labels: \", ngff_image.label.list())\n",
"print(\"List of Labels: \", ngff_image.labels.list())\n",
"\n",
"label_nuclei = ngff_image.label.get_label(\"nuclei\", path=\"0\")\n",
"label_nuclei = ngff_image.labels.get_label(\"nuclei\", path=\"0\")\n",
"print(f\"{label_nuclei.shape=}\")\n",
"print(f\"{label_nuclei.pixel_size=}\")"
]
Expand All @@ -133,10 +133,10 @@
"metadata": {},
"outputs": [],
"source": [
"print(\"List of Tables: \", ngff_image.table.list())\n",
"print(\" - Feature tables: \", ngff_image.table.list(table_type='feature_table'))\n",
"print(\" - Roi tables: \", ngff_image.table.list(table_type='roi_table'))\n",
"print(\" - Masking Roi tables: \", ngff_image.table.list(table_type='masking_roi_table'))"
"print(\"List of Tables: \", ngff_image.tables.list())\n",
"print(\" - Feature tables: \", ngff_image.tables.list(table_type='feature_table'))\n",
"print(\" - Roi tables: \", ngff_image.tables.list(table_type='roi_table'))\n",
"print(\" - Masking Roi tables: \", ngff_image.tables.list(table_type='masking_roi_table'))"
]
},
{
Expand All @@ -146,7 +146,7 @@
"outputs": [],
"source": [
"# Loading a table\n",
"feature_table = ngff_image.table.get_table(\"regionprops_DAPI\")\n",
"feature_table = ngff_image.tables.get_table(\"regionprops_DAPI\")\n",
"feature_table.table"
]
},
Expand All @@ -157,7 +157,7 @@
"outputs": [],
"source": [
"# Loading a roi table\n",
"roi_table = ngff_image.table.get_table(\"FOV_ROI_table\")\n",
"roi_table = ngff_image.tables.get_table(\"FOV_ROI_table\")\n",
"\n",
"print(f\"{roi_table.field_indexes=}\")\n",
"print(f\"{roi_table.get_roi('FOV_1')=}\")\n",
Expand Down
11 changes: 9 additions & 2 deletions docs/notebooks/image.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -294,17 +294,24 @@
"feat_df = pd.DataFrame.from_records(list_of_records)\n",
"\n",
"# Create a new feature table\n",
"feat_table = ngff_image.table.new(name='new_feature_table',\n",
"feat_table = ngff_image.tables.new(name='new_feature_table',\n",
" label_image='../nuclei',\n",
" table_type='feature_table',\n",
" overwrite=True)\n",
"\n",
"print(f\"New list of feature table: {ngff_image.table.list(table_type='feature_table')}\")\n",
"print(f\"New list of feature table: {ngff_image.tables.list(table_type='feature_table')}\")\n",
"feat_table.set_table(feat_df)\n",
"feat_table.consolidate()\n",
"\n",
"feat_table.table"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
8 changes: 4 additions & 4 deletions docs/notebooks/processing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"print(\"MIP image loaded with shape:\", mip_image.shape)\n",
"\n",
"# Get a ROI table\n",
"roi_table = ngff_image.table.get_table(\"FOV_ROI_table\")\n",
"roi_table = ngff_image.tables.get_table(\"FOV_ROI_table\")\n",
"print(\"ROI table loaded with\", len(roi_table.rois), \"ROIs\")\n",
"\n",
"# For each ROI in the table\n",
Expand Down Expand Up @@ -157,7 +157,7 @@
"metadata": {},
"outputs": [],
"source": [
"mip_roi_table = mip_ngff.table.new(\"FOV_ROI_table\", overwrite=True)\n",
"mip_roi_table = mip_ngff.tables.new(\"FOV_ROI_table\", overwrite=True)\n",
"\n",
"roi_list = []\n",
"for roi in roi_table.rois:\n",
Expand Down Expand Up @@ -221,7 +221,7 @@
"metadata": {},
"outputs": [],
"source": [
"nuclei_image = mip_ngff.label.derive(name=\"nuclei\", overwrite=True)"
"nuclei_image = mip_ngff.labels.derive(name=\"nuclei\", overwrite=True)"
]
},
{
Expand All @@ -242,7 +242,7 @@
"print(\"Source image loaded with shape:\", source_image.shape)\n",
"\n",
"# Get a ROI table\n",
"roi_table = mip_ngff.table.get_table(\"FOV_ROI_table\")\n",
"roi_table = mip_ngff.tables.get_table(\"FOV_ROI_table\")\n",
"print(\"ROI table loaded with\", len(roi_table.rois), \"ROIs\")\n",
"\n",
"# Find the DAPI channel\n",
Expand Down
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,12 @@ skip-magic-trailing-comma = false # default is false
[tool.mypy]
files = "src/**/"
strict = true
ignore_missing_imports = true
disallow_any_generics = false
disallow_subclassing_any = false
show_error_codes = true
pretty = true

# # module specific overrides
[[tool.mypy.overrides]]
module = ["numpy.*", "dask.*", "zarr.*"]
ignore_errors = true

# https://docs.pytest.org/
[tool.pytest.ini_options]
minversion = "7.0"
Expand Down
6 changes: 5 additions & 1 deletion src/ngio/core/image_like_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from ngio.core.dimensions import Dimensions
from ngio.core.roi import WorldCooROI
from ngio.core.utils import Lock
from ngio.io import AccessModeLiteral, StoreOrGroup, open_group_wrapper
from ngio.ngff_meta import (
Dataset,
Expand All @@ -23,6 +22,11 @@
from ngio.utils import ngio_logger
from ngio.utils._common_types import ArrayLike

try:
from dask.distributed import Lock
except ImportError:
Lock = None # type: ignore


class ImageLike:
"""A class to handle OME-NGFF images stored in Zarr format.
Expand Down

0 comments on commit 97e7682

Please sign in to comment.