diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..e7d2425 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,43 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Install '....' +3. Run commands '....' + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Environment** + +### operating system and version? +e.g. Ubuntu 23.10 LTS + +### Python environment and version? +e.g. Conda environment with Python 3.10. Check your Python version with: +```sh +python --version +``` + +### version of brainles_preprocessing ? +please specify your version of brainles_preprocessing (please make sure you run the latest version): +```sh +pip freeze | grep brainles_preprocessing +``` + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000..f7af62c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,11 @@ +--- +name: Question +about: Please ask your question, make sure to read the FAQ before +title: '' +labels: '' +assignees: '' + +--- + +**Your question** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bca21a7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +name: release + +on: + release: + types: [created] + workflow_dispatch: + +jobs: + publish: + name: Publish to test PyPI + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Install dependencies + run: | + pip install build + pip install twine + - name: Build package + run: python -m build + - name: Upload to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: | + twine upload dist/*.whl diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..9a0602e --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,40 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: tests + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11","3.12"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest + pip install -e . + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..d5fda5f --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,32 @@ +# .readthedocs.yaml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the version of Python and other tools you might need +build: + os: ubuntu-22.04 + tools: + python: "3.10" + jobs: + post_create_environment: + # Install poetry + # https://python-poetry.org/docs/#installing-manually + - pip install poetry + # Tell poetry to not use a virtual environment + - poetry config virtualenvs.create false + post_install: + # Install dependencies with 'docs' dependency group + # https://python-poetry.org/docs/managing-dependencies/#dependency-groups + - poetry install --with docs + +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: docs/source/conf.py +# If using Sphinx, optionally build your docs in additional formats such as PDF +# formats: +# - pdf + +# Optionally declare the Python requirements required to build your docs diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..747ffb7 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..06c0ef5 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,66 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. + +import os +import sys + +sys.path.insert(0, os.path.abspath("../../")) + + +# -- Project information ----------------------------------------------------- + +project = 'panoptica' +copyright = '2023, florian kofler et al.' +author = 'Florian Kofler et al.' + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.napoleon", + "sphinx_copybutton", + "myst_parser", +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = "sphinx_rtd_theme" + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +autodoc_default_options = { + "members": True, + "undoc-members": True, + "private-members": True, + "show-inheritance": True, +} diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..c930f15 --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,45 @@ +.. panoptica documentation master file, created by + sphinx-quickstart on Tue Nov 21 12:02:41 2023. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to panoptica's documentation! +===================================== + +.. include:: ../../README.md + :parser: myst_parser.sphinx_ + +.. toctree:: + :maxdepth: 4 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + +.. toctree:: + :maxdepth: 2 + :caption: Panoptica: + + panoptica.rst + + + +.. toctree:: + :maxdepth: 2 + :caption: Metrics: + + panoptica.metrics.rst + + + +.. toctree:: + :maxdepth: 2 + :caption: Utils: + + panoptica.utils.rst \ No newline at end of file diff --git a/docs/source/panoptica.metrics.rst b/docs/source/panoptica.metrics.rst new file mode 100644 index 0000000..159d1bb --- /dev/null +++ b/docs/source/panoptica.metrics.rst @@ -0,0 +1,22 @@ +panoptica.utils +=========================== + + +panoptica.metrics.assd +-------------------------------------------- + +.. automodule:: panoptica.metrics.assd + + +panoptica.metrics.dice +-------------------------------------- + +.. automodule:: panoptica.metrics.dice + + + +panoptica.metrics.iou +-------------------------------------- + +.. automodule:: panoptica.metrics.iou + diff --git a/docs/source/panoptica.rst b/docs/source/panoptica.rst new file mode 100644 index 0000000..68da618 --- /dev/null +++ b/docs/source/panoptica.rst @@ -0,0 +1,32 @@ +panoptica +====================== + + +panoptica.evaluator +-------------------------------------------- + +.. automodule:: panoptica.evaluator + + +panoptica.instance_approximator +-------------------------------------------- + +.. automodule:: panoptica.instance_approximator + + +panoptica.instance_matcher +-------------------------------------------- + +.. automodule:: panoptica.instance_matcher + + +panoptica.instance_evaluator +-------------------------------------------- + +.. automodule:: panoptica.instance_evaluator + + +panoptica.result +-------------------------------------------- + +.. automodule:: panoptica.result diff --git a/docs/source/panoptica.utils.rst b/docs/source/panoptica.utils.rst new file mode 100644 index 0000000..1b3056e --- /dev/null +++ b/docs/source/panoptica.utils.rst @@ -0,0 +1,23 @@ +panoptica.utils +=========================== + + +panoptica.utils.constants +-------------------------------------------- + +.. automodule:: panoptica.utils.constants + + + +panoptica.utils.datatypes +-------------------------------------- + +.. automodule:: panoptica.utils.datatypes + + + +panoptica.util.numpy_utils +----------------------------------- + +.. automodule:: panoptica.utils.numpy_utils + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d9fbb1e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,41 @@ +[build-system] +requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"] +build-backend = "poetry_dynamic_versioning.backend" + +[tool.poetry-dynamic-versioning] +enable = true + +[tool.poetry] +name = "panoptica" +version = "0.0.0" +description = "Panoptic Quality (PQ) computation for binary masks." +authors = ["Florian Kofler "] +repository = "https://github.com/BrainLesion/panoptica" +homepage = "https://github.com/BrainLesion/panoptica" +documentation = "https://panoptica.readthedocs.io/" +readme = "README.md" + + +# Add the exclude field directly under [tool.poetry] +exclude = ["examples", "benchmark"] + +[tool.poetry.dependencies] +python = "^3.10" +numpy = "^1.20.0" +connected-components-3d = "^3.12.3" +scipy = "^1.7.0" +rich = "^13.6.0" + +[tool.poetry.dev-dependencies] +pytest = "^6.2.5" +pytest-cov = "^3.0.0" +pytest-mock = "^3.6.0" + +[tool.poetry.group.docs] +optional = true + +[tool.poetry.group.docs.dependencies] +Sphinx = ">=7.0.0" +sphinx-copybutton = ">=0.5.2" +sphinx-rtd-theme = ">=1.3.0" +myst-parser = ">=2.0.0" \ No newline at end of file