Automated malaria diagnosis and parasitemia estimation using a customized OpenFlexure microscope | Research Square window.SnipcartSettings = { analytics: { enabled: false } }; (function() { var accessVector = localStorage.getItem('access_vector') || ''; window.dataLayer = window.dataLayer || []; if (accessVector) { window.dataLayer.push({ user: { profile: { profileInfo: { snid: accessVector } } } }); } })(); (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-K279D39R'); Browse Preprints In Review Journals COVID-19 Preprints AJE Video Bytes Research Tools Research Promotion AJE Professional Editing AJE Rubriq About Preprint Platform In Review Editorial Policies Our Team Advisory Board Help Center Sign In Submit a Preprint Cite Share Download PDF Research Article Automated malaria diagnosis and parasitemia estimation using a customized OpenFlexure microscope Daniel Maitethia Memeu This is a preprint; it has not been peer reviewed by a journal. https://doi.org/ 10.21203/rs.3.rs-6809543/v1 This work is licensed under a CC BY 4.0 License Status: Posted Version 1 posted You are reading this latest preprint version Abstract We present a customized OpenFlexure Microscope (OFM) platform for automated malaria diagnosis and parasitemia estimation. The system integrates a Laplacian-based autofocusing algorithm optimized for 100× oil immersion imaging and a YOLO-based deep learning model to detect Plasmodium-infected and non-infected red blood cells and white blood cells. A Python control script performs automated slide scanning and real-time analysis across 100 fields of view. The OFM achieved 80% accuracy in parasitemia estimation, compared to 38% for human microscopists, and reduced diagnostic time from over 100 minutes to under 40 minutes, demonstrating its potential for use in point-of-care settings. Laboratory Diagnostics Parasitemia Plasmodium Edge devices Point of Care YOLO autofocusing slide scanning Figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Figure 8 Figure 9 1. Introduction Malaria remains a major public health challenge, particularly in sub-Saharan Africa, where it accounts for a significant proportion of morbidity and mortality. Accurate and timely diagnosis is essential for effective treatment and malaria control. Microscopy of Giemsa-stained blood smears remains the gold standard for malaria diagnosis due to its ability to quantify parasitemia and distinguish between Plasmodium species. However, conventional optical microscopy is time-consuming, requires well-trained personnel, and suffers from limited reproducibility, especially in resource-constrained settings. Recent advances in digital microscopy and artificial intelligence (AI) offer opportunities to overcome these limitations by automating the diagnostic process. Early efforts utilized conventional machine learning algorithms such as Support Vector Machines (SVMs), k-Nearest Neighbors (k-NN), Decision Trees and shallow Artificial Neural Network (ANN) [1]. These methods required manual feature extraction from blood smear images, relying on handcrafted features like color, texture, and shape to differentiate between infected and uninfected cells. While these approaches provided initial automation, their performance was limited by the quality of feature extraction and lacked robustness across diverse datasets. The advent of deep learning, particularly Convolutional Neural Networks (CNNs), revolutionized image-based malaria diagnosis. CNNs automatically learn hierarchical feature representations from raw pixel data, eliminating the need for manual feature engineering. Architectures like ResNet50 and EfficientNet have demonstrated high accuracy in classifying parasitized and uninfected red blood cells [2 - 8]. A recent study has reported an accuracy of 99.51% in classifying Plasmodium species using a CNN-based model [8]. More recently, transformer-based models, originally developed for natural language processing tasks, have been adapted for image analysis. Vision Transformers (ViTs) and their variants employ self-attention mechanisms to capture global contextual information in images [9-10]. A notable study proposed a multiheaded attention-based transformer model for malaria parasite detection, achieving high accuracy and offering interpretability through techniques like Grad-CAM [11]. These models have shown promise in capturing complex patterns in blood smear images, potentially outperforming traditional CNNs in certain scenarios. Despite these advancements, many AI-enabled diagnostic systems are designed for deployment on conventional PCs interfaced with high-end digital microscopes. Such setups are often impractical in rural or low-income settings due to their cost, size, and power requirements. The reliance on powerful computing resources and stable internet connectivity further limits their applicability in resource-constrained environments. To address these challenges, there is a growing interest in deploying AI models on edge devices—compact, low-power hardware capable of performing computations locally. Edge deployment reduces latency, enhances data privacy, and enables real-time diagnostics without the need for continuous internet access. A few pioneering studies have demonstrated the integration of artificial intelligence (AI) models into edge devices for real-time malaria diagnosis. These efforts represent critical milestones toward the democratization of diagnostic technologies, especially in low-resource settings. One notable example is miLab™, a portable, automated diagnostic platform that integrates a deep learning model on embedded hardware for malaria screening. miLab™ automates slide staining, autofocusing, imaging, and parasite detection. Deployed in field settings in Malawi and Sudan, it achieved a high detection accuracy of 98.86% [12-13]. While miLab™ is a fully integrated system, it still relies on relatively complex mechanics for slide handling and may not be easily locally fabricated or maintained without specialized components. Another key contribution is MAIScope—a low-cost, portable microscope enhanced with vision AI, designed to automate malaria diagnostics in rural areas. MAIScope uses a custom CNN model for RBC segmentation and parasite detection, and is operable without internet access. It achieved an average classification accuracy of 89.9%, and was evaluated using a smartphone-attached microscope [14]. However, the system was limited by low image resolution and lacked support for high-magnification imaging (e.g., 100× oil immersion), which is crucial for detecting early-stage (ring form) parasites. The Mobile Malaria Attention Network (M2ANET) is another lightweight model designed specifically for mobile device deployment. M2ANET combines MobileNetV3 blocks with multi-head self-attention for real-time inference on mobile phones. It outperformed other mobile-compatible networks in accuracy and inference speed [15]. Despite its efficient architecture, M2ANET’s validation was primarily done on cropped and preprocessed image patches, without demonstrating full-slide scanning or field-deployable hardware integration. A different study introduced a real-time edge AI system deployed on smartphones to assist in the screening and species differentiation of filarial samples using mobile microscopy [16]. Collectively, these studies mark significant progress in the shift from laboratory-based AI applications to on-device, real-time malaria diagnostics. However, they typically fall short in one or more of the following areas: Limited integration with physical microscopy hardware, especially affordable, opensource, high-magnification systems like the OpenFlexure Microscope (OFM); Lack of support for full slide scanning workflows; Dependence on preprocessed or cropped image datasets, which may not reflect the variability in real-world blood smear slides; Insufficient field validation across large sample sizes and varied environmental conditions. The OpenFlexure Microscope (OFM) is an open-source, 3D-printed digital microscope that has gained attention as a low-cost and customizable imaging platform [17]. Its modular design and local manufacturability make it a promising tool for point-of-care (PoC) applications. While the OFM has previously been used for basic imaging tasks [18], its potential for automated diagnostic workflows remains underexplored. In this study, we present a fully integrated and automated malaria diagnostic system based on the OpenFlexure Microscope (OFM) platform. Our contributions include: (i) the development of a custom autofocusing algorithm optimized for 100× oil immersion imaging of blood smear samples; (ii) the integration of a YOLO-based object detection model to identify and quantify Plasmodium -infected red blood cells (iRBCs), non-infected RBCs, and white blood cells (WBCs); and (iii) the implementation of a complete slide scanning routine covering 100 fields of view. We evaluated the system’s performance in terms of parasitemia estimation accuracy, result reproducibility, and time efficiency, benchmarking it against expert human microscopists. Our findings demonstrate the feasibility of deploying AI-powered, low-cost diagnostic solutions in low-resource settings, supporting global efforts toward malaria control and elimination. The image dataset and Python code used in this work are available in the GitHub repository referenced in [19]. A link to a short youtube video demo illustrating the operation of the prototype can be accessed through reference [20] . 2. Materials and Methods 2.1 Ethical approval Ethical approval to conduct the study was sought from Meru University Institutional Research Ethics Review Committee (MIRERC) which is a local ethics review board licensed by the national research regulatory body of Kenya referred to as National Council of Science Technology and Innovation (NACOSTI). Participants in the study were required to give informed consent indicating they have been adequately informed about the goal, methodology and potential benefits and risks of the study and they willfully and voluntarily decided to participate in the study. The consent agreement also provided for withdrawal from participation at any point of the study. Informed consent by minors participating in the study was made by their guardians. 2.2 Sample collection and bood smear preparation Peripheral blood samples were obtained from participants with confirmed malaria infection. Each participant donated 2 ml of venous blood, which was collected into EDTA-treated tubes and securely sealed to prevent coagulation. A total of 20 participants contributed blood samples for the study. From each blood sample, multiple aliquots were used to prepare thin blood smears. In total, approximately 400 blood smear slides were prepared. The smears were air-dried, fixed with methanol, and stained using Giemsa stain. The stained slides were then imaged using the OpenFlexure Microscope (OFM) for further analysis. 2.3 Image Acquisition Image acquisition was carried out using the OpenFlexure Microscope (OFM), an open-source, low-cost, motorized microscope. Prepared Giemsa-stained thin blood smear slides were loaded individually onto the microscope’s sample stage and secured using the built-in slide clips. The OFM was connected to an external monitor via HDMI to enable real-time visualization. A keyboard and mouse were also connected to the system to facilitate user interaction. Once the microscope was powered on, the OFM-Connect application was launched to initiate image acquisition. Figure 1 shows the setup. A camera calibration routine, including white balance adjustment, was performed before imaging to ensure color fidelity and accurate representation of stained cellular structures. Initial focusing of the first image was achieved either manually by adjusting up or down the z-position of the objective lens through the OFM software interface or by using the built-in autofocus function. Once the image was brought into coarse focus, an automatic image acquisition script was launch to grab and save the blood smear images at different microscope Field of Views (FoVs). A 100X oil immersion objective lens was used throughout the imaging process to ensure sufficient magnification and resolution for identifying Plasmodium-infected red blood cells. The steps followed to implement the automated image acquisition routine were; (i) Sample autofocusing (ii) Image capture and saving, (iii) Stage translation to a new FoV, (iv) Repetition of the above steps across the entire scan area i.e., 100 FoVs. Slides were scanned using a raster scanning pattern with a lateral step size of 400 motor steps (~400 between successive fields. This allowed systematic coverage of the smear area while minimizing image overlap and redundancy. During a preliminary evaluation of the application the OFM to image malaria blood smear using 100X 1.25NA oil immersion objective, we found that the default microscope autofocus function produced increasingly defocused images after a few iterations of the scan cycle. This is due to the shallow Depth of Field (DoF) of the objective lens which implies a slight lateral displacement result in the image getting out of focus due to both the sample nonuniform thickness and the motor gear backrush during microscope stage translation. Therefore, one of the objectives of this work was to develop a custom autofocus algorithm optimized for blood smear auto scanning using 100X 1.25 NA objective. The autofocusing algorithm was integrated with the raster scanning routine described above. The algorithmic steps for the improved autofocus method are detailed below. 2.3.1 Custom Autofocus Algorithm The algorithm involves two stages: first, determination of the rough focus direction and position, and second refinement through fine focus scanning. Figure 2 presents the algorithmic steps and the description of the steps is provided below. Rough Focus Determination When the microscope is translated to a new field of view, the system begins by identifying the approximate focus region through a z-stack acquisition process. The objective lens is first moved downwards, acquiring 10 images at equal intervals with a coarse step size of 200 motor steps (with each step being ). The lens is then returned to the initial z-position, after which 10 additional images are acquired in the upward direction using the same step size. This results in a total of 20 z-stack images. For each image in the z-stack, a Laplacian transform is computed, and the v ariance of the resulting Laplacian image is calculated. The variance of the Laplacian is evaluated and used as image sharpness metric. Higher variance values indicate sharper images and better focus. The direction of the sharpness gradient is then analysed as follows: If the variance values have a clear peak between the start and end of the z-stack (i.e., a maximum exists within the 20 images), the corresponding z-position of this peak is identified as the rough focus position. The microscope is moved to this z-position. Else if the variance values show a monotonic increase or decrease across the 20 points (i.e., no peak is detected), the objective is moved one additional step (200 steps) beyond the current endpoint in the direction of increasing variance and additional images are acquired in that direction. At each new z-position: A new image is captured, the Laplacian and its variance are calculated, the variance of the current image is compared to that of the previous position. If the current variance is greater, the objective continues moving in the same direction. Else if the variance decreases, the previous z-position (with the highest variance) is set as the rough focus position. Fine Focus Determination To refine the focus, a second z-stack is acquired around the rough focus position: the objective is first moved 200 steps below the rough focus position, a fine z-stack is then acquired this time using a smaller step size of 50 steps. The scan continues until the objective is 200 steps above the rough focus position, covering a total of 400 steps. As before, the Laplacian of each image is computed and the variance calculated. The z-position corresponding to the maximum variance within this finer stack is identified as the fine focus position. The microscope is then moved to this position, and the focused image is captured and saved for further processing. 2.4 Image Annotation Following the acquisition of blood smear images using the previously described method, image annotation was carried out to generate labelled datasets for machine learning model training. The annotation process was performed using the Sreeni Image Annotator software [21]. The objective was to classify and label individual cells within each image based on their infection status and cell type. The following procedure was followed: 2.4.1 Class Definition Three annotation classes were created within the software to guide the labelling process. The classes were; Infected RBC – Red blood cells containing visible Plasmodium parasites, Non-Infected RBC – Red blood cells without any observable signs of infection and WBC – White blood cells present in the blood smear. To facilitate efficient annotation, the acquired images were imported into the annotation software batches and each image was manually reviewed and annotated by marking individual cells with bounding boxes and assigning them to one of the three predefined classes. Upon completion of the labelling process for each image, annotations were saved in YOLO (You Only Look Once) format, which is suitable for training object detection models. This process was repeated across all batches, resulting in a total of approximately 4000 annotated images. The annotated dataset was periodically reviewed to ensure consistency and accuracy in labelling across images. Any discrepancies identified during the quality checks were corrected to maintain high-quality annotation standards. 2.5 Dataset Preparation A total of 4,000 annotated images were used for training a machine learning model to detect malaria-infected red blood cells. The dataset was split as follows: 70% for training (2,800 images), 20% for validation (800 images) and10% for testing (400 images). The dataset was organized using a data.yaml configuration file, which is essential for training YOLO-based models. This file specifies; File paths to images and labels, Class names (e.g., infected RBC, uninfected RBC, WBC) and Dataset splits (train, validation, test) 2.6 Model Training The YOLOv11n model was selected due to its high speed and efficient performance, making it suitable for real-time object detection on edge devices. Despite its lightweight nature, YOLOv11n achieves a good balance between speed and accuracy. 2.6.1 Model Architecture YOLOv11n follows the typical YOLO architecture, which consists of three main components: Backbone Responsible for extracting features from the input image using convolutional layers. YOLOv11n uses the C3K2 block - an optimized version of Cross Stage Partial (CSP) for faster processing. It also introduces the C2PSA block - which adds spatial attention to focus on the most relevant regions of an image, enhancing detection accuracy. Neck Combines and processes multi-scale features extracted by the backbone. Enhances the model's ability to detect objects of varying sizes. YOLOv11n incorporates improved C3K2 blocks at this stage for better speed and performance. Head Generates final predictions, including bounding boxes and class labels for objects (e.g., infected or uninfected RBCs, WBCs). 2.6.2 Training Process The training process was conducted in a JupyterLab environment on a GPU-enabled workstation equipped with an NVIDIA GPU (driver version 522.06) and 8 GB of memory. The training was executed over 100 epochs, with each epoch taking an average of approximately 247 seconds, resulting in a total training time of around 6.7 hours. The learning process utilized the default YOLO optimizer and learning rate, which is based on the Adam optimizer with an initial learning rate of 0.001. During training, no data augmentation techniques were applied, as the training framework in use did not support inline augmentation via the command-line interface. The model relied solely on the original distribution of the dataset, which was inherently imbalanced in terms of class frequency. No techniques such as class weighting or oversampling were applied. The model was therefore trained to learn directly from the naturally occurring distribution of infected and uninfected cells. YOLOv11n optimizes a combination of three loss components during training: classification loss for accurate label prediction, localization loss based on Intersection over Union (IoU) for precise bounding box regression, and objectness loss to evaluate the presence of target objects within bounding boxes. These loss components are built into the YOLO architecture and work together to improve the model’s overall detection performance. Throughout training, the model's performance on the validation set was monitored to avoid overfitting. While no early stopping strategy was explicitly used, the model was capped at 100 epochs, and the best-performing version—based on validation accuracy—was automatically saved in PyTorch format (best.pt). No conversion to other deployment formats (e.g., ONNX or TensorRT) was performed at this stage, as the model was to be deployed within the same PyTorch-compatible environment. 2.7 Model Evaluation Procedure After training the YOLOv11n model on the annotated blood smear image dataset, the model's performance was evaluated using a systematic validation process. The goal of this evaluation was to assess the model’s ability to accurately detect and classify three target cell types: infected red blood cells (RBCs), non-infected RBCs, and white blood cells (WBCs). A test dataset comprising 20% of the total annotated images was used for performance assessment. This dataset was not exposed to the model during training, ensuring an unbiased evaluation of generalization capability. The evaluation process employed several standard metrics widely used in object detection and classification tasks: Precision was used to quantify the proportion of true positive predictions out of all positive predictions made by the model. This metric is important for evaluating the model's ability to avoid false positives. Recall was used to measure the proportion of true positive detections out of all actual positive instances in the dataset. It assesses the model's capacity to detect relevant objects comprehensively. Mean Average Precision (mAP) was used to evaluate the model’s overall detection accuracy. The mAP score was calculated at different Intersection over Union (IoU) thresholds. [email protected] measures average precision at a fixed IoU threshold of 0.5, while [email protected] :0.95 provides a more stringent assessment by averaging precision over multiple IoU thresholds from 0.5 to 0.95 in increments of 0.05. Loss Metrics were monitored during validation and included bounding box loss (for object localization), segmentation loss (where applicable), and classification loss (for label prediction). These losses provided insights into the model’s learning efficiency and convergence behavior. Precision-Confidence and Recall-Confidence Curves were plotted to analyze how model confidence levels affected its performance. These curves helped identify optimal confidence thresholds for reliable predictions. Confusion Matrix analysis was also performed to examine the distribution of true positives, false positives, and false negatives across all three classes. This provided a visual overview of how well the model distinguished between different cell types. Throughout the evaluation process, model checkpoints and predictions were compared against ground truth annotations prepared during the image annotation phase. The evaluation procedure was conducted using the same YOLO training and inference environment, ensuring consistency in preprocessing and metric computation. This evaluation methodology provided a comprehensive understanding of the model’s strengths and limitations and guided further fine-tuning and deployment decisions. 2.8 Model Deployment in the OpenFlexure Microscope (OFM) After training, the malaria detection model was saved in PyTorch format (best.pt) on the GPU workstation. For deployment, the model was compressed and transferred to a laptop connected to the OpenFlexure Microscope (OFM) system over a local network. The model was then integrated into a custom Python script responsible for controlling the OFM’s slide scanning, image acquisition, and analysis. Upon initiation, the system brings the blood smear slide into focus using an autofocusing algorithm that evaluates image sharpness based on the variance of the Laplacian. Once the optimal focus is achieved, an image is captured and immediately passed to the malaria detection model for analysis. The model detects and classifies individual cells as Plasmodium -infected red blood cells (iRBCs), non-infected RBCs, or white blood cells (WBCs). It also generates bounding boxes around each detected object, using distinct border colors for different cell classes to facilitate easy verification by a trained microscopist. The system systematically scans 100 fields of view (FoVs) across the sample, performing autofocusing, image capture, analysis, and result compilation at each location. For each scanned FoV, the number of infected RBCs, non-infected RBCs, and WBCs is recorded, along with the time taken for processing. At the end of the scanning session, the system collates and outputs a diagnostic report summarizing the total and average counts of each cell type across the scanned area. This deployment enables the OFM to operate as a fully automated malaria diagnostic platform, capable of real-time detection, parasitemia estimation, and generation of verifiable diagnostic outputs from stained blood smear samples. 2.9 Performance Evaluation of the OFM-Based Automated Malaria Diagnostic Platform To evaluate the performance of the OpenFlexure Microscope (OFM)-based automated malaria diagnostic platform, a comparative study was conducted against the conventional manual optical microscopy method. The evaluation focused on three key metrics: parasitemia estimation accuracy, diagnostic time, and result reproducibility. Three Giemsa-stained thin blood smear slides—distinct from those used during the model training phase—were selected for testing. To ensure consistency, the same diagnostic protocol was applied to both the OFM system and human operators. For the manual microscopy evaluation, three experienced human microscopists were enlisted. Each microscopist examined the three slides using a standard optical microscope equipped with a 100×, 1.25 NA oil immersion objective and a 10× eyepiece. They systematically reviewed 100 fields of view (FoVs) per slide, recording the number of Plasmodium -infected red blood cells (iRBCs), the total number of RBCs, and the number of white blood cells (WBCs) for each FoV. In parallel, the OFM platform performed automated analysis on the same three slides, scanning and analyzing 100 FoVs per slide using its integrated autofocusing and cell detection pipeline. To assess reproducibility, each slide was scanned and analyzed three times under identical conditions using the OFM system, allowing for evaluation of result consistency across repeated runs. To establish the ground truth for parasitemia estimation, three sets of images—each comprising 300 distinct FoVs per slide—were acquired independently using the OFM. These images were annotated by an experienced microscopist not involved in the model training or initial evaluation. The independently annotated results were used to calculate the ground truth parasitemia, against which the parasitemia estimation accuracies of both the OFM platform and the human microscopists were assessed. 3. RESULTS AND DISCUSSION In this section, we present a comparative analysis of image sharpness and acquisition time for 100 images obtained using the custom-developed autofocusing algorithm versus the built-in autofocus function provided by the OFM client library. We also report the evaluation results of the YOLO-based object detection model used for detecting the specified cellular components in blood smear images. Finally, we compare the diagnostic performance of the customized OFM system against that of expert human-operated microscopy. 3.1 Evaluation of the Custom-Developed Autofocusing Algorithm The performance of the custom-developed slide scanning and autofocusing algorithm was first evaluated to determine its efficiency and reliability in capturing high-quality, in-focus images across multiple fields of view (FoVs). Autofocusing was a critical component of the system, ensuring sharp imaging necessary for accurate detection of cellular components. Figure 3 presents sample plots of the variance of the Laplacian computed from z-stack images acquired during the course and fine focusing procedures. Figure 4 compares representative images obtained using the custom autofocus method and the built-in OFM client library autofocus function. Figure 5 provides a comparison of the variance of the Laplacian—used as a sharpness metric—at various FoVs, along with the total time taken to scan 100 fields using each autofocus strategy. Automatic slide scanning using the OFM’s built-in autofocus function often produced out-of-focus images, particularly after small stage translations. As shown in Figure 3 panels f to I, less than 75% of the 100 acquired images were of insufficient quality for assessing RBC infection status. In contrast, our custom-developed autofocus algorithm consistently produced sharper images across all 100 fields of view. Figure 3 panels a to e, shows that all the 100 images acquired from varying microscope FoVs were of sufficient quality to be used to access infection status of the cells. Table 2 indicates that the sharpness metric declined more rapidly with the built-in function compared to the custom algorithm for images captured within 100 FoVs. Image acquisition time was comparable for both methods—approximately 19 minutes for 100 FOVs. However, while most images from the built-in function were unusable, all the images acquired using the custom algorithm found to be usable. 3.2 Evaluation of the deep learning object detection model The YOLOv11n model trained on annotated blood smear images was evaluated using standard performance metrics to assess its detection accuracy, learning convergence, and training stability. A total of 4,000 annotated images were used in the training and evaluation process, with the dataset split into 70% for training, 20% for validation, and 10% for testing. The annotations captured three distinct classes: infected red blood cells (RBCs), non-infected RBCs, and white blood cells (WBCs). Figure 6 shows the training and validation metrics for your YOLOv11n model across 100 epochs. It's organized into two rows: the top row represents training metrics, and the bottom row represents validation metrics. Each column represents a different metric, giving a comprehensive view of the model's performance. The following are some general observations regarding the generated training and validation losses. (i) Decreasing Loss: All loss plots (box, seg, cls, dfl) show a decreasing trend, indicating that the model was learning effectively. (ii) Increasing Precision and Recall: Precision and recall for bounding boxes are generally increasing, suggesting the model was improving its detection performance. (iii) Increasing mAP50: The mAP50 is also increasing, reinforcing the positive trends in precision and recall. (iv) Potential for Further Improvement: While the model is performing well, one could consider further optimization techniques (e.g., data augmentation, hyperparameter tuning) to see if you can squeeze out even better performance. Figure 7 presents the precision-confidence and recall-confidence curves for the three target classes. The model achieved high precision values, particularly at higher confidence thresholds, indicating its ability to make reliable predictions for infected and non-infected RBCs and WBCs. Table 1 displays the confusion matrix derived from the validation data, highlighting the model’s ability to accurately differentiate among the three classes. The highest detection counts lie along the diagonal of the matrix, suggesting correct classification, although a small number of background pixels were occasionally misclassified as non-infected RBCs. Table 1 : Confusion matrix showing the classification performance of the YOLO-based object detection model for detecting Plasmodium-infected red blood cells (RBCs), non-infected RBCs, white blood cells (WBCs), and background. The diagonal elements represent correctly classified instances for each class, while off-diagonal values indicate misclassifications. True: Infected RBC Non-infected RBC WBC Background Pred: Infected RBC 65,868 10,504 0 16,673 Pred: Non-infected RBC 6,014 199,892 1 28,313 Pred: WBC 1 2 239 60 Using values presented in Table 1, the class specific precision, recall, F1 score and overall accuracy was computed and presented in Table 2. Table 2 : Class-wise precision, recall, and F1 score for the YOLO-based object detection model in identifying Plasmodium-infected red blood cells (RBCs), non-infected RBCs, and white blood cells (WBCs). The model achieved the highest recall for WBCs (99.6%) and the highest F1 score for non-infected RBCs (89.9%), indicating robust performance in differentiating cell types. The overall model accuracy across all classes was 81.2%. Class Precision Recall F1 Score Infected RBC 0.707916 0.916322 0.798749 Non-infected RBC 0.853437 0.950066 0.899163 WBC 0.791391 0.995833 0.881919 Overall accuracy 0.812045 The model achieved an overall accuracy of 81.2%, with a precision, recall, and F1 score for infected RBCs being 70.8%, 91.6%, and 79.9%, respectively. The prediction scores for non-infected RBCs were precision: 85.3%, recall 95.0%, and F1 score 88.2% while that for WBCs were precision 79.1%, recall: 99.5% and F1 score 88.2%. These metrics are significant in the context of a disease diagnostic model because: Precision reflects how many of the cells identified as infected were actually infected, which is critical for reducing false positives that may lead to unnecessary treatment. Recall (or sensitivity) indicates how many of the truly infected cells were successfully detected by the model. A recall of 70.8% suggests that while the model is effective, there is still room for improvement in capturing all true cases, which is vital for early and accurate malaria diagnosis. F1 Score, the harmonic mean of precision and recall, provides a balanced measure of the model’s diagnostic performance. Compared to manual microscopy, which has a reported sensitivity of 75–90% when performed by expert microscopists, the model’s sensitivity is within an acceptable range, especially considering its automation potential. In contrast, Rapid Diagnostic Tests (RDTs) typically show lower sensitivity—often between 60–75%—and may fail to detect low parasite densities. Therefore, this automated model demonstrates a promising balance of accuracy and scalability, with the potential to augment or even outperform traditional diagnostic methods in resource-limited settings, especially when deployed on portable systems like the OpenFlexure Microscope. The image in Figure 8 illustrates one of the detection output from the automated malaria diagnostic system, in which a YOLOv11n object detection model has classified individual red blood cells (RBCs) based on infection status. Red bounding boxes highlight RBCs identified as Plasmodium -infected, while yellow bounding boxes indicate non-infected RBCs. Infected cells exhibit characteristic morphological features such as the presence of dark-staining ring forms, cytoplasmic inclusions, or altered cell shape and texture—hallmarks of intraerythrocytic Plasmodium parasites. In contrast, non-infected RBCs typically display a uniform round shape with a central pale zone (biconcave appearance) and lack any internal inclusions or distortions. The detection pattern demonstrates the model’s ability to differentiate subtle visual cues across a densely populated field, thereby enabling accurate parasitemia quantification in a manner consistent with expert microscopy assessment. The different color of bounding boxes aid in counterchecking the correctness of the results provided by automated system. The sytem is programmed to count the total infected RBCs, non-infected RBCs and white blood cells detected in 100 FoV automatically scanned. Parasitemia; which is the ratio of infected to non-infected RBCs is also then computed and displayed on the screen. 3.3 Comparative Diagnostic study The fully integrated OFM-based diagnostic system was evaluated in a comparative study alongside three experienced human microscopists. The evaluation focused on three key aspects: diagnostic accuracy relative to expert-annotated ground truth, average diagnostic time per slide, and the reproducibility of results across repeated OFM runs and among human examiners. The bar chart in Figure 9 compares the parasitemia estimation accuracy of the OFM-based deep learning (DL) diagnostic system to that of experienced human microscopists. The OFM system achieved a markedly higher average accuracy of 80.3%, while human microscopists averaged 38.0%—indicating a significant performance gap in favor of the automated approach. Additionally, the error bars show that the OFM system exhibited lower variability, suggesting greater reproducibility and consistency across repeated evaluations. In contrast, the human microscopists' performance was both less accurate and more inconsistent. These results emphasize the limitations of manual microscopy for quantitative parasitemia assessment, which is inherently subjective and time-consuming, and underscore the potential of the OFM system to deliver rapid, accurate, and reproducible malaria diagnostics suitable for deployment in routine clinical and field settings. The average time taken by the OFM system was 40 minutes while the human microscope operators took an average time of 1 hour 40 minutes. Discussion Our custom-developed autofocusing algorithm, implemented on the OpenFlexure Microscope (OFM), is a software-driven, two-stage routine that combines coarse and fine z-stack scanning with Laplacian variance-based sharpness estimation. In the first stage, the system acquires a bidirectional z-stack (20 images) with coarse steps to approximate the focal region. This is followed by a finer z-stack (8–10 images) around the peak variance to precisely determine the best-focus position. This approach emphasizes focus accuracy, robustness, and adaptability across large scan areas and varying sample topographies. This method extends the foundational autofocus strategy proposed by Knapper et al. (2021), who introduced the smart stack algorithm to address mechanical backlash in OFM hardware. While their approach uses JPEG file size as a proxy for sharpness and fits a Chebyshev polynomial to guide focus correction, it remains limited to generalized imaging tasks and is prone to increased acquisition time due to stack retries. In contrast, our algorithm achieves comparable reliability with minimal overhead by leveraging variance of the Laplacian, a well-established and computationally efficient image sharpness metric. Additionally, our integration with a deep learning diagnostic pipeline demonstrates the algorithm’s suitability for clinical workflows where both image quality and operational speed are critical. Compared to the hardware-centric dual-axis optical autofocus system described by Lightley et al. (2023) in the openFrame microscope, our approach offers a cost-effective and easily deployable solution that does not require additional optics, calibration steps, or lookup tables. While the dual-axis laser system provides high precision (<200 nm) and rapid closed-loop correction using single-shot triangulation, it involves more complex hardware integration that may not be feasible in low-resource or field settings. Our algorithm, in contrast, maintains sub-micron focusing reliability through software-only control and can be implemented entirely using existing OFM components, thus aligning better with the goals of open-access, locally manufacturable diagnostic tools. Together, these comparisons highlight that our autofocus method strikes a practical balance between precision, robustness, and accessibility. It extends previous OFM developments with a malaria-specific application focus, enabling slide scanning with reliable focus over 100 fields of view—a functionality not demonstrated in either of the prior studies. Our study demonstrated that a fully automated diagnostic platform built around the OpenFlexure Microscope (OFM), integrated with a YOLOv11n-based object detection model, can achieve high diagnostic accuracy, rapid image acquisition, and reproducible detection of Plasmodium-infected red blood cells (RBCs). The system addressed multiple limitations in previous work, as outlined below. Many earlier studies, such as Poostchi et al. (2018) [1], Madhu et al. (2023) [2], and Rahman et al. (2021) [5], demonstrated the feasibility of using deep learning for malaria diagnosis, reporting classification accuracies ranging from 90% to 96%. Similarly, Khan et al. (2022) [6] and Kudisthalert et al. (2020) [7] explored CNN architectures and counting algorithms for parasite quantification. However, these studies were often limited to small, curated datasets or lacked field validation. In contrast, our model was trained on a large and diverse set of 4,000 images acquired from real patient samples prepared under local clinical conditions, where variations in smear thickness, cell distribution, and staining quality are common. These conditions reflect the practical challenges encountered in field diagnostics. Despite this variability, the model was validated against expert-annotated ground truth and achieved strong performance metrics (e.g., [email protected] = 0.865, precision = 0.818, recall = 0.840), which fall within or exceed the range reported in most comparative studies—demonstrating the robustness and real-world applicability of our approach. Recent efforts such as those by Islam et al. (2022) [10], Tan & Liang (2023) [9], and Sengar et al. (2022) [11] explored transformer-based and attention-driven models to improve malaria parasite detection. While these models achieved high accuracy, they often require significant computational resources, limiting their deployability in field conditions. Our choice of YOLOv11n offered a balance between detection accuracy and computational efficiency, allowing real-time inference on a Raspberry Pi embedded in the OFM—a critical advantage for point-of-care settings. Many studies (e.g., Ramos-Briceño et al., 2025 [8]; Elayaraja et al., 2024 [4]) have focused solely on the image analysis aspect, often assuming access to pre-focused, high-quality images. Our work advances the field by integrating autofocusing, slide scanning, image capture, detection, and result generation into a single automated workflow. This positions our system closer to the embedded, sample-to-answer devices such as miLab™ (Hamid et al., 2024 [13]) and MAIScope (Sangameswaran, 2022 [14]), but at a fraction of the cost, and built using open-source tools that promote scalability and local adaptation. While Kudisthalert et al. [7] and Khan et al. [6] attempted parasite counting, most prior models were not assessed for reproducibility across repeated runs, nor compared against multiple human operators. Our results showed high consistency across three repeated OFM runs (low inter-run variability), and comparable or superior accuracy to human microscopists, who showed inter-operator variation in cell counts. Additionally, our system demonstrated promising performance in parasitemia estimation, achieving significantly higher accuracy and consistency compared to manual microscopy. While many previous studies on AI-assisted malaria diagnostics have focused primarily on binary classification of infected versus uninfected cells, parasitemia estimation—a critical parameter for assessing disease severity and monitoring treatment response—has often been underrepresented or overlooked. This gap is concerning, given the clinical importance of quantifying parasite load in guiding therapeutic decisions and identifying high-risk cases. In our study, manual microscopy yielded parasitemia estimates with low accuracy (average 38%) and high inter-observer variability, further compounded by the time-intensive nature of counting cells across multiple fields of view. In contrast, our automated OFM-based system produced accurate and reproducible parasitemia estimates in under 40 minutes, highlighting its potential as a reliable tool for real-time disease severity assessment in both clinical and field settings. Unlike most existing models which operate as standalone tools, our vision includes IoT connectivity for remote diagnostics and real-time surveillance, aligning with recent edge AI trends such as those reported by Lin et al. (2024) [16] and Bae et al. (2024) [12]. This approach could enable large-scale epidemiological monitoring and integration into national health information systems. In line with the OpenFlexure framework (Collins et al., 2020 [17]; Rosen et al., 2024 [18]), our platform is modular and has shown preliminary success in histological image analysis for cancer diagnosis. This supports future applications beyond malaria, as explored by Bhattiprolu (2024) [19] through open-source image annotation tools, and reinforces the adaptability of our approach. In summary, our work contributes to the growing body of literature on AI-assisted malaria diagnosis by offering a fully integrated, low-cost, and field-deployable platform. It bridges the gap between lab-scale AI models and practical diagnostic tools by focusing on automation, reproducibility, and connectivity—key elements for scalable, equitable healthcare delivery in low-resource settings. 4. Conclusion This study set out to develop and evaluate a fully automated malaria diagnostic system based on a customized OpenFlexure Microscope (OFM), with the specific objectives of enabling accurate parasitemia estimation, integrating a reliable autofocusing mechanism for high-magnification imaging, and deploying a deep learning model for real-time detection of infected and non-infected red blood cells (RBCs) as well as white blood cells (WBCs). To address the limitations of manual microscopy—namely its time intensiveness, reliance on expert skill, and low reproducibility—we implemented a custom Laplacian variance-based autofocusing algorithm and trained a YOLOv11n object detection model on locally acquired and annotated blood smear images. Our system achieved a parasitemia estimation accuracy of 80%, compared to 38% for experienced human microscopists, while reducing diagnostic time from over 1 hour and 40 minutes to under 40 minutes per slide. The system also demonstrated consistent image quality and focus across 100 fields of view. These findings highlight the potential of our OFM-based platform as a practical, low-cost solution for automated malaria diagnosis, particularly in resource-limited and point-of-care settings. Declarations Ethics Statement : This study involving human participants was reviewed and approved by the Meru University of Science and Technology Institutional Research Ethics Committee (MIRERC). Written informed consent was obtained from all participants, and for minors under 18 years of age, assent was obtained in addition to parental or guardian consent. All procedures were conducted in accordance with the relevant guidelines and regulations. Funding Academy of Medical Sciences Networking Grant (NGR1\1211), funded by the UK Department for Science, Innovation and Technology (DSIT) through the International Science Partnerships Fund (ISPF). Acknowledgment The authors gratefully acknowledge the Academy of Medical Sciences for providing partial funding to support this research. We also extend our sincere appreciation to Professor Pietro Cicuta of University of Cambridge for his invaluable role in supporting capacity building, particularly in the acquisition of skills related to the fabrication and customization of the OpenFlexure Microscope. Disclosures The authors declare that there is no conflict of interest regarding the publication of this work. Data availability Data and source code underlying the results presented in this paper are available in a public GitHub repository: https://github.com/EzekielOtieno/Malaria (Ref. [19]). References M. Poostchi, K. Silamut, R. J. Maude, et al., "Image analysis and machine learning for detecting malaria," Transl. Res. 194 , 36–55 (2018). G. Madhu, A. W. Mohamed, S. Kautish, et al., "Intelligent diagnostic model for malaria parasite detection and classification using imperative inception-based capsule neural networks," Sci. Rep. 13 (1), 13377 (2023). S. Kumar, T. Arif, A. S. Alotaibi, et al., "Advances towards automatic detection and classification of parasites microscopic images using deep convolutional neural network: methods, models and research directions," Arch. Comput. Methods Eng. 30 (3), 2013–2039 (2023). S. Elayaraja, S. Yeruva, V. Stejskal, et al., "Multi-Class Microscopic Image Analysis of Protozoan Parasites Using Convolutional Neural Network," J. Univ. Comput. Sci. 30 (4), 420 (2024). A. Rahman, H. Zunair, T. R. Reme, et al., "A comparative analysis of deep learning architectures on high variation malaria parasite classification dataset," Tissue Cell 69 , 101473 (2021). S. H. Khan, N. S. Shah, R. Nuzhat, et al., "Malaria parasite classification framework using a novel channel squeezed and boosted CNN," Microscopy 71 (5), 271–282 (2022). W. Kudisthalert, K. Pasupa, and S. Tongsima, "Counting and classification of malarial parasite from giemsa-stained thin film images," IEEE Access 8 , 78663–78682 (2020). D. A. Ramos-Briceño, A. Flammia-D’Aleo, G. Fernández-López, et al., "Deep learning-based malaria parasite detection: convolutional neural networks model for accurate species identification of Plasmodium falciparum and Plasmodium vivax ," Sci. Rep. 15 (1), 3746 (2025). D. Tan and X. Liang, "Multiclass malaria parasite recognition based on transformer models and a generative adversarial network," Sci. Rep. 13 (1), 17136 (2023). M. R. Islam, M. Nahiduzzaman, M. O. F. Goni, et al., "Explainable transformer-based deep learning model for the detection of malaria parasites from blood cell images," Sensors 22 (12), 4358 (2022). N. Sengar, R. Burget, and M. K. Dutta, "A vision transformer based approach for analysis of Plasmodium vivax life cycle for malaria prediction using thin blood smear microscopic images," Comput. Methods Programs Biomed. 224 , 106996 (2022). C. Y. Bae, Y. M. Shin, M. Kim, et al., "Embedded-deep-learning-based sample-to-answer device for on-site malaria diagnosis," Front. Bioeng. Biotechnol. 12 , 1392269 (2024). M. M. A. Hamid, A. O. Mohamed, F. O. Mohammed, et al., "Diagnostic accuracy of an automated microscope solution (miLab™) in detecting malaria parasites in symptomatic patients at point-of-care in Sudan: a case–control study," Malar. J. 23 (1), 200 (2024). R. Sangameswaran, "MAIScope: A low-cost portable microscope with built-in vision AI to automate microscopic diagnosis of diseases in remote rural settings," arXiv preprint arXiv:2208.06114 (2022). S. A. Ali, P. S. Abdulqadir, S. A. Abdullah, et al., "M2ANET: Mobile Malaria Attention Network for efficient classification of Plasmodium parasites in blood cells," arXiv preprint arXiv:2405.14242 (2024). L. Lin, E. Dacal, N. Díez, et al., "Edge Artificial Intelligence (AI) for real-time automatic quantification of filariasis in mobile microscopy," PLoS Negl. Trop. Dis. 18 (4), e0012117 (2024). J. T. Collins, J. Knapper, J. Stirling, et al., "Robotic microscopy for everyone: the OpenFlexure microscope," Biomed. Opt. Express 11 (5), 2447–2460 (2020). D. G. Rosen, E. S. de Mello, S. Dhingra, et al., "Utility of a low-cost 3-D printed microscope for evaluating esophageal biopsies," Ann. 3D Print. Med. 13 , 100145 (2024). Additional Declarations The authors declare no competing interests. Cite Share Download PDF Status: Posted Version 1 posted You are reading this latest preprint version Research Square lets you share your work early, gain feedback from the community, and start making changes to your manuscript prior to peer review in a journal. As a division of Research Square Company, we’re committed to making research communication faster, fairer, and more useful. We do this by developing innovative software and high quality services for the global research community. Our growing team is made up of researchers and industry professionals working together to solve the most critical problems facing scientific publishing. Also discoverable on Platform About Our Team In Review Editorial Policies Advisory Board Help Center Resources Author Services Accessibility API Access RSS feed Manage Cookie Preferences © Research Square 2026 | ISSN 2693-5015 (online) Privacy Policy Terms of Service Do Not Sell My Personal Information {"props":{"pageProps":{"initialData":{"identity":"rs-6809543","acceptedTermsAndConditions":true,"allowDirectSubmit":true,"archivedVersions":[],"articleType":"Research Article","associatedPublications":[],"authors":[{"id":465769800,"identity":"f3144c02-b616-4398-a657-aa0a103d2210","order_by":0,"name":"Daniel Maitethia Memeu","email":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAAyAQMAAABI0h/eAAAABlBMVEX///8AAABVwtN+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA8UlEQVRIie3PMWsCMRTA8SeBuKTnei7nV3gi9PPcIdTlKoKLg8NB4VwKXV3EDyE4Pwm0S+ZiydTlJodbBIdQ+q7QpUjUrUP+ZEngx8sDCIX+Y/RzIJUg6PdNXCYEyESmfMXrCDQEQOF1JHrXn7qeuXHUNseNcg46CxJYe0jXPiCRwalUj1t7VyLEJhXZ0kPQpki7ErMSGlLwx/YgtPKSUU27LyadQ2WVQ+g1xHlJzlMKJnEurZIIyGToW79r8wmZ1wGT6v5jVQ5U32RP/WcPiexoU8/mSbZ+GVb7g0uS5E3r+OQb8zdevFXcAkKhUCh0pm8GZlYLy2hOuwAAAABJRU5ErkJggg==","orcid":"","institution":"Meru University of Science and Technology","correspondingAuthor":true,"prefix":"","firstName":"Daniel","middleName":"Maitethia","lastName":"Memeu","suffix":""}],"badges":[],"createdAt":"2025-06-03 09:33:22","currentVersionCode":1,"declarations":{"humanSubjects":true,"vertebrateSubjects":false,"conflictsOfInterestStatement":false,"humanSubjectEthicalGuidelines":true,"humanSubjectConsent":true,"humanSubjectClinicalTrial":false,"humanSubjectCaseReport":false,"vertebrateSubjectEthicalGuidelines":false},"doi":"10.21203/rs.3.rs-6809543/v1","doiUrl":"https://doi.org/10.21203/rs.3.rs-6809543/v1","draftVersion":[],"editorialEvents":[],"editorialNote":"","failedWorkflow":false,"files":[{"id":84205001,"identity":"14e6fba6-6e0c-456d-a828-61be46368f27","added_by":"auto","created_at":"2025-06-09 08:55:43","extension":"png","order_by":1,"title":"Figure 1","display":"","copyAsset":false,"role":"figure","size":818071,"visible":true,"origin":"","legend":"\u003cp\u003e\u003cem\u003eSetup of the customized OpenFlexure Microscope (OFM) for automated malaria diagnosis. A Giemsa-stained blood smear slide is mounted on the sample stage of the OFM. The system is connected to a large LED display via HDMI for real-time image visualization, while a USB keyboard and mouse are used to navigate and control the OFM software interface. The setup enables automated slide scanning, image acquisition, and analysis directly from the microscope platform.\u003c/em\u003e\u003c/p\u003e","description":"","filename":"1.png","url":"https://assets-eu.researchsquare.com/files/rs-6809543/v1/7e7512807ff2e9716673b9e9.png"},{"id":84203889,"identity":"c0b07274-791f-41e0-a2aa-51e0b48544ce","added_by":"auto","created_at":"2025-06-09 08:47:43","extension":"png","order_by":2,"title":"Figure 2","display":"","copyAsset":false,"role":"figure","size":173063,"visible":true,"origin":"","legend":"\u003cp\u003e\u003cem\u003eFlowchart illustrating the custom autofocus algorithm implemented on the OpenFlexure Microscope (OFM). The algorithm consists of a two-stage focusing process: rough focus determination through coarse z-stack acquisition and Laplacian variance analysis, followed by fine focus refinement using smaller step-size scanning around the rough focus position.\u003c/em\u003e\u003c/p\u003e","description":"","filename":"2.png","url":"https://assets-eu.researchsquare.com/files/rs-6809543/v1/8fc4d8f108106147eb668584.png"},{"id":84202834,"identity":"e2230d54-44b2-48e4-932b-4f63f86026fb","added_by":"auto","created_at":"2025-06-09 08:39:43","extension":"png","order_by":3,"title":"Figure 3","display":"","copyAsset":false,"role":"figure","size":66023,"visible":true,"origin":"","legend":"\u003cp\u003e\u003cem\u003eVariance of Laplacian values computed from microscope z-scan images for autofocus determination. (a) Coarse focus scan with a motor step size of 200 units; the z-position corresponding to the peak of the curve indicates the coarse focus position. (b) Fine focus scan with a reduced motor step size of 50 units, performed around the coarse focus position. The best focus is identified by locating the peak variance value between the immediate left and right neighbors of the coarse focus position.\u003c/em\u003e\u003c/p\u003e","description":"","filename":"3.png","url":"https://assets-eu.researchsquare.com/files/rs-6809543/v1/c256d5e15ff7e420f541e51b.png"},{"id":84202839,"identity":"b5ee7c6f-d72c-4627-911f-1bc2a6c54854","added_by":"auto","created_at":"2025-06-09 08:39:43","extension":"png","order_by":4,"title":"Figure 4","display":"","copyAsset":false,"role":"figure","size":1083124,"visible":true,"origin":"","legend":"\u003cp\u003e\u003cem\u003eComparison of best-focus images acquired using the custom-developed autofocus algorithm and the OpenFlexure Microscope (OFM) client library autofocus function. Panels (a)–(e) show images captured at the 1st, 25th, 50th, and 100th fields of view (FOVs) using the custom algorithm, while panels (f)–(i) display images captured at the corresponding FOV positions (1st, 25th, 50th, and 75th) using the OFM client autofocus function.\u003c/em\u003e\u003c/p\u003e","description":"","filename":"4.png","url":"https://assets-eu.researchsquare.com/files/rs-6809543/v1/a1fd9acb2fdddddcdd0677d9.png"},{"id":84205003,"identity":"5ba2876f-79ab-4ac4-808a-0adc445bcedd","added_by":"auto","created_at":"2025-06-09 08:55:43","extension":"png","order_by":5,"title":"Figure 5","display":"","copyAsset":false,"role":"figure","size":99395,"visible":true,"origin":"","legend":"\u003cp\u003e\u003cem\u003eComparison of image sharpness and scanning time between a custom-developed autofocus algorithm and the OpenFlexure Microscope (OFM) client library autofocus function. Image sharpness was quantified using the variance of the Laplacian of each best-focus image across five representative positions in a 100-field scan. Total scanning time for all 100 images is also reported for each method.\u003c/em\u003e\u003c/p\u003e","description":"","filename":"5.png","url":"https://assets-eu.researchsquare.com/files/rs-6809543/v1/1270b99c0b80a1a89750e8c4.png"},{"id":84202850,"identity":"d3d39026-8849-4afa-bf3f-df4c0a0f13bf","added_by":"auto","created_at":"2025-06-09 08:39:43","extension":"png","order_by":6,"title":"Figure 6","display":"","copyAsset":false,"role":"figure","size":139356,"visible":true,"origin":"","legend":"\u003cp\u003eTraining and validation performance metrics of the YOLOv11n model over 100 epochs. The top row shows training losses and performance metrics including box loss, segmentation loss, classification loss, distribution focal loss (DFL), precision, and recall. The bottom row presents corresponding validation metrics. Also shown are the mean average precision (mAP) at IoU thresholds 0.5 and 0.5:0.95 for both bounding box detection (B) and mask-based object detection (M). The consistently decreasing loss curves and increasing mAP scores indicate stable learning and improving model performance throughout training.\u003c/p\u003e","description":"","filename":"6.png","url":"https://assets-eu.researchsquare.com/files/rs-6809543/v1/b0872a8366747d12b1890d1e.png"},{"id":84203891,"identity":"7a8be85d-3be6-4a56-a421-fd230696b271","added_by":"auto","created_at":"2025-06-09 08:47:43","extension":"png","order_by":7,"title":"Figure 7","display":"","copyAsset":false,"role":"figure","size":94259,"visible":true,"origin":"","legend":"\u003cp\u003e\u003cem\u003ePrecision-confidence (left) and recall-confidence (right) curves for the three target classes: infected RBCs, non-infected RBCs, and WBCs. The model demonstrates high precision at elevated confidence thresholds, particularly for non-infected RBCs and WBCs, reflecting its reliability in making accurate predictions.\u003c/em\u003e\u003c/p\u003e","description":"","filename":"7.png","url":"https://assets-eu.researchsquare.com/files/rs-6809543/v1/1f54fee037cb34d6b6eaeee6.png"},{"id":84202852,"identity":"8c12fa7c-dccd-4a0a-838a-7023e866f274","added_by":"auto","created_at":"2025-06-09 08:39:43","extension":"png","order_by":8,"title":"Figure 8","display":"","copyAsset":false,"role":"figure","size":849162,"visible":true,"origin":"","legend":"\u003cp\u003eRepresentative output image from the automated malaria diagnostic system showing the results of object detection using the YOLOv11n model. Red bounding boxes indicate red blood cells (RBCs) identified as Plasmodium-infected, while yellow bounding boxes represent non-infected RBCs. The system accurately detects and classifies individual cells across the field of view, supporting reliable parasitemia estimation.\u003c/p\u003e","description":"","filename":"8.png","url":"https://assets-eu.researchsquare.com/files/rs-6809543/v1/1dfd7fa881fefdd086ff548e.png"},{"id":84202849,"identity":"6ad5d205-fa55-41a7-8c11-765e6ee5b7d1","added_by":"auto","created_at":"2025-06-09 08:39:43","extension":"png","order_by":9,"title":"Figure 9","display":"","copyAsset":false,"role":"figure","size":63130,"visible":true,"origin":"","legend":"\u003cp\u003e\u003cem\u003eComparison of average parasitemia estimation accuracy between the OFM-based deep learning system and human microscopists. Error bars represent standard deviations calculated from three independent evaluations per system.\u003c/em\u003e\u003c/p\u003e","description":"","filename":"9.png","url":"https://assets-eu.researchsquare.com/files/rs-6809543/v1/e1f2ae6a733f40fd1ae6c5a9.png"},{"id":84206520,"identity":"aa691795-59e2-411a-82c3-597aa7cd004a","added_by":"auto","created_at":"2025-06-09 09:11:45","extension":"pdf","order_by":0,"title":"","display":"","copyAsset":false,"role":"manuscript-pdf","size":4537414,"visible":true,"origin":"","legend":"","description":"","filename":"manuscript.pdf","url":"https://assets-eu.researchsquare.com/files/rs-6809543/v1/f267538f-8951-475d-8ac6-b0f5f88bcf5b.pdf"}],"financialInterests":"The authors declare no competing interests.","formattedTitle":"\u003cp\u003e\u003cstrong\u003eAutomated malaria diagnosis and parasitemia estimation using a customized OpenFlexure microscope\u003c/strong\u003e\u003c/p\u003e","fulltext":[{"header":"1. Introduction","content":"\u003cp\u003eMalaria remains a major public health challenge, particularly in sub-Saharan Africa, where it accounts for a significant proportion of morbidity and mortality. Accurate and timely diagnosis is essential for effective treatment and malaria control. Microscopy of Giemsa-stained blood smears remains the gold standard for malaria diagnosis due to its ability to quantify parasitemia and distinguish between Plasmodium species. However, conventional optical microscopy is time-consuming, requires well-trained personnel, and suffers from limited reproducibility, especially in resource-constrained settings.\u003c/p\u003e\n\u003cp\u003eRecent advances in digital microscopy and artificial intelligence (AI) offer opportunities to overcome these limitations by automating the diagnostic process. Early efforts utilized conventional machine learning algorithms such as Support Vector Machines (SVMs), k-Nearest Neighbors (k-NN), Decision Trees and shallow Artificial Neural Network (ANN) [1]. These methods required manual feature extraction from blood smear images, relying on handcrafted features like color, texture, and shape to differentiate between infected and uninfected cells. While these approaches provided initial automation, their performance was limited by the quality of feature extraction and lacked robustness across diverse datasets.\u003c/p\u003e\n\u003cp\u003eThe advent of deep learning, particularly Convolutional Neural Networks (CNNs), revolutionized image-based malaria diagnosis. CNNs automatically learn hierarchical feature representations from raw pixel data, eliminating the need for manual feature engineering. Architectures like ResNet50 and EfficientNet have demonstrated high accuracy in classifying parasitized and uninfected red blood cells [2 - 8]. A recent study has reported an accuracy of 99.51% in classifying Plasmodium species using a CNN-based model [8].\u003c/p\u003e\n\u003cp\u003eMore recently, transformer-based models, originally developed for natural language processing tasks, have been adapted for image analysis. Vision Transformers (ViTs) and their variants employ self-attention mechanisms to capture global contextual information in images [9-10]. A notable study proposed a multiheaded attention-based transformer model for malaria parasite detection, achieving high accuracy and offering interpretability through techniques like Grad-CAM [11]. These models have shown promise in capturing complex patterns in blood smear images, potentially outperforming traditional CNNs in certain scenarios.\u003c/p\u003e\n\u003cp\u003eDespite these advancements, many AI-enabled diagnostic systems are designed for deployment on conventional PCs interfaced with high-end digital microscopes. Such setups are often impractical in rural or low-income settings due to their cost, size, and power requirements. The reliance on powerful computing resources and stable internet connectivity further limits their applicability in resource-constrained environments. To address these challenges, there is a growing interest in deploying AI models on edge devices\u0026mdash;compact, low-power hardware capable of performing computations locally. Edge deployment reduces latency, enhances data privacy, and enables real-time diagnostics without the need for continuous internet access.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eA few pioneering studies have demonstrated the integration of artificial intelligence (AI) models into edge devices for real-time malaria diagnosis. These efforts represent critical milestones toward the democratization of diagnostic technologies, especially in low-resource settings. One notable example is miLab\u0026trade;, a portable, automated diagnostic platform that integrates a deep learning model on embedded hardware for malaria screening. miLab\u0026trade; automates slide staining, autofocusing, imaging, and parasite detection. Deployed in field settings in Malawi and Sudan, it achieved a high detection accuracy of 98.86% [12-13]. While miLab\u0026trade; is a fully integrated system, it still relies on relatively complex mechanics for slide handling and may not be easily locally fabricated or maintained without specialized components.\u003c/p\u003e\n\u003cp\u003eAnother key contribution is MAIScope\u0026mdash;a low-cost, portable microscope enhanced with vision AI, designed to automate malaria diagnostics in rural areas. MAIScope uses a custom CNN model for RBC segmentation and parasite detection, and is operable without internet access. It achieved an average classification accuracy of 89.9%, and was evaluated using a smartphone-attached microscope [14]. However, the system was limited by low image resolution and lacked support for high-magnification imaging (e.g., 100\u0026times; oil immersion), which is crucial for detecting early-stage (ring form) parasites.\u003c/p\u003e\n\u003cp\u003eThe Mobile Malaria Attention Network (M2ANET) is another lightweight model designed specifically for mobile device deployment. M2ANET combines MobileNetV3 blocks with multi-head self-attention for real-time inference on mobile phones. It outperformed other mobile-compatible networks in accuracy and inference speed [15]. Despite its efficient architecture, M2ANET\u0026rsquo;s validation was primarily done on cropped and preprocessed image patches, without demonstrating full-slide scanning or field-deployable hardware integration. A different study introduced a real-time edge AI system deployed on smartphones to assist in the screening and species differentiation of filarial samples using mobile microscopy [16].\u003c/p\u003e\n\u003cp\u003eCollectively, these studies mark significant progress in the shift from laboratory-based AI applications to on-device, real-time malaria diagnostics. However, they typically fall short in one or more of the following areas:\u003c/p\u003e\n\u003col start=\"1\" type=\"i\"\u003e\n \u003cli\u003eLimited integration with physical microscopy hardware, especially affordable, opensource, high-magnification systems like the OpenFlexure Microscope (OFM);\u003c/li\u003e\n \u003cli\u003eLack of support for full slide scanning workflows;\u003c/li\u003e\n \u003cli\u003eDependence on preprocessed or cropped image datasets, which may not reflect the variability in real-world blood smear slides;\u003c/li\u003e\n \u003cli\u003eInsufficient field validation across large sample sizes and varied environmental conditions.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eThe OpenFlexure Microscope (OFM) is an open-source, 3D-printed digital microscope that has gained attention as a low-cost and customizable imaging platform [17]. Its modular design and local manufacturability make it a promising tool for point-of-care (PoC) applications. While the OFM has previously been used for basic imaging tasks [18], its potential for automated diagnostic workflows remains underexplored.\u003c/p\u003e\n\u003cp\u003eIn this study, we present a fully integrated and automated malaria diagnostic system based on the OpenFlexure Microscope (OFM) platform. Our contributions include: (i) the development of a custom autofocusing algorithm optimized for 100\u0026times; oil immersion imaging of blood smear samples; (ii) the integration of a YOLO-based object detection model to identify and quantify \u003cem\u003ePlasmodium\u003c/em\u003e-infected red blood cells (iRBCs), non-infected RBCs, and white blood cells (WBCs); and (iii) the implementation of a complete slide scanning routine covering 100 fields of view. We evaluated the system\u0026rsquo;s performance in terms of parasitemia estimation accuracy, result reproducibility, and time efficiency, benchmarking it against expert human microscopists. Our findings demonstrate the feasibility of deploying AI-powered, low-cost diagnostic solutions in low-resource settings, supporting global efforts toward malaria control and elimination. The image dataset and Python code used in this work are available in the GitHub repository referenced in [19].\u003cstrong\u003e\u0026nbsp;\u003c/strong\u003eA link to a short youtube video demo illustrating the operation of the prototype can be accessed through reference [20]\u003cstrong\u003e.\u003c/strong\u003e\u003c/p\u003e"},{"header":"2. Materials and Methods","content":"\u003ch2\u003e\u003cstrong\u003e2.1 Ethical approval\u003c/strong\u003e\u003c/h2\u003e\n\u003cp\u003eEthical approval to conduct the study was sought from Meru University Institutional Research Ethics Review Committee (MIRERC) which is a local ethics review board licensed by the national research regulatory body of Kenya referred to as National Council of Science Technology and Innovation (NACOSTI). Participants in the study were required to give informed consent indicating they have been adequately informed about the goal, methodology and potential benefits and risks of the study and they willfully and voluntarily decided to participate in the study. The consent agreement also provided for withdrawal from participation at any point of the study. Informed consent by minors participating in the study was made by their guardians.\u003c/p\u003e\n\u003ch2\u003e\u003cstrong\u003e2.2 Sample collection and bood smear preparation\u003c/strong\u003e\u003c/h2\u003e\n\u003cp\u003ePeripheral blood samples were obtained from participants with confirmed malaria infection. Each participant donated 2 ml of venous blood, which was collected into EDTA-treated tubes and securely sealed to prevent coagulation. A total of 20 participants contributed blood samples for the study. From each blood sample, multiple aliquots were used to prepare thin blood smears. In total, approximately 400 blood smear slides were prepared. The smears were air-dried, fixed with methanol, and stained using Giemsa stain. The stained slides were then imaged using the OpenFlexure Microscope (OFM) for further analysis.\u003c/p\u003e\n\u003ch2\u003e\u003cstrong\u003e2.3 Image Acquisition\u003c/strong\u003e\u003c/h2\u003e\n\u003cp\u003eImage acquisition was carried out using the OpenFlexure Microscope (OFM), an open-source, low-cost, motorized microscope. Prepared Giemsa-stained thin blood smear slides were loaded individually onto the microscope\u0026rsquo;s sample stage and secured using the built-in slide clips. The OFM was connected to an external monitor via HDMI to enable real-time visualization. A keyboard and mouse were also connected to the system to facilitate user interaction. Once the microscope was powered on, the OFM-Connect application was launched to initiate image acquisition. Figure 1 shows the setup.\u003c/p\u003e\n\u003cp\u003eA camera calibration routine, including white balance adjustment, was performed before imaging to ensure color fidelity and accurate representation of stained cellular structures. Initial focusing of the first image was achieved either manually by adjusting up or down the z-position of the objective lens through the OFM software interface or by using the built-in autofocus function. Once the image was brought into coarse focus, an automatic image acquisition script was launch to grab and save the blood smear images at different microscope Field of Views (FoVs). A 100X oil immersion objective lens was used throughout the imaging process to ensure sufficient magnification and resolution for identifying Plasmodium-infected red blood cells. The steps followed to implement the automated image acquisition routine were; (i) Sample autofocusing (ii) Image capture and saving, (iii) Stage translation to a new FoV, (iv) Repetition of the above steps across the entire scan area i.e., 100 FoVs.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eSlides were scanned using a raster scanning pattern with a lateral step size of 400 motor steps (~400 between successive fields. This allowed systematic coverage of the smear area while minimizing image overlap and redundancy. During a preliminary evaluation of the application the OFM to image malaria blood smear using 100X 1.25NA oil immersion objective, we found that the default microscope autofocus function produced increasingly defocused images after a few iterations of the scan cycle. This is due to the shallow Depth of Field (DoF) of the objective lens which implies a slight lateral displacement result in the image getting out of focus due to both the sample nonuniform thickness and the motor gear backrush during microscope stage translation. Therefore, one of the objectives of this work was to develop a custom autofocus algorithm optimized for blood smear auto scanning using 100X 1.25 NA objective. The autofocusing algorithm was integrated with the raster scanning routine described above. The algorithmic steps for the improved autofocus method are detailed below.\u0026nbsp;\u003c/p\u003e\n\u003ch3\u003e\u003cstrong\u003e2.3.1 Custom Autofocus Algorithm\u003c/strong\u003e\u003c/h3\u003e\n\u003cp\u003eThe algorithm involves two stages: first, determination of the rough focus direction and position, and second refinement through fine focus scanning. Figure 2 presents the algorithmic steps and the description of the steps is provided below.\u003cstrong\u003e\u003cem\u003e\u0026nbsp;\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003e\u003cem\u003eRough Focus Determination\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eWhen the microscope is translated to a new field of view, the system begins by identifying the approximate focus region through a z-stack acquisition process. The objective lens is first moved downwards, acquiring 10 images at equal intervals with a coarse step size of 200 motor steps (with each step being \u0026nbsp;). The lens is then returned to the initial z-position, after which 10 additional images are acquired in the upward direction using the same step size. This results in a total of 20 z-stack images. For each image in the z-stack, a Laplacian transform is computed, and the \u003cstrong\u003ev\u003c/strong\u003eariance of the resulting Laplacian image is calculated. The variance of the Laplacian is evaluated and used as image sharpness metric. Higher variance values indicate sharper images and better focus.\u003c/p\u003e\n\u003cp\u003eThe direction of the sharpness gradient is then analysed as follows: If the variance values have a clear peak between the start and end of the z-stack (i.e., a maximum exists within the 20 images), the corresponding z-position of this peak is identified as the rough focus position. The microscope is moved to this z-position. Else if the variance values show a monotonic increase or decrease across the 20 points (i.e., no peak is detected), the objective is moved one additional step (200 steps) beyond the current endpoint in the direction of increasing variance and additional images are acquired in that direction. At each new z-position: A new image is captured, the Laplacian and its variance are calculated, the variance of the current image is compared to that of the previous position. If the current variance is greater, the objective continues moving in the same direction. Else if the variance decreases, the previous z-position (with the highest variance) is set as the rough focus position.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003e\u003cem\u003eFine Focus Determination\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eTo refine the focus, a second z-stack is acquired around the rough focus position: the objective is first moved 200 steps below the rough focus position, a fine z-stack is then acquired this time using a smaller step size of 50 steps. The scan continues until the objective is 200 steps above the rough focus position, covering a total of 400 steps. As before, the Laplacian of each image is computed and the variance calculated. The z-position corresponding to the maximum variance within this finer stack is identified as the fine focus position. The microscope is then moved to this position, and the focused image is captured and saved for further processing. \u0026nbsp;\u003c/p\u003e\n\u003ch2\u003e\u003cstrong\u003e2.4 Image Annotation\u003c/strong\u003e\u003c/h2\u003e\n\u003cp\u003eFollowing the acquisition of blood smear images using the previously described method, image annotation was carried out to generate labelled datasets for machine learning model training. The annotation process was performed using the Sreeni Image Annotator software [21]. The objective was to classify and label individual cells within each image based on their infection status and cell type. The following procedure was followed:\u003c/p\u003e\n\u003ch3\u003e\u003cstrong\u003e2.4.1 Class Definition\u003c/strong\u003e\u003c/h3\u003e\n\u003cp\u003eThree annotation classes were created within the software to guide the labelling process. The classes were; Infected RBC \u0026ndash; Red blood cells containing visible Plasmodium parasites, Non-Infected RBC \u0026ndash; Red blood cells without any observable signs of infection and WBC \u0026ndash; White blood cells present in the blood smear. To facilitate efficient annotation, the acquired images were imported into the annotation software batches and each image was manually reviewed and annotated by marking individual cells with bounding boxes and assigning them to one of the three predefined classes. \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eUpon completion of the labelling process for each image, annotations were saved in YOLO (You Only Look Once) format, which is suitable for training object detection models. This process was repeated across all batches, resulting in a total of approximately 4000 annotated images. The annotated dataset was periodically reviewed to ensure consistency and accuracy in labelling across images. Any discrepancies identified during the quality checks were corrected to maintain high-quality annotation standards.\u0026nbsp;\u003c/p\u003e\n\u003ch2\u003e\u003cstrong\u003e2.5 Dataset Preparation\u003c/strong\u003e\u003c/h2\u003e\n\u003cp\u003eA total of 4,000 annotated images were used for training a machine learning model to detect malaria-infected red blood cells. The dataset was split as follows: 70% for training (2,800 images), 20% for validation (800 images) and10% for testing (400 images). The dataset was organized using a data.yaml configuration file, which is essential for training YOLO-based models. This file specifies; File paths to images and labels, Class names (e.g., infected RBC, uninfected RBC, WBC) and Dataset splits (train, validation, test)\u003cstrong\u003e\u0026nbsp;\u003c/strong\u003e\u003c/p\u003e\n\u003ch2\u003e\u003cstrong\u003e2.6 Model Training\u003c/strong\u003e\u003c/h2\u003e\n\u003cp\u003eThe YOLOv11n model was selected due to its high speed and efficient performance, making it suitable for real-time object detection on edge devices. Despite its lightweight nature, YOLOv11n achieves a good balance between speed and accuracy.\u003c/p\u003e\n\u003ch3\u003e\u003cstrong\u003e2.6.1 Model Architecture\u003c/strong\u003e\u003c/h3\u003e\n\u003cp\u003eYOLOv11n follows the typical YOLO architecture, which consists of three main components:\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003e\u003cem\u003eBackbone\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eResponsible for extracting features from the input image using convolutional layers. YOLOv11n uses the C3K2 block - an optimized version of Cross Stage Partial (CSP) for faster processing. It also introduces the C2PSA block - which adds spatial attention to focus on the most relevant regions of an image, enhancing detection accuracy.\u003cstrong\u003e\u003cem\u003e\u0026nbsp;\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003e\u003cem\u003eNeck\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eCombines and processes multi-scale features extracted by the backbone. Enhances the model\u0026apos;s ability to detect objects of varying sizes. YOLOv11n incorporates improved C3K2 blocks at this stage for better speed and performance.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003e\u003cem\u003eHead\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eGenerates final predictions, including bounding boxes and class labels for objects (e.g., infected or uninfected RBCs, WBCs).\u003c/p\u003e\n\u003ch3\u003e\u003cstrong\u003e2.6.2 Training Process\u003c/strong\u003e\u003c/h3\u003e\n\u003cp\u003eThe training process was conducted in a JupyterLab environment on a GPU-enabled workstation equipped with an NVIDIA GPU (driver version 522.06) and 8 GB of memory. The training was executed over 100 epochs, with each epoch taking an average of approximately 247 seconds, resulting in a total training time of around 6.7 hours. The learning process utilized the default YOLO optimizer and learning rate, which is based on the Adam optimizer with an initial learning rate of 0.001.\u003c/p\u003e\n\u003cp\u003eDuring training, no data augmentation techniques were applied, as the training framework in use did not support inline augmentation via the command-line interface. The model relied solely on the original distribution of the dataset, which was inherently imbalanced in terms of class frequency. No techniques such as class weighting or oversampling were applied. The model was therefore trained to learn directly from the naturally occurring distribution of infected and uninfected cells.\u003c/p\u003e\n\u003cp\u003eYOLOv11n optimizes a combination of three loss components during training: classification loss for accurate label prediction, localization loss based on Intersection over Union (IoU) for precise bounding box regression, and objectness loss to evaluate the presence of target objects within bounding boxes. These loss components are built into the YOLO architecture and work together to improve the model\u0026rsquo;s overall detection performance.\u003c/p\u003e\n\u003cp\u003eThroughout training, the model\u0026apos;s performance on the validation set was monitored to avoid overfitting. While no early stopping strategy was explicitly used, the model was capped at 100 epochs, and the best-performing version\u0026mdash;based on validation accuracy\u0026mdash;was automatically saved in PyTorch format (best.pt). No conversion to other deployment formats (e.g., ONNX or TensorRT) was performed at this stage, as the model was to be deployed within the same PyTorch-compatible environment.\u003c/p\u003e\n\u003ch2\u003e\u003cstrong\u003e2.7 Model Evaluation Procedure\u003c/strong\u003e\u003c/h2\u003e\n\u003cp\u003eAfter training the YOLOv11n model on the annotated blood smear image dataset, the model\u0026apos;s performance was evaluated using a systematic validation process. The goal of this evaluation was to assess the model\u0026rsquo;s ability to accurately detect and classify three target cell types: infected red blood cells (RBCs), non-infected RBCs, and white blood cells (WBCs).\u003c/p\u003e\n\u003cp\u003eA test dataset comprising 20% of the total annotated images was used for performance assessment. This dataset was not exposed to the model during training, ensuring an unbiased evaluation of generalization capability. The evaluation process employed several standard metrics widely used in object detection and classification tasks:\u003c/p\u003e\n\u003cp\u003ePrecision was used to quantify the proportion of true positive predictions out of all positive predictions made by the model. This metric is important for evaluating the model\u0026apos;s ability to avoid false positives. Recall was used to measure the proportion of true positive detections out of all actual positive instances in the dataset. It assesses the model\u0026apos;s capacity to detect relevant objects comprehensively. Mean Average Precision (mAP) was used to evaluate the model\u0026rsquo;s overall detection accuracy. The mAP score was calculated at different Intersection over Union (IoU) thresholds.
[email protected] measures average precision at a fixed IoU threshold of 0.5, while
[email protected]:0.95 provides a more stringent assessment by averaging precision over multiple IoU thresholds from 0.5 to 0.95 in increments of 0.05.\u003c/p\u003e\n\u003cp\u003eLoss Metrics were monitored during validation and included bounding box loss (for object localization), segmentation loss (where applicable), and classification loss (for label prediction). These losses provided insights into the model\u0026rsquo;s learning efficiency and convergence behavior. Precision-Confidence and Recall-Confidence Curves were plotted to analyze how model confidence levels affected its performance. These curves helped identify optimal confidence thresholds for reliable predictions. Confusion Matrix analysis was also performed to examine the distribution of true positives, false positives, and false negatives across all three classes. This provided a visual overview of how well the model distinguished between different cell types.\u003c/p\u003e\n\u003cp\u003eThroughout the evaluation process, model checkpoints and predictions were compared against ground truth annotations prepared during the image annotation phase. The evaluation procedure was conducted using the same YOLO training and inference environment, ensuring consistency in preprocessing and metric computation. This evaluation methodology provided a comprehensive understanding of the model\u0026rsquo;s strengths and limitations and guided further fine-tuning and deployment decisions.\u0026nbsp;\u003c/p\u003e\n\u003ch2\u003e\u003cstrong\u003e2.8 Model Deployment in the OpenFlexure Microscope (OFM)\u003c/strong\u003e\u003c/h2\u003e\n\u003cp\u003eAfter training, the malaria detection model was saved in PyTorch format (best.pt) on the GPU workstation. For deployment, the model was compressed and transferred to a laptop connected to the OpenFlexure Microscope (OFM) system over a local network. The model was then integrated into a custom Python script responsible for controlling the OFM\u0026rsquo;s slide scanning, image acquisition, and analysis.\u003c/p\u003e\n\u003cp\u003eUpon initiation, the system brings the blood smear slide into focus using an autofocusing algorithm that evaluates image sharpness based on the variance of the Laplacian. Once the optimal focus is achieved, an image is captured and immediately passed to the malaria detection model for analysis.\u003c/p\u003e\n\u003cp\u003eThe model detects and classifies individual cells as \u003cem\u003ePlasmodium\u003c/em\u003e-infected red blood cells (iRBCs), non-infected RBCs, or white blood cells (WBCs). It also generates bounding boxes around each detected object, using distinct border colors for different cell classes to facilitate easy verification by a trained microscopist.\u003c/p\u003e\n\u003cp\u003eThe system systematically scans 100 fields of view (FoVs) across the sample, performing autofocusing, image capture, analysis, and result compilation at each location. For each scanned FoV, the number of infected RBCs, non-infected RBCs, and WBCs is recorded, along with the time taken for processing. At the end of the scanning session, the system collates and outputs a diagnostic report summarizing the total and average counts of each cell type across the scanned area.\u003c/p\u003e\n\u003cp\u003eThis deployment enables the OFM to operate as a fully automated malaria diagnostic platform, capable of real-time detection, parasitemia estimation, and generation of verifiable diagnostic outputs from stained blood smear samples.\u003c/p\u003e\n\u003ch2\u003e\u003cstrong\u003e2.9 Performance Evaluation of the OFM-Based Automated Malaria Diagnostic Platform\u003c/strong\u003e\u003c/h2\u003e\n\u003cp\u003eTo evaluate the performance of the OpenFlexure Microscope (OFM)-based automated malaria diagnostic platform, a comparative study was conducted against the conventional manual optical microscopy method. The evaluation focused on three key metrics: parasitemia estimation accuracy, diagnostic time, and result reproducibility.\u003c/p\u003e\n\u003cp\u003eThree Giemsa-stained thin blood smear slides\u0026mdash;distinct from those used during the model training phase\u0026mdash;were selected for testing. To ensure consistency, the same diagnostic protocol was applied to both the OFM system and human operators.\u003c/p\u003e\n\u003cp\u003eFor the manual microscopy evaluation, three experienced human microscopists were enlisted. Each microscopist examined the three slides using a standard optical microscope equipped with a 100\u0026times;, 1.25 NA oil immersion objective and a 10\u0026times; eyepiece. They systematically reviewed 100 fields of view (FoVs) per slide, recording the number of \u003cem\u003ePlasmodium\u003c/em\u003e-infected red blood cells (iRBCs), the total number of RBCs, and the number of white blood cells (WBCs) for each FoV.\u003c/p\u003e\n\u003cp\u003eIn parallel, the OFM platform performed automated analysis on the same three slides, scanning and analyzing 100 FoVs per slide using its integrated autofocusing and cell detection pipeline. To assess reproducibility, each slide was scanned and analyzed three times under identical conditions using the OFM system, allowing for evaluation of result consistency across repeated runs.\u003c/p\u003e\n\u003cp\u003eTo establish the ground truth for parasitemia estimation, three sets of images\u0026mdash;each comprising 300 distinct FoVs per slide\u0026mdash;were acquired independently using the OFM. These images were annotated by an experienced microscopist not involved in the model training or initial evaluation. The independently annotated results were used to calculate the ground truth parasitemia, against which the parasitemia estimation accuracies of both the OFM platform and the human microscopists were assessed.\u003c/p\u003e"},{"header":"3. RESULTS AND DISCUSSION","content":"\u003cp\u003eIn this section, we present a comparative analysis of image sharpness and acquisition time for 100 images obtained using the custom-developed autofocusing algorithm versus the built-in autofocus function provided by the OFM client library. We also report the evaluation results of the YOLO-based object detection model used for detecting the specified cellular components in blood smear images. Finally, we compare the diagnostic performance of the customized OFM system against that of expert human-operated microscopy.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003e3.1 Evaluation of the Custom-Developed Autofocusing Algorithm\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eThe performance of the custom-developed slide scanning and autofocusing algorithm was first evaluated to determine its efficiency and reliability in capturing high-quality, in-focus images across multiple fields of view (FoVs). Autofocusing was a critical component of the system, ensuring sharp imaging necessary for accurate detection of cellular components.\u003c/p\u003e\n\u003cp\u003eFigure 3 presents sample plots of the variance of the Laplacian computed from z-stack images acquired during the course and fine focusing procedures. Figure 4 compares representative images obtained using the custom autofocus method and the built-in OFM client library autofocus function.\u003c/p\u003e\n\u003cp\u003eFigure 5 provides a comparison of the variance of the Laplacian\u0026mdash;used as a sharpness metric\u0026mdash;at various FoVs, along with the total time taken to scan 100 fields using each autofocus strategy.\u003c/p\u003e\n\u003cp\u003eAutomatic slide scanning using the OFM\u0026rsquo;s built-in autofocus function often produced out-of-focus images, particularly after small stage translations. As shown in Figure 3 panels f to I, less than 75% of the 100 acquired images were of insufficient quality for assessing RBC infection status.\u003c/p\u003e\n\u003cp\u003eIn contrast, our custom-developed autofocus algorithm consistently produced sharper images across all 100 fields of view. Figure 3 panels a to e, shows that all the 100 images acquired from varying microscope FoVs were of sufficient quality to be used to access infection status of the cells. Table 2 indicates that the sharpness metric declined more rapidly with the built-in function compared to the custom algorithm for images captured within 100 FoVs.\u003c/p\u003e\n\u003cp\u003eImage acquisition time was comparable for both methods\u0026mdash;approximately 19 minutes for 100 FOVs. However, while most images from the built-in function were unusable, all the images acquired using the custom algorithm found to be usable.\u0026nbsp;\u003c/p\u003e\n\u003ch2\u003e\u003cstrong\u003e3.2 Evaluation of the deep learning object detection model\u003c/strong\u003e\u003c/h2\u003e\n\u003cp\u003eThe YOLOv11n model trained on annotated blood smear images was evaluated using standard performance metrics to assess its detection accuracy, learning convergence, and training stability. A total of 4,000 annotated images were used in the training and evaluation process, with the dataset split into 70% for training, 20% for validation, and 10% for testing. The annotations captured three distinct classes: infected red blood cells (RBCs), non-infected RBCs, and white blood cells (WBCs).\u003c/p\u003e\n\u003cp\u003eFigure 6 shows the training and validation metrics for your YOLOv11n model across 100 epochs. It\u0026apos;s organized into two rows: the top row represents training metrics, and the bottom row represents validation metrics. Each column represents a different metric, giving a comprehensive view of the model\u0026apos;s performance.\u003c/p\u003e\n\u003cp\u003eThe following are some general observations regarding the generated training and validation losses. (i) Decreasing Loss: All loss plots (box, seg, cls, dfl) show a decreasing trend, indicating that the model was learning effectively. (ii) Increasing Precision and Recall: Precision and recall for bounding boxes are generally increasing, suggesting the model was improving its detection performance. (iii) Increasing mAP50: The mAP50 is also increasing, reinforcing the positive trends in precision and recall. (iv) Potential for Further Improvement: While the model is performing well, one could consider further optimization techniques (e.g., data augmentation, hyperparameter tuning) to see if you can squeeze out even better performance.\u003cstrong\u003e\u0026nbsp;\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eFigure 7 presents the precision-confidence and recall-confidence curves for the three target classes. The model achieved high precision values, particularly at higher confidence thresholds, indicating its ability to make reliable predictions for infected and non-infected RBCs and WBCs.\u003c/p\u003e\n\u003cp\u003eTable 1 displays the confusion matrix derived from the validation data, highlighting the model\u0026rsquo;s ability to accurately differentiate among the three classes. The highest detection counts lie along the diagonal of the matrix, suggesting correct classification, although a small number of background pixels were occasionally misclassified as non-infected RBCs.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eTable 1\u003c/strong\u003e: \u003cem\u003eConfusion matrix showing the classification performance of the YOLO-based object detection model for detecting Plasmodium-infected red blood cells (RBCs), non-infected RBCs, white blood cells (WBCs), and background. The diagonal elements represent correctly classified instances for each class, while off-diagonal values indicate misclassifications.\u0026nbsp;\u003c/em\u003e\u003c/p\u003e\n\u003ctable border=\"1\" cellspacing=\"0\" cellpadding=\"0\"\u003e\n \u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\"\u003e\u003cbr\u003e\u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e\u003cstrong\u003eTrue: Infected RBC\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e\u003cstrong\u003eNon-infected RBC\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e\u003cstrong\u003eWBC\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e\u003cstrong\u003eBackground\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e\u003cstrong\u003ePred: Infected RBC\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e65,868\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e10,504\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e0\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e16,673\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e\u003cstrong\u003ePred: Non-infected RBC\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e6,014\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e199,892\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e1\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e28,313\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e\u003cstrong\u003ePred: WBC\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e1\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e2\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e239\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\"\u003e\n \u003cp\u003e60\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003eUsing values presented in Table 1, the class specific precision, recall, F1 score and overall accuracy was computed and presented in Table 2.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eTable 2\u003c/strong\u003e\u003cem\u003e: Class-wise precision, recall, and F1 score for the YOLO-based object detection model in identifying Plasmodium-infected red blood cells (RBCs), non-infected RBCs, and white blood cells (WBCs). The model achieved the highest recall for WBCs (99.6%) and the highest F1 score for non-infected RBCs (89.9%), indicating robust performance in differentiating cell types. The overall model accuracy across all classes was 81.2%.\u003c/em\u003e\u003c/p\u003e\n\u003ctable border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"463\"\u003e\n \u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\" style=\"width: 141px;\"\u003e\n \u003cp\u003e\u003cstrong\u003eClass\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 115px;\"\u003e\n \u003cp\u003e\u003cstrong\u003ePrecision\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 93px;\"\u003e\n \u003cp\u003e\u003cstrong\u003eRecall\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 113px;\"\u003e\n \u003cp\u003e\u003cstrong\u003eF1 Score\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\" style=\"width: 141px;\"\u003e\n \u003cp\u003e\u003cstrong\u003eInfected RBC\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 115px;\"\u003e\n \u003cp\u003e0.707916\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 93px;\"\u003e\n \u003cp\u003e0.916322\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 113px;\"\u003e\n \u003cp\u003e0.798749\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\" style=\"width: 141px;\"\u003e\n \u003cp\u003e\u003cstrong\u003eNon-infected RBC\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 115px;\"\u003e\n \u003cp\u003e0.853437\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 93px;\"\u003e\n \u003cp\u003e0.950066\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 113px;\"\u003e\n \u003cp\u003e0.899163\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\" style=\"width: 141px;\"\u003e\n \u003cp\u003e\u003cstrong\u003eWBC\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 115px;\"\u003e\n \u003cp\u003e0.791391\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 93px;\"\u003e\n \u003cp\u003e0.995833\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 113px;\"\u003e\n \u003cp\u003e0.881919\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n \u003ctd valign=\"top\" style=\"width: 141px;\"\u003e\n \u003cp\u003e\u003cstrong\u003eOverall accuracy\u003c/strong\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 115px;\"\u003e\n \u003cp\u003e\u0026nbsp;\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 93px;\"\u003e\n \u003cp\u003e\u0026nbsp;\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd valign=\"top\" style=\"width: 113px;\"\u003e\n \u003cp\u003e0.812045\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003eThe model achieved an overall accuracy of 81.2%, with a precision, recall, and F1 score for infected RBCs being 70.8%, 91.6%, and 79.9%, respectively. The prediction scores for non-infected RBCs were precision: 85.3%, recall 95.0%, and F1 score 88.2% while that for WBCs were precision 79.1%, recall: 99.5% and F1 score 88.2%.\u003c/p\u003e\n\u003cp\u003eThese metrics are significant in the context of a disease diagnostic model because:\u003c/p\u003e\n\u003cul type=\"disc\"\u003e\n \u003cli\u003ePrecision reflects how many of the cells identified as infected were actually infected, which is critical for reducing false positives that may lead to unnecessary treatment.\u003c/li\u003e\n \u003cli\u003eRecall (or sensitivity) indicates how many of the truly infected cells were successfully detected by the model. A recall of 70.8% suggests that while the model is effective, there is still room for improvement in capturing all true cases, which is vital for early and accurate malaria diagnosis.\u003c/li\u003e\n \u003cli\u003eF1 Score, the harmonic mean of precision and recall, provides a balanced measure of the model\u0026rsquo;s diagnostic performance.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eCompared to manual microscopy, which has a reported sensitivity of 75\u0026ndash;90% when performed by expert microscopists, the model\u0026rsquo;s sensitivity is within an acceptable range, especially considering its automation potential. In contrast, Rapid Diagnostic Tests (RDTs) typically show lower sensitivity\u0026mdash;often between 60\u0026ndash;75%\u0026mdash;and may fail to detect low parasite densities. Therefore, this automated model demonstrates a promising balance of accuracy and scalability, with the potential to augment or even outperform traditional diagnostic methods in resource-limited settings, especially when deployed on portable systems like the OpenFlexure Microscope.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eThe image in Figure 8 illustrates one of the detection output from the automated malaria diagnostic system, in which a YOLOv11n object detection model has classified individual red blood cells (RBCs) based on infection status. Red bounding boxes highlight RBCs identified as \u003cem\u003ePlasmodium\u003c/em\u003e-infected, while yellow bounding boxes indicate non-infected RBCs. Infected cells exhibit characteristic morphological features such as the presence of dark-staining ring forms, cytoplasmic inclusions, or altered cell shape and texture\u0026mdash;hallmarks of intraerythrocytic \u003cem\u003ePlasmodium\u003c/em\u003e parasites. In contrast, non-infected RBCs typically display a uniform round shape with a central pale zone (biconcave appearance) and lack any internal inclusions or distortions. The detection pattern demonstrates the model\u0026rsquo;s ability to differentiate subtle visual cues across a densely populated field, thereby enabling accurate parasitemia quantification in a manner consistent with expert microscopy assessment. The different color of bounding boxes aid in counterchecking the correctness of the results provided by automated system. The sytem is programmed to count the total infected RBCs, non-infected RBCs and white blood cells detected in 100 FoV automatically scanned. Parasitemia; which is the ratio of infected to non-infected RBCs is also then computed and displayed on the screen.\u0026nbsp;\u003c/p\u003e\n\u003ch2\u003e\u003cstrong\u003e3.3 Comparative Diagnostic study\u0026nbsp;\u003c/strong\u003e\u003c/h2\u003e\n\u003cp\u003eThe fully integrated OFM-based diagnostic system was evaluated in a comparative study alongside three experienced human microscopists. The evaluation focused on three key aspects: diagnostic accuracy relative to expert-annotated ground truth, average diagnostic time per slide, and the reproducibility of results across repeated OFM runs and among human examiners.\u003c/p\u003e\n\u003cp\u003eThe bar chart in Figure 9 compares the parasitemia estimation accuracy of the OFM-based deep learning (DL) diagnostic system to that of experienced human microscopists. The OFM system achieved a markedly higher average accuracy of 80.3%, while human microscopists averaged 38.0%\u0026mdash;indicating a significant performance gap in favor of the automated approach. Additionally, the error bars show that the OFM system exhibited lower variability, suggesting greater reproducibility and consistency across repeated evaluations. In contrast, the human microscopists\u0026apos; performance was both less accurate and more inconsistent. These results emphasize the limitations of manual microscopy for quantitative parasitemia assessment, which is inherently subjective and time-consuming, and underscore the potential of the OFM system to deliver rapid, accurate, and reproducible malaria diagnostics suitable for deployment in routine clinical and field settings. The average time taken by the OFM system was 40 minutes while the human microscope operators took an average time of 1 hour 40 minutes.\u003c/p\u003e\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\n\u003ch3\u003eDiscussion\u003c/h3\u003e\n\u003cp\u003eOur custom-developed autofocusing algorithm, implemented on the OpenFlexure Microscope (OFM), is a software-driven, two-stage routine that combines coarse and fine z-stack scanning with Laplacian variance-based sharpness estimation. In the first stage, the system acquires a bidirectional z-stack (20 images) with coarse steps to approximate the focal region. This is followed by a finer z-stack (8\u0026ndash;10 images) around the peak variance to precisely determine the best-focus position. This approach emphasizes focus accuracy, robustness, and adaptability across large scan areas and varying sample topographies.\u003c/p\u003e\n\u003cp\u003eThis method extends the foundational autofocus strategy proposed by Knapper et al. (2021), who introduced the \u003cem\u003esmart stack\u003c/em\u003e algorithm to address mechanical backlash in OFM hardware. While their approach uses JPEG file size as a proxy for sharpness and fits a Chebyshev polynomial to guide focus correction, it remains limited to generalized imaging tasks and is prone to increased acquisition time due to stack retries. In contrast, our algorithm achieves comparable reliability with minimal overhead by leveraging variance of the Laplacian, a well-established and computationally efficient image sharpness metric. Additionally, our integration with a deep learning diagnostic pipeline demonstrates the algorithm\u0026rsquo;s suitability for clinical workflows where both image quality and operational speed are critical.\u003c/p\u003e\n\u003cp\u003eCompared to the hardware-centric dual-axis optical autofocus system described by Lightley et al. (2023) in the openFrame microscope, our approach offers a cost-effective and easily deployable solution that does not require additional optics, calibration steps, or lookup tables. While the dual-axis laser system provides high precision (\u0026lt;200 nm) and rapid closed-loop correction using single-shot triangulation, it involves more complex hardware integration that may not be feasible in low-resource or field settings. Our algorithm, in contrast, maintains sub-micron focusing reliability through software-only control and can be implemented entirely using existing OFM components, thus aligning better with the goals of open-access, locally manufacturable diagnostic tools.\u003c/p\u003e\n\u003cp\u003eTogether, these comparisons highlight that our autofocus method strikes a practical balance between precision, robustness, and accessibility. It extends previous OFM developments with a malaria-specific application focus, enabling slide scanning with reliable focus over 100 fields of view\u0026mdash;a functionality not demonstrated in either of the prior studies.\u003c/p\u003e\n\u003cp\u003eOur study demonstrated that a fully automated diagnostic platform built around the OpenFlexure Microscope (OFM), integrated with a YOLOv11n-based object detection model, can achieve high diagnostic accuracy, rapid image acquisition, and reproducible detection of Plasmodium-infected red blood cells (RBCs). The system addressed multiple limitations in previous work, as outlined below.\u003c/p\u003e\n\u003cp\u003eMany earlier studies, such as Poostchi et al. (2018) [1], Madhu et al. (2023) [2], and Rahman et al. (2021) [5], demonstrated the feasibility of using deep learning for malaria diagnosis, reporting classification accuracies ranging from 90% to 96%. Similarly, Khan et al. (2022) [6] and Kudisthalert et al. (2020) [7] explored CNN architectures and counting algorithms for parasite quantification. However, these studies were often limited to small, curated datasets or lacked field validation.\u003c/p\u003e\n\u003cp\u003eIn contrast, our model was trained on a large and diverse set of 4,000 images acquired from real patient samples prepared under local clinical conditions, where variations in smear thickness, cell distribution, and staining quality are common. These conditions reflect the practical challenges encountered in field diagnostics. Despite this variability, the model was validated against expert-annotated ground truth and achieved strong performance metrics (e.g.,
[email protected] = 0.865, precision = 0.818, recall = 0.840), which fall within or exceed the range reported in most comparative studies\u0026mdash;demonstrating the robustness and real-world applicability of our approach.\u003c/p\u003e\n\u003cp\u003eRecent efforts such as those by Islam et al. (2022) [10], Tan \u0026amp; Liang (2023) [9], and Sengar et al. (2022) [11] explored transformer-based and attention-driven models to improve malaria parasite detection. While these models achieved high accuracy, they often require significant computational resources, limiting their deployability in field conditions.\u003c/p\u003e\n\u003cp\u003eOur choice of YOLOv11n offered a balance between detection accuracy and computational efficiency, allowing real-time inference on a Raspberry Pi embedded in the OFM\u0026mdash;a critical advantage for point-of-care settings.\u003c/p\u003e\n\u003cp\u003eMany studies (e.g., Ramos-Brice\u0026ntilde;o et al., 2025 [8]; Elayaraja et al., 2024 [4]) have focused solely on the image analysis aspect, often assuming access to pre-focused, high-quality images. Our work advances the field by integrating autofocusing, slide scanning, image capture, detection, and result generation into a single automated workflow.\u003c/p\u003e\n\u003cp\u003eThis positions our system closer to the embedded, sample-to-answer devices such as miLab\u0026trade; (Hamid et al., 2024 [13]) and MAIScope (Sangameswaran, 2022 [14]), but at a fraction of the cost, and built using open-source tools that promote scalability and local adaptation.\u003c/p\u003e\n\u003cp\u003eWhile Kudisthalert et al. [7] and Khan et al. [6] attempted parasite counting, most prior models were not assessed for reproducibility across repeated runs, nor compared against multiple human operators. Our results showed high consistency across three repeated OFM runs (low inter-run variability), and comparable or superior accuracy to human microscopists, who showed inter-operator variation in cell counts.\u003c/p\u003e\n\u003cp\u003eAdditionally, our system demonstrated promising performance in parasitemia estimation, achieving significantly higher accuracy and consistency compared to manual microscopy. While many previous studies on AI-assisted malaria diagnostics have focused primarily on binary classification of infected versus uninfected cells, parasitemia estimation\u0026mdash;a critical parameter for assessing disease severity and monitoring treatment response\u0026mdash;has often been underrepresented or overlooked. This gap is concerning, given the clinical importance of quantifying parasite load in guiding therapeutic decisions and identifying high-risk cases. In our study, manual microscopy yielded parasitemia estimates with low accuracy (average 38%) and high inter-observer variability, further compounded by the time-intensive nature of counting cells across multiple fields of view. In contrast, our automated OFM-based system produced accurate and reproducible parasitemia estimates in under 40 minutes, highlighting its potential as a reliable tool for real-time disease severity assessment in both clinical and field settings.\u003c/p\u003e\n\u003cp\u003eUnlike most existing models which operate as standalone tools, our vision includes IoT connectivity for remote diagnostics and real-time surveillance, aligning with recent edge AI trends such as those reported by Lin et al. (2024) [16] and Bae et al. (2024) [12]. This approach could enable large-scale epidemiological monitoring and integration into national health information systems.\u003c/p\u003e\n\u003cp\u003eIn line with the OpenFlexure framework (Collins et al., 2020 [17]; Rosen et al., 2024 [18]), our platform is modular and has shown preliminary success in histological image analysis for cancer diagnosis. This supports future applications beyond malaria, as explored by Bhattiprolu (2024) [19] through open-source image annotation tools, and reinforces the adaptability of our approach.\u003c/p\u003e\n\u003cp\u003eIn summary, our work contributes to the growing body of literature on AI-assisted malaria diagnosis by offering a fully integrated, low-cost, and field-deployable platform. It bridges the gap between lab-scale AI models and practical diagnostic tools by focusing on automation, reproducibility, and connectivity\u0026mdash;key elements for scalable, equitable healthcare delivery in low-resource settings.\u003c/p\u003e"},{"header":"4. Conclusion","content":"\u003cp\u003eThis study set out to develop and evaluate a fully automated malaria diagnostic system based on a customized OpenFlexure Microscope (OFM), with the specific objectives of enabling accurate parasitemia estimation, integrating a reliable autofocusing mechanism for high-magnification imaging, and deploying a deep learning model for real-time detection of infected and non-infected red blood cells (RBCs) as well as white blood cells (WBCs). To address the limitations of manual microscopy\u0026mdash;namely its time intensiveness, reliance on expert skill, and low reproducibility\u0026mdash;we implemented a custom Laplacian variance-based autofocusing algorithm and trained a YOLOv11n object detection model on locally acquired and annotated blood smear images. Our system achieved a parasitemia estimation accuracy of 80%, compared to 38% for experienced human microscopists, while reducing diagnostic time from over 1 hour and 40 minutes to under 40 minutes per slide. The system also demonstrated consistent image quality and focus across 100 fields of view. These findings highlight the potential of our OFM-based platform as a practical, low-cost solution for automated malaria diagnosis, particularly in resource-limited and point-of-care settings.\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\u003c/p\u003e"},{"header":"Declarations","content":"\u003cp\u003e\u003cspan\u003e\u003cstrong\u003eEthics Statement\u003c/strong\u003e: This study involving human participants was reviewed and approved by the Meru University of Science and Technology Institutional Research Ethics Committee (MIRERC). Written informed consent was obtained from all participants, and for minors under 18 years of age, assent was obtained in addition to parental or guardian consent. All procedures were conducted in accordance with the relevant guidelines and regulations.\u003c/span\u003e\u003c/p\u003e\u003cp\u003e\u003cstrong\u003eFunding\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eAcademy of Medical Sciences Networking Grant (NGR1\\1211), funded by the UK Department for Science, Innovation and Technology (DSIT) through the International Science Partnerships Fund (ISPF).\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eAcknowledgment\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eThe authors gratefully acknowledge the Academy of Medical Sciences for providing partial funding to support this research. We also extend our sincere appreciation to Professor Pietro Cicuta of University of Cambridge for his invaluable role in supporting capacity building, particularly in the acquisition of skills related to the fabrication and customization of the OpenFlexure Microscope.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eDisclosures\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eThe authors declare that there is no conflict of interest regarding the publication of this work.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eData availability\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eData and source code underlying the results presented in this paper are available in a public GitHub repository: https://github.com/EzekielOtieno/Malaria (Ref. [19]).\u003c/p\u003e"},{"header":"References","content":"\u003col\u003e\n \u003cli\u003eM. Poostchi, K. Silamut, R. J. Maude, et al., \u0026quot;Image analysis and machine learning for detecting malaria,\u0026quot; \u003cem\u003eTransl. Res.\u003c/em\u003e \u003cstrong\u003e194\u003c/strong\u003e, 36\u0026ndash;55 (2018).\u003c/li\u003e\n \u003cli\u003eG. Madhu, A. W. Mohamed, S. Kautish, et al., \u0026quot;Intelligent diagnostic model for malaria parasite detection and classification using imperative inception-based capsule neural networks,\u0026quot; \u003cem\u003eSci. Rep.\u003c/em\u003e \u003cstrong\u003e13\u003c/strong\u003e(1), 13377 (2023).\u003c/li\u003e\n \u003cli\u003eS. Kumar, T. Arif, A. S. Alotaibi, et al., \u0026quot;Advances towards automatic detection and classification of parasites microscopic images using deep convolutional neural network: methods, models and research directions,\u0026quot; \u003cem\u003eArch. Comput. Methods Eng.\u003c/em\u003e \u003cstrong\u003e30\u003c/strong\u003e(3), 2013\u0026ndash;2039 (2023).\u003c/li\u003e\n \u003cli\u003eS. Elayaraja, S. Yeruva, V. Stejskal, et al., \u0026quot;Multi-Class Microscopic Image Analysis of Protozoan Parasites Using Convolutional Neural Network,\u0026quot; \u003cem\u003eJ. Univ. Comput. Sci.\u003c/em\u003e \u003cstrong\u003e30\u003c/strong\u003e(4), 420 (2024).\u003c/li\u003e\n \u003cli\u003eA. Rahman, H. Zunair, T. R. Reme, et al., \u0026quot;A comparative analysis of deep learning architectures on high variation malaria parasite classification dataset,\u0026quot; \u003cem\u003eTissue Cell\u003c/em\u003e \u003cstrong\u003e69\u003c/strong\u003e, 101473 (2021).\u003c/li\u003e\n \u003cli\u003eS. H. Khan, N. S. Shah, R. Nuzhat, et al., \u0026quot;Malaria parasite classification framework using a novel channel squeezed and boosted CNN,\u0026quot; \u003cem\u003eMicroscopy\u003c/em\u003e \u003cstrong\u003e71\u003c/strong\u003e(5), 271\u0026ndash;282 (2022).\u003c/li\u003e\n \u003cli\u003eW. Kudisthalert, K. Pasupa, and S. Tongsima, \u0026quot;Counting and classification of malarial parasite from giemsa-stained thin film images,\u0026quot; \u003cem\u003eIEEE Access\u003c/em\u003e \u003cstrong\u003e8\u003c/strong\u003e, 78663\u0026ndash;78682 (2020).\u003c/li\u003e\n \u003cli\u003eD. A. Ramos-Brice\u0026ntilde;o, A. Flammia-D\u0026rsquo;Aleo, G. Fern\u0026aacute;ndez-L\u0026oacute;pez, et al., \u0026quot;Deep learning-based malaria parasite detection: convolutional neural networks model for accurate species identification of \u003cem\u003ePlasmodium falciparum\u003c/em\u003e and \u003cem\u003ePlasmodium vivax\u003c/em\u003e,\u0026quot; \u003cem\u003eSci. Rep.\u003c/em\u003e \u003cstrong\u003e15\u003c/strong\u003e(1), 3746 (2025).\u003c/li\u003e\n \u003cli\u003eD. Tan and X. Liang, \u0026quot;Multiclass malaria parasite recognition based on transformer models and a generative adversarial network,\u0026quot; \u003cem\u003eSci. Rep.\u003c/em\u003e \u003cstrong\u003e13\u003c/strong\u003e(1), 17136 (2023).\u003c/li\u003e\n \u003cli\u003eM. R. Islam, M. Nahiduzzaman, M. O. F. Goni, et al., \u0026quot;Explainable transformer-based deep learning model for the detection of malaria parasites from blood cell images,\u0026quot; \u003cem\u003eSensors\u003c/em\u003e \u003cstrong\u003e22\u003c/strong\u003e(12), 4358 (2022).\u003c/li\u003e\n \u003cli\u003eN. Sengar, R. Burget, and M. K. Dutta, \u0026quot;A vision transformer based approach for analysis of \u003cem\u003ePlasmodium vivax\u003c/em\u003e life cycle for malaria prediction using thin blood smear microscopic images,\u0026quot; \u003cem\u003eComput. Methods Programs Biomed.\u003c/em\u003e \u003cstrong\u003e224\u003c/strong\u003e, 106996 (2022).\u003c/li\u003e\n \u003cli\u003eC. Y. Bae, Y. M. Shin, M. Kim, et al., \u0026quot;Embedded-deep-learning-based sample-to-answer device for on-site malaria diagnosis,\u0026quot; \u003cem\u003eFront. Bioeng. Biotechnol.\u003c/em\u003e \u003cstrong\u003e12\u003c/strong\u003e, 1392269 (2024).\u003c/li\u003e\n \u003cli\u003eM. M. A. Hamid, A. O. Mohamed, F. O. Mohammed, et al., \u0026quot;Diagnostic accuracy of an automated microscope solution (miLab\u0026trade;) in detecting malaria parasites in symptomatic patients at point-of-care in Sudan: a case\u0026ndash;control study,\u0026quot; \u003cem\u003eMalar. J.\u003c/em\u003e \u003cstrong\u003e23\u003c/strong\u003e(1), 200 (2024).\u003c/li\u003e\n \u003cli\u003eR. Sangameswaran, \u0026quot;MAIScope: A low-cost portable microscope with built-in vision AI to automate microscopic diagnosis of diseases in remote rural settings,\u0026quot; \u003cem\u003earXiv\u003c/em\u003e preprint arXiv:2208.06114 (2022).\u003c/li\u003e\n \u003cli\u003eS. A. Ali, P. S. Abdulqadir, S. A. Abdullah, et al., \u0026quot;M2ANET: Mobile Malaria Attention Network for efficient classification of \u003cem\u003ePlasmodium\u003c/em\u003e parasites in blood cells,\u0026quot; \u003cem\u003earXiv\u003c/em\u003e preprint arXiv:2405.14242 (2024).\u003c/li\u003e\n \u003cli\u003eL. Lin, E. Dacal, N. D\u0026iacute;ez, et al., \u0026quot;Edge Artificial Intelligence (AI) for real-time automatic quantification of filariasis in mobile microscopy,\u0026quot; \u003cem\u003ePLoS Negl. Trop. Dis.\u003c/em\u003e \u003cstrong\u003e18\u003c/strong\u003e(4), e0012117 (2024).\u003c/li\u003e\n \u003cli\u003eJ. T. Collins, J. Knapper, J. Stirling, et al., \u0026quot;Robotic microscopy for everyone: the OpenFlexure microscope,\u0026quot; \u003cem\u003eBiomed. Opt. Express\u003c/em\u003e \u003cstrong\u003e11\u003c/strong\u003e(5), 2447\u0026ndash;2460 (2020).\u003c/li\u003e\n \u003cli\u003eD. G. Rosen, E. S. de Mello, S. Dhingra, et al., \u0026quot;Utility of a low-cost 3-D printed microscope for evaluating esophageal biopsies,\u0026quot; \u003cem\u003eAnn. 3D Print. Med.\u003c/em\u003e \u003cstrong\u003e13\u003c/strong\u003e, 100145 (2024).\u003c/li\u003e\n\u003c/ol\u003e"}],"fulltextSource":"","fullText":"","funders":[],"hasAdminPriorityOnWorkflow":false,"hasManuscriptDocX":true,"hasOptedInToPreprint":true,"hasPassedJournalQc":"","hasAnyPriority":true,"hideJournal":true,"highlight":"","institution":"Meru University of Science and Technology","isAcceptedByJournal":false,"isAuthorSuppliedPdf":false,"isDeskRejected":"","isHiddenFromSearch":false,"isInQc":false,"isInWorkflow":false,"isPdf":false,"isPdfUpToDate":true,"isWithdrawnOrRetracted":false,"journal":{"display":true,"email":"
[email protected]","identity":"researchsquare","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":true,"externalIdentity":"","sideBox":"","snPcode":"","submissionUrl":"/submission","title":"Research Square","twitterHandle":"researchsquare","acdcEnabled":true,"dfaEnabled":false,"editorialSystem":"","reportingPortfolio":"","inReviewEnabled":false,"inReviewRevisionsEnabled":true},"keywords":"Parasitemia, Plasmodium, Edge devices, Point of Care, YOLO, autofocusing, slide scanning","lastPublishedDoi":"10.21203/rs.3.rs-6809543/v1","lastPublishedDoiUrl":"https://doi.org/10.21203/rs.3.rs-6809543/v1","license":{"name":"CC BY 4.0","url":"https://creativecommons.org/licenses/by/4.0/"},"manuscriptAbstract":"\u003cp\u003eWe present a customized OpenFlexure Microscope (OFM) platform for automated malaria diagnosis and parasitemia estimation. The system integrates a Laplacian-based autofocusing algorithm optimized for 100\u0026times; oil immersion imaging and a YOLO-based deep learning model to detect Plasmodium-infected and non-infected red blood cells and white blood cells. A Python control script performs automated slide scanning and real-time analysis across 100 fields of view. The OFM achieved 80% accuracy in parasitemia estimation, compared to 38% for human microscopists, and reduced diagnostic time from over 100 minutes to under 40 minutes, demonstrating its potential for use in point-of-care settings.\u003c/p\u003e","manuscriptTitle":"Automated malaria diagnosis and parasitemia estimation using a customized OpenFlexure microscope","msid":"","msnumber":"","nonDraftVersions":[{"code":1,"date":"2025-06-09 08:39:38","doi":"10.21203/rs.3.rs-6809543/v1","editorialEvents":[{"type":"communityComments","content":0}],"status":"published","journal":{"display":true,"email":"
[email protected]","identity":"researchsquare","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":true,"externalIdentity":"","sideBox":"","snPcode":"","submissionUrl":"/submission","title":"Research Square","twitterHandle":"researchsquare","acdcEnabled":true,"dfaEnabled":false,"editorialSystem":"","reportingPortfolio":"","inReviewEnabled":false,"inReviewRevisionsEnabled":true}}],"origin":"","ownerIdentity":"a40e8a5c-ecd4-4958-b603-eb0d201ac46c","owner":[],"postedDate":"June 9th, 2025","published":true,"recentEditorialEvents":[],"rejectedJournal":[],"revision":"","amendment":"","status":"posted","subjectAreas":[{"id":49445324,"name":"Laboratory Diagnostics"}],"tags":[],"updatedAt":"2025-06-09T08:39:38+00:00","versionOfRecord":[],"versionCreatedAt":"2025-06-09 08:39:38","video":"","vorDoi":"","vorDoiUrl":"","workflowStages":[]},"version":"v1","identity":"rs-6809543","journalConfig":"researchsquare"},"__N_SSP":true},"page":"/article/[identity]/[[...version]]","query":{"redirect":"/article/rs-6809543","identity":"rs-6809543","version":["v1"]},"buildId":"8U1c8b4HqxoKbykW_rLl7","isFallback":false,"isExperimentalCompile":false,"dynamicIds":[84888],"gssp":true,"scriptLoader":[]}
Text is read by the "Ask this paper" AI Q&A widget below.
Extraction quality varies by source — PMC NXML preserves structure
cleanly, OA-HTML may include some navigation residue, and OA-PDF can
have broken hyphenation. The publisher copy
(via DOI)
is the canonical version.