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

Fix row-column/X-Y coordinates mix-up in Random Tiler #317

Merged
merged 12 commits into from Sep 5, 2021

Conversation

alessiamarcolini
Copy link
Collaborator

@alessiamarcolini alessiamarcolini commented Aug 31, 2021

Description

This PR fixes the mismatch between row-column / X-Y coordinates in the RandomTiler. In the end, the result was correct due to a double bug, but know they should both be fixed.

Moreover, it fixes inverted y_ul and x_br in CoordinatePair used in unit testing (causing no harm), and it moves the conversion from np coords to PIL coords to regions_from_binary_mask

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@alessiamarcolini alessiamarcolini added the bug Something isn't working label Aug 31, 2021
@alessiamarcolini alessiamarcolini added this to In progress in histolab via automation Aug 31, 2021
@alessiamarcolini alessiamarcolini added this to the 0.2.7 milestone Aug 31, 2021
@codecov
Copy link

codecov bot commented Aug 31, 2021

Codecov Report

Merging #317 (7fe6469) into master (fbfc897) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #317   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           17        17           
  Lines         1284      1285    +1     
  Branches       124       124           
=========================================
+ Hits          1284      1285    +1     
Impacted Files Coverage Δ
src/histolab/tiler.py 100.00% <ø> (ø)
src/histolab/util.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fbfc897...7fe6469. Read the comment docs.

Copy link
Member

@ernestoarbitrio ernestoarbitrio left a comment

Choose a reason for hiding this comment

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

I like the fix ❤️ thx

Some comments before i can do another review round :D

src/histolab/util.py Outdated Show resolved Hide resolved
src/histolab/util.py Outdated Show resolved Hide resolved
@@ -123,7 +123,7 @@ def it_locates_tiles_on_the_slide(
slide = Slide(fixture_slide, "")
random_tiles_extractor = RandomTiler(
tile_size=tile_size,
n_tiles=2,
n_tiles=100,
Copy link
Member

Choose a reason for hiding this comment

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

did you consider the performance during testrunner increasing the n tiles of 2 order of magnitude?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did consider it, but the point is that with only 2 tiles we cannot really see how the tiler is sampling the tiles, if you compare the old and new expectations you will see that only now this test is really meaninfgul

tests/integration/test_util.py Show resolved Hide resolved
setup.cfg Outdated Show resolved Hide resolved
tests/unit/test_tiler.py Outdated Show resolved Hide resolved
src/histolab/util.py Outdated Show resolved Hide resolved
@alessiamarcolini
Copy link
Collaborator Author

@ernestoarbitrio to do what you suggest I need to unroll the list comprehension to a normal for statement.. I will do that

@ernestoarbitrio
Copy link
Member

ernestoarbitrio commented Sep 1, 2021

@ernestoarbitrio to do what you suggest I need to unroll the list comprehension to a normal for statement.. I will do that

Actually i think you can still use comprehension if you write an internal function that given the rp.bbox it gives you back the correct new bbox shape. Hope i have been clear

@alessiamarcolini
Copy link
Collaborator Author

alessiamarcolini commented Sep 1, 2021

actually this code is wrong..

bbox = list(reversed(rp.bbox))
and then in the Region pass bbox=[*bbox[:2], *bbox[2:]]

I need to "split" the tuple in two and then individually reverse.. anyway I will implement it in a subfunction

It would be like this in the end bbox_pil = [*reversed(bbox_np[:2]), *reversed(bbox_np[2:])].

Copy link
Member

@ernestoarbitrio ernestoarbitrio left a comment

Choose a reason for hiding this comment

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

LGTM, just 1 minor thing. Good to go after this

src/histolab/util.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@kheffah kheffah left a comment

Choose a reason for hiding this comment

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

Thanks @alessiamarcolini for this important PR! All looks good to me.

@ernestoarbitrio ernestoarbitrio merged commit cc4a8ea into master Sep 5, 2021
histolab automation moved this from In progress to Done Sep 5, 2021
@ernestoarbitrio ernestoarbitrio deleted the fix-inverted-coords branch September 5, 2021 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
histolab
  
Done
Development

Successfully merging this pull request may close these issues.

Row-column X, Y coordinate mix-up in RandomTiler
3 participants