From a3da7e67229c7f48ca0c4caf055ead31d71df6f4 Mon Sep 17 00:00:00 2001 From: Bengt Ljungquist Date: Thu, 8 Aug 2024 14:46:27 -0400 Subject: [PATCH 1/6] Added units, doc for alternate version --- README.md | 13 +++++++++++++ README_short.md | 14 ++++++++++---- src/microjson/model.py | 8 ++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index db2ba71..d5417a2 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ MicroJSON is a JSON-based format inspired by [GeoJSON](https://geojson.org), designed to encode a variety of data structures related to microscopy images. It can handle representations of reference points, regions of interest, and other annotations, making it an ideal solution for conveying complex microscopy data in a straightforward, easy-to-use format. +For more extensive documentation, please refer to the [online documentation](https://polusai.github.io/microjson/). + + ## Features MicroJSON offers a range of features designed to meet the needs of microscopy data representation: @@ -19,6 +22,16 @@ There are two additional functionalities added which supports binary and label i - **MicrojsonBinaryModel:** Reconstruct binary images using polygon coordinates from json file. +## Installation + +To install MicroJSON, you can use the following command: + +```pip install microjson``` +This will install the default version of MicroJSON with the basic functionalities and minimal dependencies. If you want to use the additional functionalities, such as provided by the ```utils``` module, you can install the package with the following command: + +```pip install microjson[all]``` + + ## Usage MicroJSON can be used with any application or tool that can process JSON data. Due to its design, it is particularly suited to applications related to the analysis, visualization, and manipulation of microscopy images. diff --git a/README_short.md b/README_short.md index 3cc9714..e650905 100644 --- a/README_short.md +++ b/README_short.md @@ -17,6 +17,15 @@ There are two additional functionalities added which supports binary images. **BinaryMicrojsonModel:** Converts objects in a binary image into polygon coordinates (rectangle, encoding) and save them in json file format using microjson package. **MicrojsonBinaryModel:** Reconstruct binary images using polygon coordinates from json file. +## Installation + +To install MicroJSON, you can use the following command: + +```pip install microjson``` +This will install the default version of MicroJSON with the basic functionalities and minimal dependencies. If you want to use the additional functionalities, such as provided by the ```utils``` module, you can install the package with the following command: + +```pip install microjson[all]``` + ## Usage MicroJSON can be used with any application or tool that can process JSON data. Due to its design, it is particularly suited to applications related to the analysis, visualization, and manipulation of microscopy images. @@ -31,10 +40,7 @@ We welcome contributions to the development and enhancement of MicroJSON. Whethe ## License -MicroJSON is licensed under MIT License, (c) 2023 Polus AI & Nextonic Solutions LLC. - -## Authors -Bengt Ljungquist [bengt.ljungquist@nextonicsolutions.com](bengt.ljungquist@nextonicsolutions.com) +MicroJSON is licensed under MIT License. --- diff --git a/src/microjson/model.py b/src/microjson/model.py index fbf5117..460548a 100644 --- a/src/microjson/model.py +++ b/src/microjson/model.py @@ -68,6 +68,14 @@ class Unit(Enum): PIXEL = "pixel" RADIAN = "radian" DEGREE = "degree" + MILLISECOND = "millisecond" + SECOND = "second" + MINUTE = "minute" + HOUR = "hour" + DAY = "day" + WEEK = "week" + MONTH = "month" + YEAR = "year" class AxisType(Enum): From f340f3df99b953663037585605996d35e62c07f3 Mon Sep 17 00:00:00 2001 From: Bengt Ljungquist Date: Thu, 8 Aug 2024 14:54:41 -0400 Subject: [PATCH 2/6] Bump version 0.1.11 -> 0.1.12 --- pyproject.toml | 6 +++--- src/microjson/__init__.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 463ca06..c029800 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "microjson" -version = "0.1.11" +version = "0.1.12" description = "MicroJSON is a library for validating, parsing, and manipulating MicroJSON data." readme = "README_short.md" authors = ["Bengt Ljungquist "] @@ -33,7 +33,7 @@ geojson-pydantic = "^1.0.2" [tool.poetry.dependencies.bfio] -version = "2.3.6" +version = "0.1.12" extras = ["all"] optional = true @@ -74,7 +74,7 @@ mkdocstrings = "^0.23.0" testpaths = ["tests/"] [tool.bumpver] -current_version = "0.1.11" +current_version = "0.1.12" version_pattern = "MAJOR.MINOR.PATCH" commit_message = "Bump version {old_version} -> {new_version}" commit = true diff --git a/src/microjson/__init__.py b/src/microjson/__init__.py index 6b61072..3e85ac7 100644 --- a/src/microjson/__init__.py +++ b/src/microjson/__init__.py @@ -1,4 +1,4 @@ from .model import MicroJSON, GeoJSON -__version__ = "0.1.11" +__version__ = "0.1.12" From 3af84228c999b4c5c041050c269c936404a9b8b0 Mon Sep 17 00:00:00 2001 From: Bengt Ljungquist Date: Wed, 14 Aug 2024 15:19:37 -0400 Subject: [PATCH 3/6] Fixed test issues --- .gitignore | 2 ++ pyproject.toml | 24 +++++++++++++++++------- src/microjson/utils.py | 6 +++++- tests/test_utils.py | 5 +++-- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 2ab134c..b076afb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ tests/__pycache__/ src/microjson/__pycache__/ poetry.lock +tmp* +dist/* \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index c029800..7c1a03d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,25 +28,33 @@ where = ["src"] [tool.poetry.dependencies] python = ">=3.9.15,<3.12" pydantic = "^2.3.0" -scikit-image = "0.20.0" geojson-pydantic = "^1.0.2" +jsonschema = "^4.0.0" + + +[tool.poetry.dependencies.scikit-image] +version = "^0.20.0" +optional = true [tool.poetry.dependencies.bfio] -version = "0.1.12" -extras = ["all"] +version = "2.4.2" optional = true [tool.poetry.dependencies.scipy] -version = ">=1.8,<1.9.2" +version = "^1.9.1" optional = true [tool.poetry.dependencies.filepattern] version = "^2.0.1" optional = true -[tool.poetry.dependencies.vaex] -version = "^4.17.0" +[tool.poetry.dependencies.vaex-core] +version = "^4.8.0" +optional = true + +[tool.poetry.dependencies.matplotlib] +version = "^3.5.1" optional = true [tool.poetry.extras] @@ -54,7 +62,9 @@ all = [ "bfio", "scipy", "filepattern", - "vaex" + "vaex-core", + "scikit-image", + "matplotlib", ] [tool.poetry.dev-dependencies] diff --git a/src/microjson/utils.py b/src/microjson/utils.py index cb2cc28..f6cba35 100644 --- a/src/microjson/utils.py +++ b/src/microjson/utils.py @@ -28,6 +28,7 @@ from microjson.model import Feature, Properties from typing import Union import pydantic +import matplotlib.pyplot as plt #define conditional imports try: @@ -94,6 +95,7 @@ def _tile_read(self) -> None: image = self.br[y:y_max, x:x_max, z : z + 1] unique_labels = len(np.unique(image)) + if unique_labels >= self.max_unique_labels: if unique_labels == self.max_unique_labels: msg = f"Binary image detected : tile {i}" @@ -113,6 +115,7 @@ def _tile_read(self) -> None: ) if as_completed(future): # type: ignore label, coordinates = future.result() + if len(label) and len(coordinates) > 0: label = [i + idx for i in range( 1, len(label) + 1)] @@ -328,9 +331,10 @@ def polygons_to_microjson( # noqa: PLR0915 if self.polygon_type == "rectangle": cor_value = list(ast.literal_eval(cor)) else: - cor_value = cor + cor_value = cor + [cor[0]] geometry = GeometryClass(type=row["geometry_type"], coordinates=[cor_value]) + # create a new properties object dynamically properties = mj.Properties(numeric=numeric_dict) diff --git a/tests/test_utils.py b/tests/test_utils.py index a5af0f0..6279211 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -6,13 +6,14 @@ import tempfile from pathlib import Path from typing import Union -import numpy as np import pytest -import skimage as sk + HAS_BFIO = False try: import bfio HAS_BFIO = True + import numpy as np + import skimage as sk except ImportError: pass From 7bc97966a85791aba2e21e259897337a8974bcf7 Mon Sep 17 00:00:00 2001 From: Bengt Ljungquist Date: Wed, 14 Aug 2024 15:20:55 -0400 Subject: [PATCH 4/6] Bump version 0.1.12 -> 0.1.13 --- pyproject.toml | 6 +++--- src/microjson/__init__.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7c1a03d..e1164ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "microjson" -version = "0.1.12" +version = "0.1.13" description = "MicroJSON is a library for validating, parsing, and manipulating MicroJSON data." readme = "README_short.md" authors = ["Bengt Ljungquist "] @@ -38,7 +38,7 @@ optional = true [tool.poetry.dependencies.bfio] -version = "2.4.2" +version = "0.1.13" optional = true [tool.poetry.dependencies.scipy] @@ -84,7 +84,7 @@ mkdocstrings = "^0.23.0" testpaths = ["tests/"] [tool.bumpver] -current_version = "0.1.12" +current_version = "0.1.13" version_pattern = "MAJOR.MINOR.PATCH" commit_message = "Bump version {old_version} -> {new_version}" commit = true diff --git a/src/microjson/__init__.py b/src/microjson/__init__.py index 3e85ac7..798e4dc 100644 --- a/src/microjson/__init__.py +++ b/src/microjson/__init__.py @@ -1,4 +1,4 @@ from .model import MicroJSON, GeoJSON -__version__ = "0.1.12" +__version__ = "0.1.13" From e9f689930f812b712d73294e292dfd1e75b2e29b Mon Sep 17 00:00:00 2001 From: Bengt Ljungquist Date: Thu, 15 Aug 2024 11:58:54 -0400 Subject: [PATCH 5/6] Bump version 0.1.13 -> 0.2.0 --- pyproject.toml | 6 +++--- src/microjson/__init__.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e1164ce..d3246ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "microjson" -version = "0.1.13" +version = "0.2.0" description = "MicroJSON is a library for validating, parsing, and manipulating MicroJSON data." readme = "README_short.md" authors = ["Bengt Ljungquist "] @@ -38,7 +38,7 @@ optional = true [tool.poetry.dependencies.bfio] -version = "0.1.13" +version = "0.2.0" optional = true [tool.poetry.dependencies.scipy] @@ -84,7 +84,7 @@ mkdocstrings = "^0.23.0" testpaths = ["tests/"] [tool.bumpver] -current_version = "0.1.13" +current_version = "0.2.0" version_pattern = "MAJOR.MINOR.PATCH" commit_message = "Bump version {old_version} -> {new_version}" commit = true diff --git a/src/microjson/__init__.py b/src/microjson/__init__.py index 798e4dc..cbb09c9 100644 --- a/src/microjson/__init__.py +++ b/src/microjson/__init__.py @@ -1,4 +1,4 @@ from .model import MicroJSON, GeoJSON -__version__ = "0.1.13" +__version__ = "0.2.0" From 79003b6f998c7e938d7776c967f4e0908fb94748 Mon Sep 17 00:00:00 2001 From: Bengt Ljungquist Date: Fri, 4 Oct 2024 12:03:33 -0400 Subject: [PATCH 6/6] Updated README after feedback --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d5417a2..c53e0a5 100644 --- a/README.md +++ b/README.md @@ -26,15 +26,19 @@ There are two additional functionalities added which supports binary and label i To install MicroJSON, you can use the following command: -```pip install microjson``` +```bash +pip install microjson +``` This will install the default version of MicroJSON with the basic functionalities and minimal dependencies. If you want to use the additional functionalities, such as provided by the ```utils``` module, you can install the package with the following command: -```pip install microjson[all]``` +```bash +pip install microjson[all] +``` ## Usage -MicroJSON can be used with any application or tool that can process JSON data. Due to its design, it is particularly suited to applications related to the analysis, visualization, and manipulation of microscopy images. +MicroJSON is compatible with any application or tool that process JSON data. Its design makes it especially well-suited for applications involving analysis, visualization, and manipulation of microscopy images. ## Examples