## 2 Materials and Methods
### Data Set Generation
#### 2.1.2 Segmentation Data Set Preparation and U-NET Model Training  
The first step of our work was to create a segmentation model for later data pre-processing. Figure S2 shows the order and method in which we processed the original hematoxylin and eosine (HE)-images to develop a U-Net model. Therefore, a segmentation data set is needed. Whole slide colorectal tissue specimens with varying pathologies were retrieved from the collection of the Institute of Pathology at the University Medical Centre Mannheim and used in a completely anonymous way. No patient information like age or gender is included. Only the histological diagnosis (normal colorectal tissue, colorectal cancer CRC, ulcerative colitis, high grade intra-epithelial neoplasia (HGIEN), low grade intra-epithelial neoplasia (LGIEN) are used. The collection and management of this data set is in accordance with the local ethics committee in Mannheim (decision 2017-806R-MA). The final dataset contained n = 29 WSIs (n = 21 for tumor, n = 1 each for high-grade and low-grade intra-epithelial neoplasia (IEN), n = 5 for ulcerative colitis, n = 1 for healthy tissue). The whole tissue sections (HE-stained) were scanned by a M8 microscope and scanner (PreciPoint GmbH, Garching b. Munchen, Germany). The resulting WSIs are saved in the.svs format. Using QuPath (version 0.1.2 and v0.2.0) the WSIs of the segmentation data set were manually segmented (example shown in Figure S2). For this manual segmentation, 13 labels were defined, with a ratio of area per label depicted in Table S1. The raw.svs images and the label masks were automatically cropped into 1000 \(\times\) 1000 pixel-sized tiles by a QuPath-script published by [PERSON] ([[https://github.com/m4](https://github.com/m4) ln/dupath-scripts]([https://github.com/m4](https://github.com/m4) ln/dupath-scripts) (accessed on 30 November 2023)) and normalized regarding staining with a tool previously described by [PERSON] et al. [18]. This yielded a data set containing pairs of tiles, each with a label mask and the corresponding HE-frame. The data set was then randomly split into three parts training (75%), validation (15%) and testing (10%). For the segmentation task, a U-Net implementation in PyTorch (version 1.3) from the Segmentation Models toolbox by [PERSON] was downloaded from GitHub [19; 20; 21]: ([[https://github.com/choosehappy/PytorchDigitalPathology/tree/master/segmentation_epistroma_unet](https://github.com/choosehappy/PytorchDigitalPathology/tree/master/segmentation_epistroma_unet)]([https://github.com/choosehappy/PytorchDigitalPathology/tree/master/segmentation_epistroma_unet](https://github.com/choosehappy/PytorchDigitalPathology/tree/master/segmentation_epistroma_unet)) (accessed on 30 November 2023)) and adapted for multi-class segmentation. A learning rate scheduler was implemented using an Adam optimizer for efficient training [22]. Against the background of heterogeneously shaped objects and variations in the saturation of HE-staining transformations of color, size and orientation were applied on randomly selected images. Class weights were used to calculate the Focal-Loss for unbalanced labels [23; 24]. The final code can be seen at [25]. The model reached an accuracy of 0.72 for the validation set. This has been seen as sufficient for this project, as our application does not require a highly specified pixel-wise segmentation but focuses on a rough estimation of the tumor content per tile.