Skip to content

Tiling patches or generate patches of whole slide image based on Openslide

Notifications You must be signed in to change notification settings

xjw00654/WSI_Extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WSI extractor

Tiling patches or generate patches of whole slide image based on Openslide

Basic Functions

  • Tiling patches and saving them to local disk
  • Generate patch generator for testing of WSIs

Usage

  • First assign the slide_folder(will findslides in subfolder(s)) and save_folder.
slide_folder = os.path.join(os.curdir, 'data', 'slide')
save_folder = os.path.join(os.curdir, 'data', 'patch')
  • For tiling patches and saving them to disks
TileSaving(slide_folder, save_folder, n_procs=4, target_size=512, ds_rate=0, black_thresh=50).tiling()
  • For get patch generation (using in the inference code)
loader_sequence = TestDataGenerator(slide_folder).get_patch_generator(mode='sequence')
for patch_gen, idx in loader_sequence:
    for patch, c, r in patch_gen:
        if patch == -1:
            # patch is black
            pass
        elif patch == -2:
            # patch is blank
            pass
        else:
            # patch is valid
            pass

loader_randomly = TestDataGenerator(slide_folder).get_patch_generator(mode='random')
for patch_gen, idx in loader_randomly:
    for patch, c, r in patch_gen:
        if patch == -1:
            # patch is black
            pass
        elif patch == -2:
            # patch is blank
            pass
        else:
            # patch is valid
            pass

About

Tiling patches or generate patches of whole slide image based on Openslide

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages