Skip to content

Commit

Permalink
add patch iterator with mask test
Browse files Browse the repository at this point in the history
  • Loading branch information
martvanrijthoven committed Jul 12, 2024
1 parent 7d78cef commit e80a19e
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions tests/patch_iterator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,37 @@


def test_patch_iterator():
with create_patch_iterator(
image_path="/tmp/TCGA-21-5784-01Z-00-DX1.tif",
patch_configuration=PatchConfiguration(spacings=(32,)),
) as patch_iterator:
for patch in patch_iterator:
patch_configuration = PatchConfiguration(patch_shape=(1024,1024,3),
spacings=(0.5,),
overlap=(0,0),
offset=(0,0),
center=False)

with create_patch_iterator(image_path='/tmp/TCGA-21-5784-01Z-00-DX1.tif',
patch_configuration=patch_configuration,
cpus=4,
backend='openslide') as patch_iterator:

print(f"Number of patches {len(patch_iterator)}\n")
assert len(patch_iterator) == 900
for idx, (patch, info) in enumerate(patch_iterator):
pass


def test_patch_iterator_with_mask():
patch_configuration = PatchConfiguration(patch_shape=(1024,1024,3),
spacings=(0.5,),
overlap=(0,0),
offset=(0,0),
center=False)

with create_patch_iterator(image_path='/tmp/TCGA-21-5784-01Z-00-DX1.tif',
mask_path='/tmp/TCGA-21-5784-01Z-00-DX1_tb_mask.tif',
patch_configuration=patch_configuration,
cpus=4,
backend='asap') as patch_iterator:

print(f"Number of patches {len(patch_iterator)}\n")
assert len(patch_iterator) == 352
for idx, (patch, mask, info) in enumerate(patch_iterator):
pass

0 comments on commit e80a19e

Please sign in to comment.