Skip to content

Commit 7b403c9

Browse files
committed
Preparing for PR
Removing large files Removing unneccessary files Fixing pre-commit [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Fixing PR issues :technologist: pre-commit autoupdate (#910) * 🧑‍💻 pre-commit autoupdate updates: - [github.com/executablebooks/mdformat: 0.7.21 → 0.7.22](hukkin/mdformat@0.7.21...0.7.22) - [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.9.4](astral-sh/ruff-pre-commit@v0.8.6...v0.9.4) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * 📌 Update `ruff` dependency * 🔥 TIAToolbox does not support Python > 3.12 yet - There is no need for this check as this will be tested while upgrading to Python 3.13 * ♻️ Refactor `typing` to `type_hints`. * 🐛 Fix `mypy` workflow --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Shan E Ahmed Raza <13048456+shaneahmed@users.noreply.github.com> 📝 Update Documentation Structure (#909) - Use `Python 3.12` for docs build - Update `copyright` year to `2025` - Landing page now shows text from README - Update documentation structure - Update `readthedocs` Build - Remove `usage.rst` - Rename Jupyter Notebooks to Usage Examples - Show README for Usage Examples instead of TOC - Reduce TOC depth for basic functionalities and pipelines - Improve `README` quality. 🐛 Fix in `test_arch_mapde` and `test_arch_sccnn` (#911) - If cuda is available model should be moved to cuda otherwise tests will fail as test data is moved to cuda. [skip ci] 📝 Improve Documentation (#913) - Update CONTRIBUTING.rst - Bug fix in conf.py to fix notebook links - Update `examples/README.md` - Update `docs/installation.rst` - Update `docs/visualization.rst` --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: adamshephard <39619155+adamshephard@users.noreply.github.com> :bug: Fix `MapDe` `dist_filter` Shape (#914) - Fix `dist_filter` in `MapDe` model for multi-class output. Explanation: Previously, if we set `num_class` to more than 1, the model would still output 1 channel. This was because the `dist_filter` always had size of 1 in its first dimension, however the first dimension determines the number of output channels in the tensor produced by `torch.functional.F.conv2d`. This PR changes this by repeating the filters the match the number of output classes. :technologist: pre-commit autoupdate (#916) * 🧑‍💻 pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.4 → v0.9.9](astral-sh/ruff-pre-commit@v0.9.4...v0.9.9) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * 🔨 Update `ruff` version * 🔨 Update noqa for Unused static method argument --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Shan E Ahmed Raza <13048456+shaneahmed@users.noreply.github.com> Add FsspecJsonWSIReader class. (#897) The `FsspecJsonWSIReader` reads fsspec json file which represents SVS or TIFF whole slide image. The images are accessible by HTTP range requests, eg: `https://api.gdc.cancer.gov/data/73c69d24-6f9e-44e2-bfe5-a608d4cf5c27` The whole image can be downloaded like: `curl -C - -o TCGA-22-1017-01Z-00-DX1.9562FE79-A261-42D3-B394-F3E0E2FF7DDA.svs https://api.gdc.cancer.gov/data/73c69d24-6f9e-44e2-bfe5-a608d4cf5c27` The `FsspecJsonWSIReader` class has a `_zarr_store` field which is created by reading json file using `fsspec`: ``` mapper = fsspec.get_mapper( "reference://", fo=str(input_img), target_protocol="file" ) self._zarr_array = zarr.open(mapper, mode="r") self._zarr_store = self._zarr_array.store self._zarr_lru_cache = zarr.LRUStoreCache(self._zarr_store, max_size=cache_size) self._zarr_group = zarr.open(self._zarr_lru_cache) ``` This is equivalent to `TIFFWSIReader` code: ``` self._zarr_store = tifffile.imread( self.input_path, series=self.series_n, aszarr=True, ) self._zarr_lru_cache = zarr.LRUStoreCache(self._zarr_store, max_size=cache_size) self._zarr_group = zarr.open(self._zarr_lru_cache) ``` Both FsspecJsonWSIReader and TIFFWSIReader forward calls to `read_bounds` and `read_rect` methods of the`TIFFWSIReaderDelegate` delegate instance. The method `_info` of the`TIFFWSIReaderDelegate` reads SVS metadata which is stored in the root group metadata like: ``` { ".zattrs": { "multiscales": [ { "metadata": { "objective_power": 40, "vendor": "Aperio", "mpp": [0.2525, 0.2525] } } ] } } ``` To test, execute from the root dir: ``` pip install -r requirements/requirements_dev.txt mkdir -p samples/slides mkdir -p samples/fsspec cd samples/slides curl -C - -o TCGA-22-1017-01Z-00-DX1.9562FE79-A261-42D3-B394-F3E0E2FF7DDA.svs https://api.gdc.cancer.gov/data/73c69d24-6f9e-44e2-bfe5-a608d4cf5c27 cd ../../ cp tiatoolbox/utils/tiff_to_fsspec.py . python tiff_to_fsspec.py "samples/slides/TCGA-22-1017-01Z-00-DX1.9562FE79-A261-42D3-B394-F3E0E2FF7DDA.svs" "samples/fsspec/73c69d24-6f9e-44e2-bfe5-a608d4cf5c27_fsspec.json" "https://api.gdc.cancer.gov/data/73c69d24-6f9e-44e2-bfe5-a608d4cf5c27" ``` Create `tileserver.py` inside of the project root: ``` from flask_cors import CORS from tiatoolbox.visualization import TileServer from tiatoolbox.wsicore.wsireader import FsspecJsonWSIReader wsi = FsspecJsonWSIReader.open( "./samples/fsspec/73c69d24-6f9e-44e2-bfe5-a608d4cf5c27_fsspec.json" ) tile_server = TileServer( title="Tiatoolbox TileServer", layers={"layer": wsi}, ) CORS(tile_server, send_wildcard=True) tile_server.run(host="127.0.0.1", port=5000) ``` Open `http://127.0.0.1:5000/` and verify that it works. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Shan E Ahmed Raza <13048456+shaneahmed@users.noreply.github.com> ✨ Support for Additional Foundation Models (#906) - Add support for additional foundation models as feature extractors using the TimmBackbone. - Added models include: UNI2, Virchow, Virchow2, kaiko and H-optimus-1. - Add more information to docstrings. - Allow foundation models with additional parameters. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Shan E Ahmed Raza <13048456+shaneahmed@users.noreply.github.com> Fixing PR issues
1 parent 35237c4 commit 7b403c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1442
-2798
lines changed

.github/workflows/mypy-type-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
mypy --install-types --non-interactive --follow-imports=skip \
4141
tiatoolbox/__init__.py \
4242
tiatoolbox/__main__.py \
43-
tiatoolbox/typing.py \
43+
tiatoolbox/type_hints.py \
4444
tiatoolbox/tiatoolbox.py \
4545
tiatoolbox/utils \
4646
tiatoolbox/tools \

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
sudo apt update
3131
sudo apt-get install -y libopenslide-dev openslide-tools libopenjp2-7 libopenjp2-tools
3232
python -m pip install --upgrade pip
33-
python -m pip install ruff==0.8.2 pytest pytest-cov pytest-runner
33+
python -m pip install ruff==0.9.9 pytest pytest-cov pytest-runner
3434
pip install -r requirements/requirements.txt
3535
- name: Cache tiatoolbox static assets
3636
uses: actions/cache@v3

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repos:
2323
- mdformat-black
2424
- mdformat-myst
2525
- repo: https://github.com/executablebooks/mdformat
26-
rev: 0.7.21
26+
rev: 0.7.22
2727
hooks:
2828
- id: mdformat
2929
# Optionally add plugins
@@ -60,7 +60,7 @@ repos:
6060
- id: rst-inline-touching-normal # Detect mistake of inline code touching normal text in rst.
6161
- repo: https://github.com/astral-sh/ruff-pre-commit
6262
# Ruff version.
63-
rev: v0.8.6
63+
rev: v0.9.9
6464
hooks:
6565
- id: ruff
6666
args: [--fix, --exit-non-zero-on-fix]

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ version: 2
99
build:
1010
os: ubuntu-24.04
1111
tools:
12-
python: "3.10"
12+
python: "3.12"
1313
apt_packages:
1414
- openslide-tools
1515
- libopenjp2-7-dev

CONTRIBUTING.rst

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
.. highlight:: shell
22

3-
============
3+
=============
44
Contributing
5-
============
5+
=============
66

7-
Contributions are welcome, and they are greatly appreciated! Every little bit
8-
helps, and credit will always be given.
7+
Contributions are welcome and greatly appreciated! Every little bit helps, and credit will always be given.
98

109
You can contribute in many ways:
1110

@@ -26,21 +25,17 @@ If you are reporting a bug, please include:
2625
Fix Bugs
2726
~~~~~~~~
2827

29-
Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
30-
wanted" is open to whoever wants to implement it.
28+
Look through the GitHub issues for bugs. Anything tagged with "bug" and "help wanted" is open to whoever wants to implement it.
3129

3230
Implement Features
3331
~~~~~~~~~~~~~~~~~~
3432

35-
Look through the GitHub issues for features. Anything tagged with "enhancement"
36-
and "help wanted" is open to whoever wants to implement it.
33+
Look through the GitHub issues for features. Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it.
3734

3835
Write Documentation
3936
~~~~~~~~~~~~~~~~~~~
4037

41-
TIA Toolbox could always use more documentation, whether as part of the
42-
official TIA Toolbox docs, in docstrings, or even on the web in blog posts,
43-
articles, and such.
38+
TIA Toolbox could always use more documentation, whether as part of the official TIA Toolbox docs, in docstrings, or even on the web in blog posts, articles, and such.
4439

4540
Submit Feedback
4641
~~~~~~~~~~~~~~~
@@ -50,9 +45,8 @@ The best way to send feedback is to file an issue at https://github.com/TissueIm
5045
If you are proposing a feature:
5146

5247
* Explain in detail how it would work.
53-
* Keep the scope as narrow as possible, to make it easier to implement.
54-
* Remember that this is a volunteer-driven project, and that contributions
55-
are welcome :)
48+
* Keep the scope as narrow as possible to make it easier to implement.
49+
* Remember that this is a volunteer-driven project, and contributions are welcome :)
5650

5751
Get Started!
5852
------------
@@ -64,7 +58,7 @@ Ready to contribute? Here's how to set up ``tiatoolbox`` for local development.
6458

6559
$ git clone git@github.com:your_name_here/tiatoolbox.git
6660

67-
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
61+
3. Install your local copy into a virtual environment. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
6862

6963
$ mkvirtualenv tiatoolbox
7064
$ cd tiatoolbox/
@@ -76,13 +70,18 @@ Ready to contribute? Here's how to set up ``tiatoolbox`` for local development.
7670

7771
Now you can make your changes locally.
7872

79-
5. When you're done making changes, check that your changes pass flake8 and the
80-
tests::
73+
5. When you're done making changes, check that your changes pass pre-commit and the tests::
8174

82-
$ flake8 tiatoolbox tests
75+
$ pre-commit run --all-files
8376
$ python setup.py test or pytest
8477

85-
To get flake8, just pip install them into your virtualenv.
78+
To get `pre-commit <https://pre-commit.com/#install>`_, just pip install it into your virtual environment using::
79+
80+
$ pip install pre-commit
81+
82+
To set up the git hook for pre-commit, run the following command after installing pre-commit::
83+
84+
$ pre-commit install
8685

8786
6. Commit your changes and push your branch to GitHub::
8887

@@ -98,20 +97,15 @@ Pull Request Guidelines
9897
Before you submit a pull request, check that it meets these guidelines:
9998

10099
1. The pull request should include tests.
101-
2. If the pull request adds functionality, the docs should be updated. Put
102-
your new functionality into a function with a docstring, and add the
103-
feature to the list in README.rst.
104-
3. The pull request should work for Python 3.8, 3.9 and 3.10, and for PyPy. Check
105-
https://travis-ci.com/tialab/tiatoolbox/pull_requests
106-
and make sure that the tests pass for all supported Python versions.
100+
2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the pull request description.
101+
3. The pull request should work for Python 3.9, 3.10, 3.11, and 3.12, and for PyPy. Check https://github.com/TissueImageAnalytics/tiatoolbox/actions/workflows/python-package.yml and make sure that the tests pass for all supported Python versions.
107102

108103
Tips
109104
----
110105

111106
To run a subset of tests::
112107

113-
$ pytest tests.test_tiatoolbox
114-
108+
$ pytest tests.test_tiatoolbox
115109

116110
Deploying
117111
---------
@@ -120,8 +114,8 @@ A reminder for the maintainers on how to deploy.
120114
Make sure all your changes are committed (including an entry in HISTORY.rst).
121115
Then run::
122116

123-
$ poetry version patch # use: "poetry version --help" for other options
124-
$ git push
125-
$ git push --tags
117+
$ poetry version patch # use: "poetry version --help" for other options
118+
$ git push
119+
$ git push --tags
126120

127-
Travis will then deploy to PyPI if tests pass.
121+
GitHub Actions will then deploy to PyPI if tests pass.

README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,21 @@
4545

4646
## Getting Started
4747

48-
TIAToolbox is a computational pathology toolbox developed by TIA Centre that provides an end-to-end API for pathology image analysis using best practices. It is based on **[PyTorch](https://pytorch.org/)**, a popular deep learning framework that enables efficient and flexible implementation of state-of-the-art algorithms. TIAToolbox supports many features through a command-line interface and can integrate with standard PyTorch modules. It also offers tools for data loading, pre-processing, model inference, post-processing, and visualization. Whether you are a computational, biomedical, or clinical researcher, TIAToolbox can help you get started in digital pathology with minimal effort.
48+
TIAToolbox is a computational pathology toolbox developed by the TIA Centre. It provides an end-to-end API for pathology image analysis using best practices. Based on **[PyTorch](https://pytorch.org/)**, a popular deep learning framework, TIAToolbox enables efficient and flexible implementation of state-of-the-art algorithms. It supports many features through a command-line interface and can integrate with standard PyTorch modules. The toolbox offers tools for data loading, pre-processing, model inference, post-processing, and visualization. Whether you are a computational, biomedical, or clinical researcher, TIAToolbox can help you get started in digital pathology with minimal effort.
4949

5050
### All Users
5151

52-
This package is for those interested in digital pathology: including graduate students, medical staff, members of the TIA Centre and of PathLAKE, and anyone, anywhere, who may find it useful. We will continue to improve this package, taking account of developments in pathology, microscopy, computing and related disciplines. Please send comments and criticisms to **[tia@dcs.warwick.ac.uk](mailto:tialab@dcs.warwick.ac.uk)**.
53-
54-
**`tiatoolbox`** is a multipurpose name that we use for 1) a certain computer program, 2) a Python package of related programs, created by us at the TIA Centre to help people get started in Digital Pathology, 3) this repository, 4) a certain virtual environment.
52+
This package is designed for those interested in digital pathology, including graduate students, medical staff, members of the TIA Centre and PathLAKE, and anyone who may find it useful. We will continue to improve this package, taking into account developments in pathology, microscopy, computing, and related disciplines. Please send comments and feedback to **[tia@dcs.warwick.ac.uk](mailto:tialab@dcs.warwick.ac.uk)**.
5553

5654
### Developers
5755

58-
Anyone wanting to contribute to this repository, please first look at our [Wiki](https://github.com/TissueImageAnalytics/tiatoolbox/wiki) and at our web page for [contributors](https://github.com/TissueImageAnalytics/tiatoolbox/blob/master/CONTRIBUTING.rst). See also the *Prepare for development* section of this document.
59-
60-
### Links, if needed
56+
If you want to contribute to this repository, please first look at our [Wiki](https://github.com/TissueImageAnalytics/tiatoolbox/wiki) and our [contributor guidelines](https://github.com/TissueImageAnalytics/tiatoolbox/blob/master/CONTRIBUTING.rst). Also, see the *Prepare for development* section of this document.
6157

62-
The [bash](https://www.gnu.org/software/bash) shell is available on all commonly encountered platforms. Commands in this README are in bash. Windows users can use the command prompt to install conda and python packages.
58+
### Useful Links
6359

64-
[conda](https://github.com/conda/conda) is a management system for software packages and [virtual environments](https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/environments.html). To get `conda`, download [Anaconda](https://www.anaconda.com/), which includes hundreds of the most useful Python packages, using 2GB disk space. Alternatively, [miniconda](https://docs.conda.io/en/latest/miniconda.html) uses 400MB, and packages can be added as needed.
60+
The [bash](https://www.gnu.org/software/bash) shell is available on all commonly encountered platforms. Commands in this README are in bash. Windows users can use the command prompt to install conda and Python packages.
6561

66-
[GitHub](https://github.com/about) is powered by the version control system [git](https://git-scm.com/), which has many users and uses. In GitHub, it is used to track versions of code and other documents.
62+
[conda](https://github.com/conda/conda) is a management system for software packages and [virtual environments](https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/environments.html). To get `conda`, download [Anaconda](https://www.anaconda.com/), which includes hundreds of the most useful Python packages, using 2GB of disk space. Alternatively, [miniconda](https://docs.conda.io/en/latest/miniconda.html) uses 400MB, and packages can be added as needed.
6763

6864
### Examples Taster
6965

@@ -130,7 +126,7 @@ or
130126

131127
### License
132128

133-
The source code TIA Toolbox (tiatoolbox) as hosted on GitHub is released under the [BSD-3-Clause license](https://github.com/TissueImageAnalytics/tiatoolbox/blob/develop/LICENSE). The full text of the licence is included in [LICENSE](https://raw.githubusercontent.com/TissueImageAnalytics/tiatoolbox/develop/LICENSE).
129+
The source code TIAToolbox (tiatoolbox) as hosted on GitHub is released under the [BSD-3-Clause license](https://github.com/TissueImageAnalytics/tiatoolbox/blob/develop/LICENSE). The full text of the licence is included in [LICENSE](https://raw.githubusercontent.com/TissueImageAnalytics/tiatoolbox/develop/LICENSE).
134130

135131
Models weights are dependent on the datasets that they were trained on. Please refer to the [documentation](https://tia-toolbox.readthedocs.io/en/latest/pretrained.html) for more details.
136132

docs/basic_functionalities.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Basic Functionalities
22
*********************
33

44
.. toctree::
5-
:maxdepth: 2
5+
:maxdepth: 1
66
:glob:
77

88
_notebooks/jnb/*

docs/conf.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484

8585
# General information about the project.
8686
project = "TIA Toolbox"
87-
copyright = "2023, TIA Lab"
87+
copyright = "2025, TIA Lab"
8888
author = "TIA Lab"
8989

9090
# The version info for the project you're documenting, acts as replacement
@@ -2005,8 +2005,8 @@ def all_but_ipynb(dir_path, contents):
20052005
)
20062006

20072007
# shutil.copy(
2008-
# os.path.join(PROJ_ROOT, "docs/notebooks.rst"),
2009-
# os.path.join(PROJ_ROOT, "docs/_notebooks/notebooks.rst"),
2008+
# os.path.join(PROJ_ROOT, "docs/usage_examples.rst"),
2009+
# os.path.join(PROJ_ROOT, "docs/_notebooks/usage_examples.rst"),
20102010
# )
20112011

20122012
# Read in the file
@@ -2016,8 +2016,8 @@ def all_but_ipynb(dir_path, contents):
20162016
# Replace the target string
20172017
file_data = file_data.replace(".rst", ".html")
20182018
file_data = file_data.replace(".ipynb", ".html")
2019-
file_data = file_data.replace("../docs/", "../")
2020-
file_data = file_data.replace("](./", "](./jnb/")
2019+
file_data = file_data.replace("](./", "](./_notebooks/jnb/")
2020+
file_data = file_data.replace("../docs/", "./")
20212021

20222022
# Write the file out again
20232023
with open("_notebooks/README.md", "w") as file:

docs/index.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
Welcome to TIA Toolbox's documentation!
22
=======================================
33

4-
.. image:: tia_logo.png
5-
:alt: alternate text
6-
:align: center
4+
.. include:: ../README.md
5+
:parser: myst_parser.sphinx_
6+
7+
Index
8+
-----
79

810
.. toctree::
9-
:maxdepth: 2
11+
:maxdepth: 1
1012

1113
Readme <readme.rst>
1214
Installation <installation.rst>
13-
Usage <usage.rst>
1415
Pre-trained Models <pretrained.rst>
15-
Jupyter Notebooks <notebooks.rst>
16+
Usage Examples <usage_examples.rst>
1617
Algorithms <algorithms.rst>
1718
Visualization <visualization.rst>
1819
API Reference <_autosummary/tiatoolbox>

0 commit comments

Comments
 (0)