## 2 Materials and Methods
### Proposed Segmentation Algorithm  
The algorithm can segment N regions of interest (ROIs) at one time by initializing N + 1 different labels, where the additional one accounts for the \"background\". As a first step, the user briefly draws over the different ROIs using distinct labels (Figure 1). All co-registered images are given to the algorithm as input. Every available co-registered sequence can be included; for instance, in brain tumor applications, this typically includes FLAIR, T1, T2, T1 Gd. Pre-processing is performed for anisotropic and/or large images. With a margin of 0.1 mm, if the input images have anisotropic spacing, i.e., the largest and the smallest voxel spacing values of an image are different by more than 0.1 mm, images are resampled to have the same spacing in all dimensions. The new selected universal spacing value is the lowest value, equal or higher than the lowest spacing value of the original images, that allows the resultant image to have less than 10 million voxels. The voxel number threshold was implemented for performance reasons. Likewise, if isotropic input images have more than 10 million voxels, they are resampled to the lowest spacing value, in all dimensions, that allows the voxel count to not exceed that limit. Resampling of labeled images is done using the nearest neighbor interpolation. The aforementioned resampling operations are part of the implementation and are not expected to be performed by the user. Results are always resampled back to the original image space. Lastly, all images are standardized to have 0 mean and 1 standard deviation. For each pair of image and class labels, an adaptive geodesic distance (AGD) map [17] (Figure 2) is produced reflecting a composite of intensity and spatial distance from the drawings, such that voxels far away and/or with very different intensity have higher values. The process is parallelized; each AGD map is created independently of each other. AGD maps are normalized in the [0, 1] range. To provide more spatial information, three \"coordinate\" maps are used, one for each dimension of the image, where the values range from 0 to the size of the image in that dimension. Figure 1: Example showcasing the result improving as a function of invested time. In the first iteration, the user quickly draws over the different areas. In the second iteration, the user places few additional labels to correct representative misclassified areas, which are then used to retrain the machine learning model. From left to right: (**a**) Anatomical image; (**b**) User annotations; (**c**) Result segmentation; (**d**) Ground truth segmentation. Figure 2: Example of AGD maps. Darker values indicate lower adaptive geodesic distance from the user drawings. In glioblastoma, non-enhancing tumor (NE) and enhancing tumor (ET) boundaries are clearer in T1 CE, while the boundary between edema (ED) and background is clearer in FLAIR. From left to right: (**a**) Anatomical image; (**b**) User annotations; (**c**) Adaptive geodesic distance (AGD) map for NE annotation; (**d**) AGD map for ET; (**e**) AGD map for peritumoral edematous/infiltrated tissue (ED); (**f**) AGD map for background. Images are parsed using ITK [23] iterators and the image values are added to a two dimensional array (OpenCV's [24] mat implementation is used), where size across the first dimension is the number of pixels/voxels in an image and across the second is the number of co-registered images. Likewise, pixels/voxels of the labeled image are added to a one-dimensional array. Only labeled samples are used for training. For performance reasons, if the number of labeled samples exceeds 3000, a balanced, i.e., retaining the ratio of samples per class, subset of 3000 labeled samples is used for training. Lastly, the selected training and labeled data are added to OpenCV's \"TrainData\" structure, which is the format expected by the OpenCV's machine learning implementations. An ensemble [25] of SVMs is trained on voxels that belong to the drawings and segments the remainder of the image.