## 2 Materials and Methods
### OCT Data Acquisition and Image Processing
#### 2.3.2 Determination of the Weld Seam  
Scattering and absorption within the sample attenuate the detected OCT signal with depth (\(z\)-direction). In deeper regions, the measurement beam is weaker, and a smaller portion of reflected light reaches the detector. This leads to a signal/brightness gradient in the data, which makes automated evaluation difficult. To overcome this issue, the average brightness of every image row (\(y\)-direction) was calculated in MATLAB. The result was smoothed using a moving mean over 50 rows and was saved as a greyscale image with constant brightness per row, which was used as a background image. Thereafter, the original image was divided pixel wise by this background image using the \"_Calculator Plus_\" function in ImageJ. This gave an image in which the detected signal was independent of the depth-dependent attenuation.  
To determine the area of the weld seam, the contrast was improved using the \"_enhance contrast_\" function with default parameters and the image was converted into binary. In contrast to the previously mentioned identification of the margins, the \"_isodata_\"-algorithm [34] and no fixed threshold were used. Since the weld seam does not always clearly differ from the surrounding bulk material, several regions (possible weld seam areas) remained in the B-scan. To remove noise and refine the selection, after using \"_remove outliers_\" with radius 5 and threshold 50, the blockwise \"_remove outliers_\" function was utilized, where the horizontal (\(y=30\)) and the vertical (\(z=5\)) size of the rectangle used for filtering can be defined. This makes use of the fact that in a B-scan, the longer axis of the weld seam is vertical (\(z\)-direction), enabling the distinction from horizontally (\(y\)-direction)-aligned features caused, for example, by the melt flow during injection molding.  
After using the \"_find connected regions_\"-algorithm, which only detects areas larger than 1500 pixels (0.01 mm\({}^{2}\)), the remaining areas were filtered by size and position. All regions adjacent to the left, right or bottom margin of the scan, larger than 20,000 pixels (0.11 mm\({}^{2}\)) or not containing any pixel in the region 0.12 mm above or below the joining zone were not transferred to MATLAB. In MATLAB, the width \(w\) and the distances between the upper surface and the upper (\(U\)) and lower (\(L\)) end of the weld seam were measured, and the seam height \(h\) (\(L-U\)) was calculated. Subsequently, the aspect ratio \(k\) of width to height was checked (\(k=h/w\)). Only areas with an aspect ratio between 3 and 5 were considered, and remaining outliers (defined as a value more than three scaled median absolute deviations away from the median) were removed. The image was concatenated into a three-dimensional array, and the next image was processed. Figure 3d shows the result after processing all images. All data were recorded and processed with identical parameters. We determined the mentioned parameters once for the best identification of U and L in a few B-scans, and no further adaptions, e.g., depending on the weld seam size, were performed.