Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
sudo apt update
sudo apt-get install -y libopenslide-dev openslide-tools libopenjp2-7 libopenjp2-tools
python -m pip install --upgrade pip
python -m pip install ruff==0.9.9 pytest pytest-cov pytest-runner
python -m pip install ruff==0.11.4 pytest pytest-cov pytest-runner
pip install -r requirements/requirements.txt
- name: Cache tiatoolbox static assets
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ repos:
- id: rst-inline-touching-normal # Detect mistake of inline code touching normal text in rst.
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.9
rev: v0.11.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/annotation_store.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2417,7 +2417,7 @@
" return_counts=True,\n",
" )\n",
" total = np.sum(counts)\n",
" frequencies = {v: 0 for v in range(256)}\n",
" frequencies = dict.fromkeys(range(256), 0)\n",
" for v, x in zip(values, counts):\n",
" frequencies[v] = x / total\n",
" frequency_array = np.array(list(frequencies.values()))\n",
Expand Down
112 changes: 66 additions & 46 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/usr/bin/env python
# flake8: noqa
"""Defines configuration for sphinx and readthedocs."""

from __future__ import annotations

import logging

#
# tiatoolbox documentation build configuration file, created by
# sphinx-quickstart on Fri Jun 9 13:47:02 2017.
Expand All @@ -12,18 +17,17 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.

# 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
from pathlib import Path
import shutil
import sys
from pathlib import Path

sys.path.insert(0, os.path.abspath(".."))
sys.path.insert(0, str(Path("..").resolve()))

import tiatoolbox

Expand Down Expand Up @@ -84,7 +88,7 @@

# General information about the project.
project = "TIA Toolbox"
copyright = "2025, TIA Lab"
copyright = "2025, TIA Lab" # noqa: A001
author = "TIA Lab"

# The version info for the project you're documenting, acts as replacement
Expand Down Expand Up @@ -134,15 +138,18 @@
#
html_theme_options = {
"navigation_with_keys": True,
"top_of_page_button": None,
"top_of_page_buttons": ["view", "edit"],
"footer_icons": [
{
"name": "TIA",
"url": "https://warwick.ac.uk/fac/cross_fac/tia/",
"html": """
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 173 175" style="enable-background:new 0 0 173 175;" xml:space="preserve">
<image style="overflow:visible;" width="519" height="525" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgcAAAINCAYAAACqOtxdAAABemlDQ1BJQ0MgUHJvZmlsZQAAKJF9
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 173 175" style="enable-background:new 0 0 173 175;"
xml:space="preserve">
<image style="overflow:visible;" width="519" height="525"
xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgcAAAINCAYAAACqOtxdAAABemlDQ1BJQ0MgUHJvZmlsZQAAKJF9
kE0rRFEYx38GjbxEsbCwuHlbDTFKbJSZNKYsNChvmzvXnRllrtudK2RjoWwVJTbeFnwCNhbKWilF
Sna+ALGRrufMjMZLeeo5z+885zn/zvmDL6Db9lxJB6Qt14lFQtr4xKTmf8KHnxqqqNeNjN0/PDyE
xFf9GW+3FKl606a0/p7/GxUzZsaAojLhPsN2XOFB4aZF11as9OoceZTwquJkjrcUx3N8kp0ZjYWF
Expand Down Expand Up @@ -884,9 +891,15 @@
"name": "TIA",
"url": "https://warwick.ac.uk/fac/cross_fac/tia/",
"html": """
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 178 171.89" style="enable-background:new 0 0 178 171.89;" xml:space="preserve">
<image style="overflow:visible;" width="518" height="525" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgYAAAINCAYAAABF+LdjAAABfWlDQ1BJQ0MgUHJvZmlsZQAAKJF9
<svg version="1.1" id="Layer_1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 178 171.89"
style="enable-background:new 0 0 178 171.89;" xml:space="preserve">
<image style="overflow:visible;"
width="518" height="525"
xlink:href="data:image/png;base64,
iVBORw0KGgoAAAANSUhEUgAAAgYAAAINCAYAAABF+LdjAAABfWlDQ1BJQ0MgUHJvZmlsZQAAKJF9
kM9LAkEUx7+uhVGGQR06dBjKOqnYBlKXQCVM8CBmkNVlXVcNdF12Nyq6dAi6CgVRl34d6i+oS4eg
cxAERRDd+geKuoRsb1xDK+gNM+8zb958mfkCgk/StFJbECirpp6KRdhcZp65XiDAhR4aTJINLZxM
JkDxnX/Gxz0cPN/5udbf83+jK6cYMuDoIJ6UNd0kniYeWjE1zlyvT6dHEW9wLti8wzlr81m9J52K
Expand Down Expand Up @@ -1863,7 +1876,8 @@
SIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAE
SIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAE
SIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAESIAE
SIAESIAESIAESIAESIAESIAESIAESIAESIAESIAE0iPwfxKOnjvVcLCDAAAAAElFTkSuQmCC" transform="matrix(0.3333 0 0 0.3333 0 -3.11)">
SIAESIAESIAESIAESIAESIAESIAESIAESIAESIAE0iPwfxKOnjvVcLCDAAAAAElFTkSuQmCC"
transform="matrix(0.3333 0 0 0.3333 0 -3.11)">
</image>
</svg>
""",
Expand All @@ -1873,8 +1887,19 @@
"name": "GitHub",
"url": "https://github.com/TissueImageAnalytics/tiatoolbox",
"html": """
<svg height="32" aria-hidden="true" viewBox="0 0 16 16" version="1.1" width="32" data-view-component="true" class="octicon octicon-mark-github v-align-middle">
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
<svg height="32" aria-hidden="true" viewBox="0 0 16 16" version="1.1"
width="32" data-view-component="true"
class="octicon octicon-mark-github v-align-middle">
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29
6.53 5.47 7.59.4.07.55-.17.55-.38
0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94
-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21
1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95
0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21
2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82
2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87
3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0
.21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
</svg>
""",
"class": "only-light",
Expand All @@ -1883,8 +1908,19 @@
"name": "GitHub",
"url": "https://github.com/TissueImageAnalytics/tiatoolbox",
"html": """
<svg height="32" aria-hidden="true" viewBox="0 0 16 16" version="1.1" width="32" data-view-component="true" class="octicon octicon-mark-github v-align-middle">
<path fill="#ffffff" fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
<svg height="32" aria-hidden="true" viewBox="0 0 16 16" version="1.1"
width="32" data-view-component="true" class="octicon octicon-mark-github
v-align-middle">
<path fill="#ffffff" fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0
8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38
0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94
-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21
1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95
0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21
2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82
2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87
3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0
.21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
</svg>
""",
"class": "only-dark",
Expand All @@ -1901,8 +1937,7 @@
html_static_path = []

# These paths are either relative to html_static_path
# or fully qualified paths (eg. https://...)
# html_css_files = []
# or fully qualified paths (e.g., https://...)

# -- Options for HTMLHelp output ---------------------------------------

Expand Down Expand Up @@ -1963,15 +1998,6 @@
"Sphinx": ("https://www.sphinx-doc.org/en/stable/", None),
}

# create latex preamble so that we can build arbitrary nested depth
fh = open("latex_preamble.tex", "r+")
PREAMBLE = fh.read()
fh.close()
latex_elements = {
# Additional stuff for the LaTeX preamble.
"preamble": PREAMBLE,
}

# -- Options for autodoc -----------------------------------------------

autodoc_typehints = "description"
Expand All @@ -1980,37 +2006,31 @@
"ArrayLike": "ArrayLike",
}

print("=" * 43)
print("Copy example notebooks into docs/_notebooks")
print("=" * 43)
logging.info("=" * 43)
logging.info("Copy example notebooks into docs/_notebooks")
logging.info("=" * 43)


def all_but_ipynb(dir_path, contents):
"""Helper to copy all .ipynb"""
def all_but_ipynb(dir_path: str, contents: list) -> list:
"""Helper to copy all *.ipynb files."""
result = []
for c in contents:
flag = os.path.isfile(os.path.join(dir_path, c)) and (not c.endswith(".ipynb"))
flag = (Path(dir_path) / c).is_file() and (not c.endswith(".ipynb"))
if flag:
result += [c]
return result


DOC_ROOT = os.path.dirname(os.path.realpath(__file__))
PROJ_ROOT = Path(DOC_ROOT).parent
shutil.rmtree(os.path.join(PROJ_ROOT, "docs/_notebooks"), ignore_errors=True)
PROJ_ROOT = Path(os.path.realpath(__file__)).parent.parent
shutil.rmtree(PROJ_ROOT / "docs/_notebooks", ignore_errors=True)
shutil.copytree(
os.path.join(PROJ_ROOT, "examples"),
os.path.join(PROJ_ROOT, "docs/_notebooks/jnb"),
PROJ_ROOT / "examples",
PROJ_ROOT / "docs/_notebooks/jnb",
ignore=all_but_ipynb,
)

# shutil.copy(
# os.path.join(PROJ_ROOT, "docs/usage_examples.rst"),
# os.path.join(PROJ_ROOT, "docs/_notebooks/usage_examples.rst"),
# )

# Read in the file
with open("../examples/README.md", "r") as file:
with Path("../examples/README.md").open() as file:
file_data = file.read()

# Replace the target string
Expand All @@ -2020,5 +2040,5 @@ def all_but_ipynb(dir_path, contents):
file_data = file_data.replace("../docs/", "./")

# Write the file out again
with open("_notebooks/README.md", "w") as file:
with Path("_notebooks/README.md").open("w") as file:
file.write(file_data)
2 changes: 1 addition & 1 deletion requirements/requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pytest>=7.2.0
pytest-cov>=4.0.0
pytest-runner>=6.0
pytest-xdist[psutil]
ruff==0.9.9 # This will be updated by pre-commit bot to latest version
ruff==0.11.4 # This will be updated by pre-commit bot to latest version
toml>=0.10.2
twine>=4.0.1
wheel>=0.37.1
7 changes: 5 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import annotations

import hashlib
import os
import shutil
from pathlib import Path
from typing import TYPE_CHECKING, NoReturn
Expand Down Expand Up @@ -1056,7 +1055,11 @@ def test_download_unzip_data(tmp_path: Path) -> None:

extracted_path = save_dir_path / "test_directory"
# to avoid hidden files in case of MAC-OS or Windows (?)
extracted_dirs = [f for f in os.listdir(extracted_path) if not f.startswith(".")]
extracted_dirs = [
f.name
for f in extracted_path.iterdir()
if f.is_dir() and not f.name.startswith(".")
]
extracted_dirs.sort() # ensure same ordering
assert extracted_dirs == ["dir1", "dir2", "dir3"]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_wsi_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def test_bspline_transform(
_ = apply_bspline_transform(fixed_img, moving_img, transform)
registered_msk = apply_bspline_transform(fixed_mask_, moving_mask_, transform)
mask_overlap = dice(fixed_mask_, registered_msk)
assert mask_overlap > 0.75
assert mask_overlap > 0.70


def test_affine_wsi_transformer(sample_ome_tiff: Path) -> None:
Expand Down
Loading