Patch Extraction Tools for Deep Learning data preparation
A set of tools dedicated to preparation of data for training Deep Learning models and reducing annotation time.
This Xtra proposes 5 modules aiming at a better control on the data preparation for training Deep Learning models, through the extraction of image patches of a fixed size. Patches can be extracted manually, randomly, or regularly across the input volume, and at repeatable positions.
A slide deck is included, giving some instructions and context for using these modules.
A workflow for focusing manual segmentation of the patches with their 3D context is also proposed.
The modules are the following:
RandomLandmarks: can generate random landmarks in the bounding box of the data (or a ROI), using uniform but possibly ‘stratified’ sampling independent in X/Y/Z. The module can also randomize the order of an existing set of landmarks, which could for instance, have been manually created with the Landmark Editor.
MaskforPatches: generate a binary image, the same size as the input image, which contains value 1 in XY patches of fixed size around the input landmarks, and 0 elsewhere. Only full patches are considered: if a landmark is too close to the image boundary, it is not taken into account. This is helpful to visualize the location of the patches, but also to navigate through them in the Segmentation Editor using the ‘next slice’ selection feature, so you may proceed with manual segmentation of these patches while observing the context.
ExtractPatches: extract the XY patches of defined size centered around input landmarks, either as an in-memory volume or as a set of 2D TIF images. Only full patches are considered: if a landmark is too close to the image boundary, it is not taken into account. The order of the landmark set defines the order of the slices in the output volume, or the name of the patch file.
ExtractSlices: extracts a fixed number of XY slices, using random uniform stratified sampling, and creates an image out of it. The list of slices is shown, can be manually copy-pasted as a parameter ; or re-used for extracting the same slices in the same order for a second dataset.
ExtractRegularPatches: extract adjacent patches of fixed size on all XY slices, to pile them up. Useful for datasets containing only one or few large slices.
Illustrations use an SOFC dataset courtesy of Sabanci University, Turkey