## 2 Experimental Setup  
For training the CNN, we use experimental data. Therefore, we use a home-built confocal microscope setup, as shown in Figure 1. The laser source is a Thorlabs CPS532 laser with 4.5 mW power operating at a wavelength of \(\lambda~{}=~{}532\) nm. The beam passing the AL and the lenses L2 and L3 is divided by a beamsplitter into the measurement and the monitoring beams. The monitoring beam is directed onto a camera through lens L5, where the input image for the CNN is captured. L4 (Ashperical Lens 354453, Thorlabs Inc.,Bergkirchen, Germany) focuses the measurement beam into the region of interest. Here, an aspherical lens was used as a front lens. For calibration, a mirror which is located on a movable stage (stage controller XPS-Q8 and motorized actuators LTA-HS, Newport Corporation, Irvine, CA) is used as a sample. This stage is movable in three axes, but for the data acquisition, it has only been moved in the axial z-direction. The lenses L2 and L3 form a 4f-system that images the AL close to L4, which minimizes aberrations of the adaptive lens but still offers a high tuning range as described in [26]. The reflected light goes back, passing the 4f-system, is focused through the pinhole (\(d~{}=~{}5~{}\upmu\)m from Thorlabs Inc.), and is measured with a detector (HCA-S Femto, Berlin, Germany). The light originating from out-of-focus regions is blocked by the pinhole. When the mirror is driven through the focus, the intensity distribution measured on the detector gives both the focus position and the axial resolution. If the voltage applied on the AL is changed, the peak of the intensity is shifted, and the focus position can be determined. The working principle of the AL is shown in Figure 2.  
Figure 1: Confocal microscopic setup with adaptive lens, AL= adaptive lens, L = lens, MMF = multi-mode fibre, PMT = detector, PH = pinhole. Figure 2: (a) Conventional lens with fixed focal spot. (b) AL enables axial scanning by shifting the focal spot; this is achieved by a deformation of the membrane of the lens. Assuming the lateral resolution in a confocal microscope to be defined as in Equation (2) and the axial resolution as in Equation (3) from [27]:  
\[\Delta x,\Delta y=\frac{0.51\cdot\lambda}{NA_{AL}} \tag{2}\]  
\[\Delta z=\frac{0.64\cdot\lambda}{n-\sqrt{n^{2}-NA_{AL}^{2}}}. \tag{3}\]  
With \(\lambda~{}=~{}570\) nm as the average wavelength of emission and excitation (defined by Equation (4)), \(n\) is the refractive index and \(NA_{AL}\) is the numerical aperture. \(NA_{AL}\) can be derived from Equation (5), here, this is the numerical aperture, which changes when a voltage is applied to the AL (induced by a change of the focal length \(f_{obj}\)) [27]:  
\[\lambda=\sqrt{2}\cdot\frac{\lambda_{ex}\cdot\lambda_{em}}{\sqrt{\lambda_{ex}^{ 2}+\lambda_{em}^{2}}} \tag{4}\]  
\[NA_{AL}=n\cdot sin(\alpha)=n\cdot sin(arctan(\frac{f_{obj}}{r})) \tag{5}\]  
Here, the refractive index is assumed as \(n~{}=~{}1\), \(r\) is the half size of the spot in front of L4, and \(f_{obj}\) is the focal length behind L4, influenced by the AL (\(f_{obj}~{}=~{}4.61\) mm while 0V applied). The spot size of the laser beam is \(d~{}=~{}10\) mm, so \(r\) is 5 mm; thereby, \(NA\) is calculated as 0.68. So, the lateral resolution becomes 0.4 \(\upmu\)m, and the axial resolution is 1.4 \(\upmu\)m. The radius of the Airy disk can be calculated according to Equation (6) [27]:  
\[r_{Airy}=\frac{0.61\cdot\lambda}{NA_{AL}}. \tag{6}\]  
This leads to a radius of the Airy disk of 0.5 \(\upmu\)m:  
\[r_{PH,proj}=\frac{r_{PH}}{M}. \tag{7}\]  
Figure 2.0  
\(M\) is the overall magnification of the setup, which can be stated as 10.7, \(r_{PH}\) is the size of the pinhole.