Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔖 Release 1.6.0 #895

Merged
merged 687 commits into from
Dec 12, 2024
Merged

🔖 Release 1.6.0 #895

merged 687 commits into from
Dec 12, 2024

Conversation

shaneahmed
Copy link
Member

@shaneahmed shaneahmed commented Dec 5, 2024

TIAToolbox v1.6.0 (2024-12-12)

Major Updates and Feature Improvements

API Changes

Bug Fixes and Other Changes

Development-Related Changes

  • Mypy Checks Added
    • Applied to utils, tools, data, annotation, and cli/common.
  • ReadTheDocs PDF Build Deprecation
  • Formatter Update
    • Replaced black with ruff-format.
  • Dependency Removal
    • Removed jinja2.
  • Test Environment Update
    • Updated to Ubuntu 24.04.
  • Conda Environment Workflow Update
    • Implemented micromamba setup.
  • Codecov Reporting Fix (🐛 Fix codecov Reporting #811)
    Full Changelog: v1.5.1...v1.6.0

shaneahmed and others added 30 commits March 10, 2023 11:08
- Filter logger output to `stdout` instead of `stderr`

---------

Co-authored-by: John Pocock <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Remove tox which is not required on GitHub Actions

Co-authored-by: John Pocock <[email protected]>
- 🚨 Use logger instead of print in `slide_info.py`.
- 🔥 Remove slide-info.py from wsicore
- 🎨 Update cli/slide_info to use wsi.slide_info instead of slide_info.py


Co-authored-by: Adam Shephard <[email protected]>
- Move `WSIReader` and `WSIMeta` import to top-level

This allows importing `WSIReader` and `WSIMeta` from `wsicore`. Improves usage of the library by importing modules as `from tiatoolbox.wsicore import WSIReader` and `from tiatoolbox.wsicore import WSIMeta`

---------

Co-authored-by: Adam Shephard <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
# Changes

- Change docstring examples to use concrete classes.
- Add custom warning when attempting to instantiate the abstract base class.
- Replace occurrences of `store.add` with `store.append` in examples.
- Fix bug with `DictionaryStore.bquery` and `geometry=None`, i.e. only a where predicate given.

# Documentation

The live build is at https://tia-toolbox.readthedocs.io/en/docs-ann-store-eg/
Annotation storage module: https://tia-toolbox.readthedocs.io/en/docs-ann-store-eg/_autosummary/tiatoolbox.annotation.storage.html#module-tiatoolbox.annotation.storage

Co-authored-by: Dima Blaginin <[email protected]>
Co-authored-by: Shan E Ahmed Raza <[email protected]>
This PR fixes the dicom slide thunbnail issue (maybe). the issue seems to arise from a difference in how the wsidicom reader treats levels, in that it labels them by their relative magnification (in power of 2).

so for example the levels in the wsidicom reader are [0, 2, 4] if the level downsamples are [1, 4, 16]

whereas in our WSIReader level is just an index [0, 1, 2], and the level_downsamples are separate.

My knowledge of DICOM is non-existent, so it may be that the fix is wrong - hopefully john can have a look at it. It fixed the thumbnail issue for me though.

----------------------------------------

Co-authored-by: Mark Eastwood <[email protected]>
Co-authored-by: John Pocock <[email protected]>
Co-authored-by: Shan Raza <[email protected]>
This docker fixes the bug with Ubuntu OS docker images.
- Improve installation instructions

---------

Co-authored-by: John Pocock <[email protected]>
Co-authored-by: Mostafa Jahanifar <[email protected]>
- Move the following models to top-level import
  - HoVerNet
  - HoVerNetPlus
  - IDaRS
  - MapDe
  - MicroNet
  - NuClick
  - SCCNN

-------------------------------------------------------
Co-authored-by: Shan Raza <[email protected]>
Co-authored-by: Adam Shephard <[email protected]>
- [x] Handle missing version keys and null values.
- [x] Add test for missing value
- [x] Add test for non-numeric values e.g. "0.5-dev" [see current spec doc](https://ngff.openmicroscopy.org/latest/#omero-md)
- [x] Warn if version < or > 0.4
- [x] Warn for inconsistent versions

---------

Co-authored-by: Shan E Ahmed Raza <[email protected]>
- Use `pyproject.toml` for `bdist_wheel` configuration
- Remove `aliases`

Co-authored-by: John Pocock <[email protected]>
- Use pyproject.toml for pytest Configuration

Co-authored-by: John Pocock <[email protected]>
* 🔧 Use pyproject.toml for isort configuration
- Use pyproject.toml for isort configuration

---------

Co-authored-by: John Pocock <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Use `pyproject.toml` for `pytest` Configuration
This PR Changes `is_ngff` to return True when above the max supported version with a warning logged.

Co-authored-by: Shan Raza <[email protected]>
This fixed potential bug with wsidicom update. The current code gets the base level as `dataset = self.wsi.base_level.datasets[0]`

The WsiDicom object has recently been changed so that this base_level is no longer a property of WsiDicom object, it is instead now only in `self.wsi.levels.base_level.datasets[0]` (before the update it was in both).

See [here](imi-bigpicture/wsidicom@9067121#diff-c193bbcec87f294abe8cc7a11e0ff209eea7d49407ff301734499e8956477501L98-L101), line 98-101 in wsidicom.py diff.
- Add `joblib` as dependency
- Update `black` Version to `23.3.0`.
- Restrict `pandas` version until #583 is merged.
* API Change for `PatchExtractor.filter_coordinates`. Instead of `coordinate_resolution`, `coordinate_units`, & `mask_resolution`, it takes `slide_shape` and a callable function `func` to validate the coordinates as input. New implementation is about ~200 times fast.

WSIPatchDataset uses `filter_coordinates` method of PatchExtractor, instead of the faster `filter_coordinates_fast`.

This PR updates it to use the faster method, and also includes a few other small improvements like allowing the min_mask_ratio argument to be used in the WSIPatchDataset in the same way it is available for patch extractor, so that behaviour between PatchExtractor and WSIPatchDataset is consistent.

Changes in this PR:
1. WSIPatchDataset now uses filter_coordinates_fast, consistent with PatchExtractor.
2. filter_coordinates_fast now uses the relative scale between the wsi dimensions at the requested patch resolution, and the mask dimensions, as the scale factor. This is units-agnostic and gives consistent results regardless of mode. Also doesn't make an even lower-res thumbnail of an already low-res mask as it did previously, which was unnecessary and could have had some wierd effects with masks which were already very low-res.
3. The documented post_proc argument now exists and will be used if given. Changed the documentation to reflect its functionality (ie its just called as is on the patch before it is returned)
4. Allows min_mask_ratio to be used in WSIPatchDataset, consistent with usage in PatchExtractor.

Rough performance comparison:
~0.6 sec using filter_coordinates_fast
~4 min using filter_coordinates
consistent with what was reported in original PR which added filter_coordinates_fast to PatchExtractor.

The PR also replicates the ability to provide a custom 'filter func' from filter_coordinates into filter_coordinates_fast, so in theory we can now get rid of filter_coordinates as it does nothing filter_coordinates_fast doesn't do.
- Pin Pandas Version to `>=2.0.0`
  - `df.append` is deprecated in favour of `pd.concat`. For more details see  https://pandas.pydata.org/docs/whatsnew/v2.0.0.html#removal-of-prior-version-deprecations-changes

-----------
Co-authored-by: Mark Eastwood <[email protected]>
- Use `logger` Instead Of `warnings` for `patchextraction.py`
- Add tests for lazy import
#590)

- Use `logger` Instead Of `warnings` for `pyramid.py` and `storage.py`
- Catches duplicate errors and prints them only once.

Co-authored-by: John Pocock <[email protected]>
- Use `logger` Instead Of `warnings` for `utils` Package

---------

Signed-off-by: Shan E Ahmed Raza <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Code is held under a BSD-3-Clause license, but model weights are dependent on the data it is trained on. Before, we generalised this and set everything under a non-commercial creative commons license, but this is not reasonable for models trained on permissive dataset, such as [PCam](https://github.com/basveeling/pcam).

This PCam specified a license per model in accordance with the original dataset license.

Documentation available at this link https://tia-toolbox.readthedocs.io/en/latest/index.html

---------

Co-authored-by: Simon Graham <[email protected]>
Co-authored-by: Shan Raza <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Add engine for the multi-task segmentor to allow simultaneous instance segmentation of nuclei and the semantic segmentation of regions. This replaces commit #216 due to history error in old PR.

TODO
====

- [x] Update unit testing
- [x] Add argument to store instance segmentation outputs as .dat files and semantic segmentation outputs as .npy
- [x] Update Notebook

---------

Co-authored-by: John Pocock <[email protected]>
Co-authored-by: Shan E Ahmed Raza <[email protected]>
- Use `logger` Instead Of `warnings` for `wsireader.py`

---------
Co-authored-by: Mark Eastwood <[email protected]>
- Add a script to update notebook URLs to match the current git ref.

This can be run with `make`. This will pass in all files in `examples`, uses the current branch name as the 'to' ref, and "develop" as the 'from' ref.
```bash
make update-notebook-urls
```

You can also run the script manually. If run manually, you can specify the target ref and input files.

```bash
python pre-commit/notebook_urls.py --from develop --to dev-notebook-urls-hook examples/*
```

---------

Co-authored-by: Shan E Ahmed Raza <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Move requirements*.txt  to requirements folder

---------

Co-authored-by: Mostafa Jahanifar <[email protected]>
pre-commit-ci bot and others added 17 commits October 18, 2024 12:00
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](pre-commit/pre-commit-hooks@v4.6.0...v5.0.0)
- [github.com/astral-sh/ruff-pre-commit: v0.6.5 → v0.6.9](astral-sh/ruff-pre-commit@v0.6.5...v0.6.9)

* 🐛 Fix pre-commit yaml

* 🧑‍💻 Change to monthly schedule.

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/executablebooks/mdformat: 0.7.17 → 0.7.18](hukkin/mdformat@0.7.17...0.7.18)
- [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](pre-commit/pre-commit-hooks@v4.6.0...v5.0.0)
- [github.com/astral-sh/ruff-pre-commit: v0.6.5 → v0.6.9](astral-sh/ruff-pre-commit@v0.6.5...v0.6.9)

* 🔀 Merge online and local copies

* 📌 Pin dependencies

* 📌 Pin `ruff` version

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Shan E Ahmed Raza <[email protected]>
- Adds the ability to get patches filtered by class or label using AnnotationStore.
- Allows the user to provide a path to an annotation store as the mask. 
  - By default the mask will then be built out of all the annotations, but the user can also provide any filter that works in the annotation store, and have only those annotations make the mask. 

For example, if the user have some pathologist annotations with some regions, and they would only want to extract patches which have some overlap with regions labelled 'tumor' or any other class, they would just need to provide the appropriate string ("props['label'] == 'tumor'" for example).

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- `numpy>=2.0` breaks the tests.
- Adds a warning to the `VahadaneExtractor` to inform users about the algorithm's instability due to changes in the dictionary learning algorithm in `scikit-learn versions > 0.23.0 (see issue #382)`. 
- The docstrings are updated accordingly to reflect this warning. 
- No other functionality is altered.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…Path`, `H-optimus-0` (#856)

- Integrates pre-trained foundation models from other labs into tiatoolbox.models.architecture.vanilla.py.

Currently, the `_get_architecture()` function allows the use of models from `torchvision.models`.

A new function `_get_timm_architecture()` has been incorporated to support foundation models which are available from `timm` with weights on HuggingFace Hub. 

- All the models from `timm` that used require users to sign the licence agreement with the authors.
- The users can add new models by modifying `_get_timm_architecture()`

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Shan E Ahmed Raza <[email protected]>
* 🧑‍💻 pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.7.0 → v0.7.2](astral-sh/ruff-pre-commit@v0.7.0...v0.7.2)

* 📌 Update `ruff` version.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Shan E Ahmed Raza <[email protected]>
- Integrates PyTorch 2.0's [torch.compile](https://pytorch.org/docs/stable/generated/torch.compile.html) functionality to demonstrate performance improvements in torch code. This PR focuses on adding `torch.compile` to `PatchPredictor`.

**Notes:**
- According to the [documentation](https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html), noticeable performance can be achieved when using modern NVIDIA GPUs (H100, A100, or V100)

**TODO:**
- [x] Resolve compilation errors related to using `torch.compile` in running models
- [x] Initial config
- [x] Add to patch predictor
- [x] Add to registration
- [x] Add to segmentation
- [x] Test on custom models
- [x] Test on `torch.compile` compatible GPUs

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Shan E Ahmed Raza <[email protected]>
Co-authored-by: Jiaqi-Lv <[email protected]>
- Add changes from New engine design #578. This will not only simplify the PR but also keep the main repo up to date.
- Refactor `model_to` to `model_abc`
- Instead of `on_gpu` use `device` as an input in line with `PyTorch`.
- `infer_batch` uses `device` as an input instead of `on_gpu`
- `torch.compile` is not currently compatible with Windows. See pytorch/pytorch#122094
- Update Jupyter Notebooks for the New Release
- Fix issues with API changes e.g., device instead of ON_GPU flag.
- Update `ruff` Version to `v0.8.1`

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
<!--pre-commit.ci start-->
updates:
- [github.com/executablebooks/mdformat: 0.7.18 → 0.7.19](hukkin/mdformat@0.7.18...0.7.19)

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Shan E Ahmed Raza <[email protected]>
- Add Example Notebook to explain how to use Foundation Models from `timm` module in TIAToolbox.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Shan E Ahmed Raza <[email protected]>
- Fix `benchmarks/annotation_store.ipynb` errors
- Merge branch 'master' into pre-release
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@shaneahmed shaneahmed added this to the Release v1.6.0 milestone Dec 5, 2024
Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.90%. Comparing base (490be26) to head (e118983).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #895      +/-   ##
==========================================
- Coverage   99.91%   99.90%   -0.01%     
==========================================
  Files          69       69              
  Lines        8518     8715     +197     
  Branches     1637     1149     -488     
==========================================
+ Hits         8511     8707     +196     
- Misses          0        3       +3     
+ Partials        7        5       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shaneahmed shaneahmed self-assigned this Dec 10, 2024
@shaneahmed shaneahmed merged commit e14a4fc into master Dec 12, 2024
39 of 40 checks passed
@shaneahmed shaneahmed deleted the pre-release branch December 12, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.