## Module: Extract Regular Patches (
)

### Description:

> This is an experimental module from the Xtra Library: https://xtras.amira-avizo.com.

> This module allows extracting 2D image patches of fixed size, mostly for training deep learning models. The primary purpose is to split a volume formed with few large slices into smaller slices to be presented to the deep learning training module, to better control the data that is used for training and validation, and the random selection of training patches performed in this module.

> Only patches that are fully inside the bounding box of the input image will be generated, so the right-most and bottom-most pixels will be ignored (pixels with large X and Y indices).

> If a disk export is requested, each patch is exported as a TIF file in the output folder. The filename is defined by the requested base filename, and the patch number following the indices of the corresponding landmarks. Please note that label images will not be re-interpreted automatically as such when loaded back in the software. This is not problematic for Deep Learning Training, but you may use Convert Image Type to a label type if necessary for visualization or manual segmentation.

### Connections:

> Data `[required]`
> Input image.

### Ports:

> Console
> Opens the Python Script Object console of the module as the active console window.

> Mode
> Choose between 2D and 3D patches.

> Size of Patches [px]
> Size of the image patches to be extracted, in number of voxels.

> Number of Patches
> Number of patches to be extracted, determined by the size of the input Data and the Size of Patches

> Export Type
> Selects whether the module will generate an output dataset in the application, or export the patches as TIF files on the disk.

> Output Directory
> Directory in which the image patches will be saved. It is recommended to indicate an empty directory.

> Base Filename
> The filename name will be composed of this basename, an underscore character "_", and the index of the corresponding landmark. For 3D patches, the slice index will also be indicated. Zeros are appended in front of the index to ensure proper alphanumeric sorting (e.g. patch_00012.tif).