From 8f074f6ade25e74c69d4c23531f832ab0b0a3268 Mon Sep 17 00:00:00 2001 From: Daniel Eddie Rollins Date: Thu, 15 Jan 2026 00:32:02 +0000 Subject: [PATCH 1/4] add playnano entry points to pyproject.toml for pluginability. Alos removed matplotlib from dependancies and added setuptool_smc to dev optional dependancies. --- pyproject.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 024adad..35d874a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,6 @@ requires-python = ">=3.11" dependencies = [ "numpy", "scipy", - "matplotlib", "ruptures", "sknw", "scikit-image>=0.26,<0.27", @@ -67,6 +66,7 @@ classifiers = [ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Scientific/Engineering :: Image Processing", ] @@ -81,11 +81,17 @@ dev = [ "codespell>=2.3.0", "mypy==1.11.1", "nbstripout", + "setuptools_scm", ] [project.urls] Homepage = "https://github.com/derollins/Python-Nanolocz-Library" +[project.entry-points."playnano.filters"] +pnanolocz_level = "pnanolocz_lib.level:apply_level" +pnanolocz_level_weighted = "pnanolocz_lib.level_weighted:apply_level_weighted" +pnanolocz_level_auto = "pnanolocz_lib.level_auto:apply_level_auto" + [tool.setuptools] package-dir = { "" = "src" } From 59350da1e23d45c3004e9e5134ccd65105209c43 Mon Sep 17 00:00:00 2001 From: Daniel Eddie Rollins Date: Thu, 15 Jan 2026 00:35:25 +0000 Subject: [PATCH 2/4] Add method dependant defaults to apply_level to make playNano CLI calls easier. --- src/pnanolocz_lib/level.py | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/pnanolocz_lib/level.py b/src/pnanolocz_lib/level.py index 251a068..fa3dcba 100644 --- a/src/pnanolocz_lib/level.py +++ b/src/pnanolocz_lib/level.py @@ -779,8 +779,8 @@ def _log_model( def apply_level( img: np.ndarray[Any, np.dtype[np.float64]], - polyx: int, - polyy: int, + polyx: int = None, + polyy: int = None, method: Literal[ "plane", "line", @@ -789,7 +789,7 @@ def apply_level( "smed_line", "mean_plane", "log_y", - ], + ] = "plane", mask: Optional[np.ndarray[Any, np.dtype[np.bool_]]] = None, ) -> np.ndarray[Any, np.dtype[np.float64]]: """ @@ -814,7 +814,7 @@ def apply_level( Use ``0`` to disable polynomial fitting along Y where applicable. method : {"plane", "line", "med_line", "med_line_y", "smed_line", "mean_plane", "log_y"} - Leveling method to apply. + Leveling method to apply. Defaults to ``"plane"``. mask : ndarray of bool, optional Exclusion mask with the same shape as `img` (after any single-image promotion to ``(1, H, W)``). @@ -865,18 +865,46 @@ def apply_level( frame_mask = mask[idx] if mask is not None else None if method == "plane": + if polyx is None: + polyx = 1 + if polyy is None: + polyy = 1 leveled = level_plane(frame, frame_mask, polyx, polyy) elif method == "line": + if polyx is None: + polyx = 1 + if polyy is None: + polyy = 0 leveled = level_line(frame, frame_mask, polyx, polyy) elif method == "med_line": + if polyx is None: + polyx = 1 + if polyy is None: + polyy = 0 leveled = level_med_line(frame, frame_mask, polyx, polyy) elif method == "med_line_y": + if polyx is None: + polyx = 0 + if polyy is None: + polyy = 0 leveled = level_med_line_y(frame, frame_mask, polyx, polyy) elif method == "smed_line": + if polyx is None: + polyx = 0 + if polyy is None: + polyy = 0 leveled = level_smed_line(frame, frame_mask, polyx, polyy) elif method == "mean_plane": + if polyx is None: + polyx = 0 + if polyy is None: + polyy = 0 leveled = level_mean_plane(frame, frame_mask, polyx, polyy) elif method == "log_y": + if polyx is None: + polyx = 0 + if polyy is None: + polyy = 1 leveled = level_log_y(frame, frame_mask, polyx, polyy) else: raise ValueError(f"Unknown leveling method: {method}") From 4d5956a0f0d8e90240c04f422dc8fc32d970d76e Mon Sep 17 00:00:00 2001 From: Daniel Eddie Rollins Date: Fri, 16 Jan 2026 14:44:44 +0000 Subject: [PATCH 3/4] Remove level_weighted plugin entry point for playnano since it can't see masks when used. --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 35d874a..facb65a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,7 +89,6 @@ Homepage = "https://github.com/derollins/Python-Nanolocz-Library" [project.entry-points."playnano.filters"] pnanolocz_level = "pnanolocz_lib.level:apply_level" -pnanolocz_level_weighted = "pnanolocz_lib.level_weighted:apply_level_weighted" pnanolocz_level_auto = "pnanolocz_lib.level_auto:apply_level_auto" [tool.setuptools] From 193ba0cc3cddd497cbdcfcadccca990172c91a7f Mon Sep 17 00:00:00 2001 From: Daniel Eddie Rollins Date: Fri, 16 Jan 2026 14:59:28 +0000 Subject: [PATCH 4/4] Fix typing (mypy) --- src/pnanolocz_lib/level.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pnanolocz_lib/level.py b/src/pnanolocz_lib/level.py index fa3dcba..c56c05f 100644 --- a/src/pnanolocz_lib/level.py +++ b/src/pnanolocz_lib/level.py @@ -779,8 +779,8 @@ def _log_model( def apply_level( img: np.ndarray[Any, np.dtype[np.float64]], - polyx: int = None, - polyy: int = None, + polyx: Optional[int] = None, + polyy: Optional[int] = None, method: Literal[ "plane", "line",