An automated slide scanning system for membrane filter imaging in diagnosis of urogenital schistosomiasis

Traditionally, automated slide scanning involves capturing a rectangular grid of field‐of‐view (FoV) images which can be stitched together to create whole slide images, while the autofocusing algorithm captures a focal stack of images to determine the best in‐focus image. However, these methods can be time‐consuming due to the need for X‐, Y‐ and Z‐axis movements of the digital microscope while capturing multiple FoV images. In this paper, we propose a solution to minimise these redundancies by presenting an optimal procedure for automated slide scanning of circular membrane filters on a glass slide. We achieve this by following an optimal path in the sample plane, ensuring that only FoVs overlapping the filter membrane are captured. To capture the best in‐focus FoV image, we utilise a hill‐climbing approach that tracks the peak of the mean of Gaussian gradient of the captured FoVs images along the Z‐axis. We implemented this procedure to optimise the efficiency of the Schistoscope, an automated digital microscope developed to diagnose urogenital schistosomiasis by imaging Schistosoma haematobium eggs on 13 or 25 mm membrane filters. Our improved method reduces the automated slide scanning time by 63.18% and 72.52% for the respective filter sizes. This advancement greatly supports the practicality of the Schistoscope in large‐scale schistosomiasis monitoring and evaluation programs in endemic regions. This will save time, resources and also accelerate generation of data that is critical in achieving the targets for schistosomiasis elimination.


INTRODUCTION
][3][4][5] These diseases have a profound impact on public health, affecting millions of individuals and leading to significant morbidity and mortality rates, particularly among vulnerable populations.Accurate and timely diagnosis is critical for prompt precision mapping, effective case management and periodic assessment of interventions overtime.In sub-Saharan Africa, microscopy has long been considered the gold standard for diagnosing parasitic diseases.It enables the visualisation of parasites and their morphological characteristics, facilitating accurate identification and quantification.Microscopic examination of filtered urine samples, stained blood smears, stool smears, and tissue biopsies has played a pivotal role in guiding treatment decisions and controlling the spread of parasitic diseases.Despite its utility, conventional microscopy techniques face several challenges, particularly in sub-Saharan Africa.Limited access to trained personnel and high-quality microscopes in remote and resource-limited areas can hinder timely and accurate diagnosis.The lack of skilled technicians often results in delays and increased diagnostic errors.Additionally, interobserver variability in expertise may lead to discrepancies in parasite detection and misdiagnosis, further impacting patient outcomes. 6][9] Digital microscopes equipped with high-resolution cameras and sophisticated imaging software can capture whole-slide images of specimens.These images can be analysed using artificial intelligence algorithms, enabling automated detection and classification of parasites.The integration of digital optics and artificial intelligence improves diagnostic accuracy, reduces human error and enhances efficiency.
Automated slide scanning systems with artificial intelligence capabilities have the potential to significantly improve and accelerate access to the optical diagnosis of parasitic diseases by overcoming challenges associated with conventional microscopy, such as limited access to skilled technicians and interobserver variability.It captures high-resolution images of entire glass slides, creating a digital representation of the specimen.By leveraging on innovation through advancements in digital optics and artificial intelligence, these technologies offer efficient and accurate parasite detection, facilitating timely interventions, effective disease management and large-scale precision diagnosis during disease mapping and periodic assessment.A fundamental challenge with automated slide scanning systems has been the ability to acquire high-quality, in-focus images at high speed. 10Several studies have implicated poor focus as the main culprit for poor image quality in these systems, [11][12][13] and addressing this challenge is crucial to ensure the successful implementation and widespread adoption.
The autofocusing system, which involves moving a microscope optical train or sample stage along a Z-axis (optical axis) to find an optimal focus position, is a critical feature of automated digital microscopes, ensuring that the image remains sharp and in focus.However, autofocusing algorithms can encounter difficulties, particularly due to the topography of the biological sample and the glass slide underneath having depth variations. 14Reflections, artefacts, and the presence of debris can also hinder accurate autofocusing, potentially impacting the quality of the captured images.Thus, the automated microscope needs to be continuously focused as it moves from one field-of-view to another.
Autofocusing systems can be broadly divided into three categories 10 -focus map surveying, real-time reflection based and real-time image based.Many automated slide scanning systems create a focus map before scanning by acquiring a Z-stack for each point on the map.This method is time-consuming and requires high-precision mechanical systems, increasing the overall system cost.In real-time reflection-based technique, a constant distance between the objective lens and a reference plane is maintained by repeatedly finding the axial location of the reference plane.2][33][34][35] These methods do not require a pregenerated focus map and can handle samples with varying topography.However, they come with their own challenges, such as the need for additional optical hardware, alignment issues and cost considerations.In the case of dual-LED illumination-based autofocusing, it allows real-time single-frame autofocusing, continuous sample motion and cost-effective design.Nonetheless, it may still require an extra camera and optical hardware and may not work well with transparent samples.Although time-consuming, focus map surveying is the most adopted autofocusing method in commercially available whole slide imaging systems.Manufacturers favour this approach because it requires no additional optical hardware, proves to be robust for different types of samples and reduces or eliminates potential intellectual property issues.
In the focus map surveying approach, multiple images are captured along the Z-axis.Then, a figure of merit (FoM) is calculated to evaluate the quality of focus for each image.The image with the highest FoM value is considered the in-focus image. 14,23One major challenge of this method is its time-consuming nature.Additionally, skipping tiles can reduce the focus map surveying time but comes at the expense of accuracy in the resulting focus map. 19Various FoM measures have been used in the literature, initially introduced by Brenner and his colleagues. 36.Commonly used figure of merit (FoM) measures include the derivative of Gaussian, variance of Laplacian, norm of Sobel operator and norm of Boddeke's operator, among others.Nevertheless, the convolution with the derivative of a Gaussian smoothing function has been demonstrated to effectively mitigate the impact of noise on the FoM curve in various optical microscopy techniques, including fluorescence, bright-field and phase contrast microscopy, in both fixed and living cells, as well as in fixed tissue. 37This approach was assessed in tuberculosis microscopy, 38,39 as well as in both bright-field microscopy of stained 40 and unstained cells. 41Autofocusing systems commonly utilise search methods designed to pinpoint the peak of the FoM curve.However, the presence of mechanical backlash complicates the positioning system of the digital microscope, since positions are never fully reproducible. 42Furthermore, in some cases, the FoM curve can have multiple peaks, which may not necessarily correspond to the best focus. 43Thus, FoM-based peak finding may lead to capturing out-of-focus images.
In this paper, we present an automated slide scanning procedure aimed at reducing the imaging time required to capture circular membrane filters in the diagnosis of urogenital schistosomiasis.Our method optimises the scanning path within the sample plane, ensuring that only field-of-views (FoVs) overlapping the filter membrane are captured.Furthermore, we developed an autofocusing algorithm based on hill-climbing to detect the peak of the figure of merit (FoM) curve along the focal plane of the membrane filter.To achieve this, we utilise the mean Gaussian gradient of the FoV image as the FoM due to its unimodal nature when imaging the membrane filter.

PERTURB AND OBSERVE AUTOFOCUSING ALGORITHM
Microscopic imaging of filter membranes for the detection of Schistosoma haematobium eggs in urine usually encounters challenges such as uneven filter membranes, presence of artefacts and deviations in slide angle and stage position. 44All these factors can result in loss of focus when capturing images across different FoVs, thus reducing the readability of the image by both humans and automatic object detection algorithms.Therefore, there is a need for an autofocusing system to ensure that the images captured are always in focus.We present an optimal autofocusing algorithm using a hill-climbing approach called perturb and observe.Perturb and observe algorithm is the most commonly used method in maximum power point tracking of photovoltaic (PV) solar systems due to its ease of implementation and top-level efficiency. 45,46We adapted the perturb and observe algorithm for detecting the best focus plane by including a perturbation in the position of the Z-axis and observing the change the FoM.Here we adopted the mean of Gaussian gradient of the captured FoV image as the FoM due to its unimodal nature when imaging the membrane filter.The curve has its peak when the Z-axis position is at the optimal focal plane.Figure 1 shows an example FoM curve of a filter membrane FoV when the Z-axis moved for the start to end position.
In our technique, incrementing the Z-axis position cause the FoM value to increase if the operation is on the left side of the FoM curve, and decreases the FoM value when the Z-axis position is on the right side of the FoM curve.We established an upper and lower boundary values for the Z-axis position which ensures a search space that encompasses the likely optimal Z-axis position based on the optical configuration of the Schistoscope.The autofocusing routine can be initiated either automatically within the membrane filter scanning procedure or manually by the Schistoscope operator from the device user interface.The perturb and observe autofocusing algorithm starts at the midpoint of the search space in the case of the former and at the current Z-axis position in the latter thus improving convergence speed.
First, we record the initial position () of the Z-axis and acquire the FoV image with dimension  × .Next, the recorded image is converted to greyscale and a figure of merit () is estimated as the mean of gradient magnitude of the convolution of a greyscale image () and a Gaussian derivatives filter () with standard deviation , as shown in Equation (1).
Subsequently, the Z-axis is incrementally adjusted to a new position, denoted as (), and the figure of merit (FoM), (()), is calculated using Equation (1).We then employ Equation (2) to determine the change in FoM (Δ) for the captured image, representing an approximation of the gradient of .A positive Δ indicates that () is on the left side of the peak, leading to an increase in the Z-axis position by a step size.Conversely, a negative Δ indicates that () is on the right side of the peak, resulting in a decrease in the Z-axis position by a step size.Δ = (max{(), ( − 1)}) − (min{(), ( − 1)}). ( F I G U R E 1 Plot of mean Gaussian gradient of captured FoV image of the membrane filter against Schistoscope's Z-axis position. The above procedure is repeated until the stopping criteria shown in Equation ( 3) is achieved.

𝑠𝑖𝑔𝑛(Δ𝐹(𝑧(𝑛))) ≠ 𝑠𝑖𝑔𝑛(Δ𝐹(𝑧(𝑛 − 1))).
( The stopping criteria indicates there is a change in the sign of Δ between the current and previous Z-axis position.This translates to reaching the peak of the FoM curve where the recorded image of the FoV is at the best focus.

OPTIMAL CIRCULAR MEMBRANE FILTER IMAGING
In traditional automated slide scanning systems, grids of FoV images are captured by moving the optical axis or sample stage sequentially along the width and length of the glass slide.This procedure consumes a high amount of time and some of the FoV images may just be images of the glass slide without sample specimen present especially when the specimen is not rectangular in shape.This is, more evident in automated diagnosis of urogenital schistosomiasis in which a circular membrane filter is scanned in a rectangular grid resulting in a large number of the FoV images captured in which the membrane filter is not present.Eliminating these images by adopting an optimal membrane filter scanning procedure would lead to a significant savings in the total sample processing time of an automated slide scanning system.We propose a membrane filter scanning procedure, which optimises the scanning time by intelligently skipping FoVs which do not overlap the circular membrane filter.To further explain our approach, we make use of the illustration shown in Figure 2.Where the shaded circle represents a membrane filter and the rectangular grid cells represents FoVs.Our algorithm utilises the principle of circle geometry to estimate the positions of the grid cells that overlap with the filter membrane in each grid row.
From the illustration in Figure 2, let ℎ  and   be the height and width of the FoV obtained by optical system of the digital microscope which is represented by the grid cell.Therefore, the minimum number of grid rows   and grid columns   for a square grid required to capture circular membrane filter of diameter   , with the membrane centred in the grid, can be obtained using Equations ( 4) and ( 5): Each grid row contains a grid slice with minimum number grid cells such that there is a complete overlap with the membrane filter.To obtain the slice we assume a circle inscribed in the square grid as illustrated in Figure 2.
The length of chord  spans the grid cells in a grid slice can thus be estimated as follows: where  is the radius of the inscribed circle defined as: And  is the distance between the chord and centre of the inscribed circle defined as: F I G U R E 2 An example 10 x 5 grid illustration of a circular membrane filter.
We then estimate the number of grid cells   overlapping the membrane filter in a grid row using Equation ( 7): It is observed that an odd number of grid cells is required for a grid with odd number of grid columns and vice versa.Also, the grid slice is always centred in the grid row.Therefore, the start column index and end column index of the grid slice is obtained using Equations ( 10) and (11), respectively.
The optimal membrane filter scanning is performed by sequentially the sample stage along a path defined by the optimal grid slices in each grid row beginning from the topmost row in the grid.The scan is performed from left to right in grid slices belonging to odd rows and in the reverse direction in grid slices of even rows.Autofocusing is performed at each grid cell position and the FoV image with the best focus is recorded before moving to the next grid cell.The algorithm is terminated after the FoV image of the last grid cell of the grid slice from the last grid row has been recorded.

THE SCHISTOSCOPE IMPLEMENTATION
The standard sample preparation procedure in diagnosing urogenital schistosomiasis involves filtering 10 mL of the patient's urine through a circular membrane filter with a mesh size small enough to retain the parasite eggs.The membrane is then placed on a glass slide and processed by the Schistoscope to for automated detection of Schistosoma haematobium eggs. 44The Schistoscope is equipped with a graphical user interface through which the operator selects from two common sizes of membrane filters that are used in urogenetal schistosmiasis diagnosis, measuring 13 and 25 mm in diameter.The Schistocope captures FoV images of the membrane filter using the developed automated scanning procedure with perturb and observe autofocusing algorithm, implemented on the device using Python programming language.The size of the image captured for estimating the FoM in the autofocusing algorithm is 320 × 240 pixels and this covers a FoV of size 1.47 mm × 1.08 mm.The Z-axis step size was set to 0.25 μm.

RESULTS AND DISCUSSION
We performed experiments to assess the impact of the presence of dirt, S. haematobium eggs, or the glass slide in the FoV, on the shape of the FoM curve and performance of the perturb and observe autofocusing algorithm.We examined four representative in-focus FoV images of a filter membrane captured using the perturb and observe autofocusing algorithm: two FoVs with a filter membrane containing dirt and S. haematobium eggs (Figure 3A and B), a FoV with a portion of the glass slide and a portion of the filter membrane (Figure 3C) and a FoV with a filter membrane without dirt and S. haematobium eggs (Figure 3D).The corresponding normalised figure of merit (FoM) curve obtained by analysing the mean Gaussian gradient of the captured stack of images along the Z-axis for the respective FoVs are displayed in Figure 3E.We obtained a unimodal FoM curve for all four cases.Notably, the optimal focus plane identified by the perturb and observe autofocusing algorithm (circle markers in Figure 3E) aligns with the peak in the FoM curves of images a, c and d.However, in the FoM curve of FoV image b, a Z-axis position error of 0.02 μ m is observed in the perturb and observe autofocusing algorithm.This position error primarily stems from mechanical backlash in the positioning system and can be mitigated by reducing the step size of the Zaxis motor.Nevertheless, decreasing the step size would prolong the convergence time of the autofocusing algorithm without yielding significant improvements to the best focus image, as the device's microscope objective has a depth of view of 55.5 μ m.Furthermore, the observed shifts in the FoM curves, despite the representative FoV images being from the same slide, arise from variations in tissue composition and slide depth variation.The slide depth variation is attributed to the imperfectly flat sample bed, especially in a low-cost device like the Schistoscope, which involves manual assembly and utilises 3D-printed parts.
To demonstrate the practical feasibility of the optimal automated slide scanning procedure with the perturb and observe autofocusing algorithm, we implemented the algorithms on the Schistoscope and performed 10 experimental trials of scanning both the 13 and 25 mm membrane filters.
In Table 1, we present the mean and standard deviation of the time taken to scan both membrane filters using the proposed procedures.
We achieved a 57.60% and 66.70% improvement in scanning time for the 13 and 25 mm filter membranes, respectively, when employing the perturb and observe autofocusing with the traditional grid scanning procedure, compared to the base case of traditional grid scanning with focal mapping autofocusing approach.This improvement can be attributed to requiring a lesser number of steps for Z-axis movement (maximum of 4 steps) compared to the focal mapping autofocusing, which necessitates a minimum of 10 steps to acquire an in-focus image for every grid cell.The traditional grid scanning approach requires a 9 13 grid (117 images) and 18 24 grid (432 images) to capture the entire 13 and 25 mm membrane filters, respectively.By applying the developed optimal membrane scanning procedure in combination with the perturb and observe auto focusing algorithm, we achieved an additional improvement in scanning times of 13.15% and 14.43% for the 13 mm and 25 mm membrane filters respectively, compared to traditional grid scanning approach with perturb and observe autofocusing algorithm.Thus, we obtained an overall improvement in scanning time of 63.18% and 71.52% for the 13 and 25 mm membrane filters, respectively, compared to the base case of traditional grid scanning with focus map surveying autofocusing approach.This improvement was achieved by the optimal scanning procedure consequently skipping 12 grid cells without membrane filter while scanning the 13 mm membrane and 76 grid cells when scanning the 25 mm membrane.Hence, only 105 and 356 images are to capture the 13 and 25 mm membrane filters, respectively, as illustrated in Figure 4.
The efficiency gains become particularly crucial in resource-constrained settings with a significant disease burden, where microscopic examination of urine samples is recommended by the WHO for the diagnosis of urogenital schistosomiasis.Considering that conventional microscopy typically takes around 5 min per sample, the further reduction in scanning time for the 25 mm membrane filter from 30 to 25 min per sample, achieved through our optimised membrane scanning procedure, significantly enhances the practicality of deploying the Schistoscope for large-scale schistosomiasis monitoring and evaluation programs, especially in regions with a high disease burden.To further enhance the computational efficiency of the Schistoscope, we acknowledge the potential benefits of implementing the algorithm in a more efficient language like C++.Additionally, exploring low-cost options for hardware acceleration, such as GPUs and TPUs, could provide further improvements.F I G U R E 4 Capture of the (A) 13 mm and (B) 25 mm membrane filters using the optimal automated slide scanning procedure with skipped grid cells highlighted in black.

CONCLUSION
This paper introduces a novel procedure for automated slide scanning of membrane filters in the diagnosis of urogenital schistosomiasis.The procedure focuses on estimating and capturing field-of-view (FoV) images only in grid cells where the membrane filter is present, optimising efficiency.Additionally, we have developed a perturb and observe autofocusing algorithm that employs a hillclimbing approach, utilising the mean of the Gaussian gradient of the FoV image as a figure of merit to determine the optimal focus plane.To evaluate the performance of our developed procedure, we implemented it on the Schistoscope and experimentally assessed of its scanning capabilities using the commonly used 13 and 25 mm membrane filters for diagnosing urogenital schistosomiasis.Our results obtained 63% and 72% s improvements in scanning times for the 13 and 25 mm membrane filters respectively compared to the traditional grid scanning procedure with the focus map surveying autofocusing algorithm.The significant reduction in scanning time greatly enhances the applicability of the Schistoscope for largescale schistosomiasis monitoring and evaluation programs in regions where the disease is prevalent.Moreover, the optimised scanning procedure can be adapted to minimise scanning time in whole slide imaging of other biological tissue smears with shapes closely resembling that of a circle (e.g., stool and thick blood smears in the diagnosis of soil transmitted helminth and malaria parasite infections respectively).Moving forward, our future work, we plan to conduct a large-scale validation study to evaluate the performance of the Schistoscope with artificial intelligence for diagnosis of urinogenital schistosomiasis in field settings.

C O N F L I C T O F I N T E R E S T S TAT E M E N T
The authors declare no potential conflict of interests.

F I G U R E 3
Representative in-focus FoV images from the same sample slide obtained using the perturb and observe autofocusing algorithm.(A, B) The FoV with a filter membrane containing dirt and S. haematobium eggs.(C) A FoV with a portion of the glass slide and a portion of the filter membrane.(D) A FoV with a filter membrane without dirt and S. haematobium eggs.(E) The normalised FoM curve corresponding to the respective images, with the detected peak indicated by the perturb and observe autofocusing algorithm.TA B L E 1 Performance in automated slide scanning of 13 and 25 mm membrane filter.
We acknowledge the Neglected Tropical Disease team from the Federal Ministry of Health Abuja and Federal Capital Territory Authority Public Health Laboratory Abuja, Nigeria and Delft University of Technology Global Initiative for their support towards this study.This work was funded by the Nederlandse Organisatie voor Wetenschappelijk Onderzoek (NWO), WOTRO Science for Global Development program, Grant Number W 07.30318.009(INSPiRED -INclusive diagnoStics for Poverty RELated parasitic Diseases in Nigeria and Gabon).