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

✨ NEW: Add Nucleus Detection Engine #538

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from

Conversation

shaneahmed
Copy link
Member

  • Add Nucleus Detection Engine
  • Fix documentation in patch_predictor.py

- Add Nucleus Detection Engine
- Fix documentation in patch_predictor.py
@shaneahmed shaneahmed marked this pull request as draft February 16, 2023 13:18
- Improve structure of init
@shaneahmed shaneahmed self-assigned this Feb 16, 2023
@codecov
Copy link

codecov bot commented Feb 16, 2023

Codecov Report

Merging #538 (6368325) into develop (25f5f3d) will decrease coverage by 0.15%.
The diff coverage is 100.00%.

❗ Current head 6368325 differs from pull request most recent head 7989aa7. Consider uploading reports for the commit 7989aa7 to get more accurate results

@@             Coverage Diff             @@
##           develop     #538      +/-   ##
===========================================
- Coverage    99.77%   99.63%   -0.15%     
===========================================
  Files           64       63       -1     
  Lines         6817     6642     -175     
  Branches      1101     1078      -23     
===========================================
- Hits          6802     6618     -184     
- Misses           7       15       +8     
- Partials         8        9       +1     
Impacted Files Coverage Δ
tiatoolbox/models/engine/__init__.py 100.00% <ø> (ø)
tiatoolbox/models/engine/semantic_segmentor.py 100.00% <ø> (ø)
tiatoolbox/models/engine/nucleus_detector.py 100.00% <100.00%> (ø)
tiatoolbox/models/engine/patch_predictor.py 100.00% <100.00%> (ø)

... and 24 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

- Add documentation for mapde and sccnn
- Add a test for nucleus detection
- Fix input in patch predictor test
- Fix mpp for cell detection
…-engine

# Conflicts:
#	docs/pretrained.rst
#	tiatoolbox/data/pretrained_model.yaml
- Fix bug with loading NucleusDetector
- Fix bug with loading sccnn
- Fix test bug in test_patch_predictor.py
- Add test for NucleusDetector
@shaneahmed shaneahmed marked this pull request as ready for review February 21, 2023 17:42
- Set GPU

Signed-off-by: Shan E Ahmed Raza <13048456+shaneahmed@users.noreply.github.com>
- Add test to improve coverage
@shaneahmed shaneahmed added the enhancement New feature or request label Feb 22, 2023
Copy link
Collaborator

@mostafajahanifar mostafajahanifar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Shan for doing this important PR.
I made some comments. As we mentioned before, I believe this engine requires some special consideration in the design, especially for post-processing. However, if we want to have it in its current shape for now, it needs some changes as well as some more rigorous testing. For example, how does the algorithm work on a slightly large WSI on a mediocre system (16-32GB RAM)?
Also, we need to consider the detection class and probability in the outputs as well because there might be some models that predict these parameters too.

tiatoolbox/models/engine/nucleus_detector.py Show resolved Hide resolved
)


class IONucleusDetectorConfig(IOSegmentorConfig):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current shape, defining this new class seems unnecessary because there is no change to IOSegmentorConfig. I see no reason why we could not use the main class.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree I can remove this for now.

tiatoolbox/models/engine/nucleus_detector.py Show resolved Hide resolved
tiatoolbox/models/engine/nucleus_detector.py Show resolved Hide resolved
# Coordinates in output resolution for the current canvas.
cum_canvas = np.expand_dims(cum_canvas, axis=0)
coordinates_canvas = pd.DataFrame(
self.model.postproc_func(cum_canvas), columns=["x", "y"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that engine is written like this, the post_proc function should be working with all detection models. There are two major things to consider:
1- this part should be compatible with all the detection models
2- this part should also support prediction class and prediction probability of detections (if available)

Therefore, it seems that we either need to update the postproc function of the detection networks to return the results in a predefined structure ([x, y, cls, prob]) and then convert the results properly here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I wonder if the post-processing works with large WSIs? as it seems that results are saved in high resolution and then the whole canvas is passed to the post-processing.

@shaneahmed shaneahmed added this to the Release v2.0.0 milestone Apr 10, 2023
# Conflicts:
#	tiatoolbox/models/engine/patch_predictor.py
#	tiatoolbox/models/engine/semantic_segmentor.py
- Pin `torch` version
- Pin `torch` version
- Try cuda 11.8 to run the tests as it passes locally.

Signed-off-by: Shan E Ahmed Raza <13048456+shaneahmed@users.noreply.github.com>
@shaneahmed shaneahmed added the stale Old PRs/Issues which are inactive label Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale Old PRs/Issues which are inactive
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants