Skip to content

Conversation

@bhashemian
Copy link
Member

@bhashemian bhashemian commented May 6, 2022

Fixes #4179

Description

This PR implements SlidingPatchWSIDataset that extract patches from one or multiple whole slide images in a sliding-window manner. This is useful for the inference of the pathology pipelines.

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

bhashemian added 8 commits May 2, 2022 18:58
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
@bhashemian bhashemian requested review from Nic-Ma and wyli May 6, 2022 19:51
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
@bhashemian bhashemian requested a review from wyli May 9, 2022 18:47
@bhashemian
Copy link
Member Author

Hi @Nic-Ma can you too help to review this PR? Thanks

Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Copy link
Contributor

@wyli wyli left a comment

Choose a reason for hiding this comment

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

thanks, please see some comments inline

Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
Copy link
Contributor

@wyli wyli left a comment

Choose a reason for hiding this comment

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

thanks, this enhances the sliding window functions and adds wsi sliding window support.

@wyli
Copy link
Contributor

wyli commented May 25, 2022

/build

@wyli
Copy link
Contributor

wyli commented May 25, 2022

there's a test error...

[2022-05-25T13:08:02.322Z] ======================================================================
[2022-05-25T13:08:02.322Z] FAIL: test_read_patches_9 (tests.test_sliding_patch_wsi_dataset.TestSlidingPatchWSIDatasetCuCIM)
[2022-05-25T13:08:02.322Z] ----------------------------------------------------------------------
[2022-05-25T13:08:02.322Z] Traceback (most recent call last):
[2022-05-25T13:08:02.322Z]   File "/opt/conda/lib/python3.8/site-packages/parameterized/parameterized.py", line 533, in standalone_func
[2022-05-25T13:08:02.322Z]     return func(*(a + p.args), **p.kwargs)
[2022-05-25T13:08:02.322Z]   File "/home/jenkins/agent/workspace/MONAI-premerge/monai/tests/test_sliding_patch_wsi_dataset.py", line 227, in test_read_patches
[2022-05-25T13:08:02.322Z]     self.assertEqual(len(dataset), len(expected))
[2022-05-25T13:08:02.322Z] AssertionError: 1 != 2
[2022-05-25T13:08:02.322Z] 
[2022-05-25T13:08:02.322Z] ----------------------------------------------------------------------

with nvcr.io/nvidia/pytorch:22.04-py3 V100, please let me know if you need more info to debug

I think the class could inherit Randomizable to ensure the deterministic behaviour e.g.

class MedNISTDataset(Randomizable, CacheDataset):

@bhashemian
Copy link
Member Author

there's a test error...

[2022-05-25T13:08:02.322Z] ======================================================================
[2022-05-25T13:08:02.322Z] FAIL: test_read_patches_9 (tests.test_sliding_patch_wsi_dataset.TestSlidingPatchWSIDatasetCuCIM)
[2022-05-25T13:08:02.322Z] ----------------------------------------------------------------------
[2022-05-25T13:08:02.322Z] Traceback (most recent call last):
[2022-05-25T13:08:02.322Z]   File "/opt/conda/lib/python3.8/site-packages/parameterized/parameterized.py", line 533, in standalone_func
[2022-05-25T13:08:02.322Z]     return func(*(a + p.args), **p.kwargs)
[2022-05-25T13:08:02.322Z]   File "/home/jenkins/agent/workspace/MONAI-premerge/monai/tests/test_sliding_patch_wsi_dataset.py", line 227, in test_read_patches
[2022-05-25T13:08:02.322Z]     self.assertEqual(len(dataset), len(expected))
[2022-05-25T13:08:02.322Z] AssertionError: 1 != 2
[2022-05-25T13:08:02.322Z] 
[2022-05-25T13:08:02.322Z] ----------------------------------------------------------------------

with nvcr.io/nvidia/pytorch:22.04-py3 V100, please let me know if you need more info to debug

I think the class could inherit Randomizable to ensure the deterministic behaviour e.g.

class MedNISTDataset(Randomizable, CacheDataset):

@wyli
I'll add the Randomizable but with set_determinisim (and using numpy random), I'm wondering why it should produce different results! Do you have any idea?

@wyli
Copy link
Contributor

wyli commented May 25, 2022

I guess because there are multiple skipUnless in the tests, depending on the skipping conditions the np.random.randint is called various times:

return tuple(np.random.randint(low, high) for low, high in offset_limits)

with the randomizable API, it's possible to use self.R.randint(low, high), so that it controls the local random state. pls see the seed usage: (
data = MedNISTDataset(root_dir=testing_dir, transform=transform, section="test", download=False, seed=42)
)

Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
@wyli
Copy link
Contributor

wyli commented May 26, 2022

/build

@wyli wyli disabled auto-merge May 26, 2022 12:39
@wyli wyli enabled auto-merge (squash) May 26, 2022 12:39
@wyli
Copy link
Contributor

wyli commented May 26, 2022

/build

1 similar comment
@wyli
Copy link
Contributor

wyli commented May 26, 2022

/build

@bhashemian
Copy link
Member Author

@wyli, it seems that blossom-ci has failed. Can you provide details about it? Thanks

@wyli
Copy link
Contributor

wyli commented May 26, 2022

I think the current errors are irrelevant to the PR, I'm working on it

bhashemian added a commit to bhashemian/MONAI that referenced this pull request May 26, 2022
Signed-off-by: Behrooz <3968947+drbeh@users.noreply.github.com>
@wyli wyli merged commit 95b7c4f into Project-MONAI:dev May 26, 2022
@bhashemian bhashemian deleted the sliding-patch branch May 26, 2022 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sliding Patch WSIReader for Inference

4 participants