A deep convolutional neural network for efficient microglia detection

Microglial cells are a type of glial cells that make up 10–15% of all brain cells, and they play a significant role in neurodegenerative disorders and cardiovascular diseases. Despite their vital role in these diseases, developing fully automated microglia counting methods from immunohistological images is challenging. Current image analysis methods are inefficient and lack accuracy in detecting microglia due to their morphological heterogeneity. This study presents development and validation of a fully automated and efficient microglia detection method using the YOLOv3 deep learning-based algorithm. We applied this method to analyse the number of microglia in different spinal cord and brain regions of rats exposed to opioid-induced hyperalgesia/tolerance. Our numerical tests showed that the proposed method outperforms existing computational and manual methods with high accuracy, achieving 94% precision, 91% recall, and 92% F1-score. Furthermore, our tool is freely available and adds value to exploring different disease models. Our findings demonstrate the effectiveness and efficiency of our new tool in automated microglia detection, providing a valuable asset for researchers in neuroscience.

no universally best tools, and many of these tools require manual changes, which strongly limits their efficient use within the biologist community [31][32][33] .
Several methods have been developed to detect microglia in past years using traditional image processing tools and DCNN [8][9][10][11]15,16,29,30 . Our researc aim was to develop a fully automated tool for microglia detection that would be more accurate, efficient, and faster than existing approaches.We present an innovative algorithm for the automatic detection of microglia based on YOLOv3 34 -a powerful DCNN platform that can be customised to deal with a range of object detection tasks (Supplementary Information).A significant advantage of this platform is that it can be tuned to deal with a range of object detection tasks.This platform enables a simple selection of the deep learning architecture size, which can be matched to the object detection task's complexity, allowing the network to be trained with a relatively small number of annotated images.Furthermore, this platform delivers competitive performance without requiring extensive training processes or optimisation of various hyperparameters.
In this project, we used sections from the control and opioid-induced hyperalgesia/tolerance (OIH/OIT) groups described by Jokinen et al. 35 .OIH/OIT refers to the dose escalation during long-term opioid therapy, which can lead to increased pain 36 .Research has shown that the long-term use of morphine can cause glia activation 37 .This activation can lead to the production and release of various neuro-excitatory substances 38,39 .Microglia tend to undergo extensive morphological changes during activation, significantly increasing variability in size and shape and showing complex arrangements of their processes and networks 36 .For our analysis, we chose specific brain and spinal cord regions believed to be involved in chronic pain management 35 .
To demonstrate the effectiveness of our microglia detection, we trained YOLOv3 using its general network architecture.To validate the performance of YOLOv3, we compared it with other commonly used approaches such as expert observer's detection, ImageJ, and semi-automated tools such as ilastik.In addition, we evaluated the detection accuracy in an experimental biological task by counting the number of cells in the forelimb motor cortex under the effect of morphine.We selected the forelimb motor cortex brain sections as we had previously reported changes in the number of microglia in this area 35 .Our results show that our algorithm performs exceptionally well compared to modern methods in terms of accuracy and computational efficiency.

Animals
The study protocol was approved by the experimental animal ethics committee of the provincial government of Southern Finland (Uudenmaan Lääninhallitus, Hämeenlinna, Finland, permission # ESAVI/7929/04.10.07/2014).All methods were performed in accordance with the relevant guidelines and regulations of the International Association for the Study of Pain 40 , and European Communities Council Directive, 24 November 1986.All experiments were performed in accordance with ARRIVE guidelines.Ten adult male Sprague-Dawley rats (from Scanbur, Sollentuna, Sweden) weighing 225 ± 25 g (mean ± SEM) were used at the beginning of experiment 35 .Rats were divided into an OIH/OIT group and a control group (saline), with five rats per each group 35 .The animal model, including precise biological experiments, is published by Jokinen et al. 35 .

Preparation of samples
The experimental dataset utilised different regions of the rat brain to examine the efficiency of the proposed approach.Tissue sections of 6 μm were prepared from selected regions of the brain and lumbar regions of the spinal cords as previously described 35 .The selected sections were labelled with antibody for Ionized calciumbinding adapter molecule 1 (Iba1) (1:1000, Catalogue No. 019-19741, Wako, Richmond, VA, USA), using antirabbit and anti-mouse biotinylated secondary antibodies and the VECTASTAIN ABC HRP Kit (Cat PK-6101, PK-4002 Vector Laboratories, Burlingame, CA, USA) 35 .Slides were scanned and imaged by the 3DHISTECH Scanner (3DHISTECH Ltd, Budapest, Hungary).

Annotation procedure
Annotations were made manually using a graphical image annotation tool LabelImg.22 images and 6500 cells were labelled for the training set.All images and data analysed during the study are included in Supplementary Information.The cells were inserted into the training set by an expert drawing a bounding box around them.The training data was annotated twice by the expert.In the second round of cell labelling, all images were rotated 180° to evaluate intra-person accuracy.

Convolutional neural network
Using general default architecture of YOLOv3, as a one-step object detection algorithm, YOLOv3 transforms the detection problem into a regression problem 34,41,42 .YOLOv3 uses darknet-53 as a backbone and binary crossentropy loss function.The Darknet53 network consists of a convolutional layer and a residual block.
The residual network employed by Darknet53 can be represented: where X is an input feature, (W 1 , X) is an input feature, a weight of W 1 is a weight, the size of the convolution kernel of W 1 is 1 × 1. β is batch normalisation, σ is nonlinear ReLU activation.X 2 is a backbone output feature of the residual structure, where the size of the convolution kernel of W 2 is 3 × 3, X 3 is a final output feature of the residual network.First, a traditional 3 × 3 convolution on the input features is performed, next step is stacks of

Evaluation methods and metrics
We evaluated the detection results by calculating precision, recall and F1-score.A correct detection (true positive, TP) happens when a ground truth object has a matched pair, and false positive (FP) detection happens when an extra object is present.In contrast, a false negative (FN) happens in the case of missing objects.Based on these definitions we calculated precision [defined as P = TP/(TP + FP)], recall [defined as R = TP/(TP + FN)], and F1-score [defined as F1 = TP/(TP + (FP + FN) × 0.5)].
The same example images of cells were mirrored and rotated, and blindly shown to the annotators to be labelled again to reduce bias to the lowest possible level.Altogether the annotators manually annotated ~ 10 different images containing ~ 650 cells using the LabelImg tool.
In ilastik, we used pixel and object classifications with Gaussian Smoothing colour/intensity feature, Gaussian Gradient Magnitude and Difference of Gaussian edge features.In ImageJ, we used global threshold maximum entropy since it performed best to other available global and local thresholds in ImageJ.All pixels outside the threshold were set to zero.Small objects were deleted as noise objects based on the object size threshold.
Correlation analysis was performed with the Pearson correlation test.The statistical test was performed in Matlab.

Results
Using precision, recall, and F1-score metrics, we evaluated the detection results from DCNN by comparing them with manual counting, ilastik, and ImageJ.Figure 1a presents examples of detected microglia by DCNN.
As shown in Fig. 1b, DCNN achieved precision, recall, and F-1 score values P = 0.94, R = 0.91, and F1 = 0.92, respectively.Whereas precision and recall values for ilastik were P = 0.74, R = 0.94, F1 = 0.83, and for ImageJ P = 0.62, R = 0.95, F1 = 0.75, for manual counting P = 0.88, R = 0.86, F1 = 0.87.As expected, our method generally performed very competitively.We hypothesise that possible reasons for any discrepancy in the accuracy are related to the atypical shape of microglia or/and variability in staining intensity.Statistics for all evaluated metrics are shown in the Supplementary Table .In practice, the runtime of a method is also an important factor.DCNN is approximately 170 times faster than manual counting, 60 times less than ilastik, and 30 times less than ImageJ.This indicates that the DCNN model is characterised by a highly beneficial cell detection time besides its good quality performance.Annotation of 6500 cells took ~ 4 h of continuous labelling, and for training, the model took ~ 45 h of training time, 300 epochs.The annotated cells were chosen to include the training data from various quality images, representative variations in staining, tissues preparations, and imaging (Supplementary Information).Taken together, DCNN has appears to have a very favourable runtime, in addition to good performance.
Additionally, we applied the proposed model for detecting cells in forelimb motor cortex brain sections of CTR and OIH/OIT groups.The microglia ratio between groups is 1.12 for manual counting and 1.13 for DCNN, indicating only ~ 2% measurement difference (Fig. 2a).The newly developed model is highly correlated with the manual counting method, with Spearman correlation of R = 0.95 (Fig. 2b).

Discussion and conclusions
Our approach introduces a novel, fully automated method for accurately detecting microglia, which can aid to better understand their pathophysiological processes.www.nature.com/scientificreports/Unlike traditional object detection models that use multiple stages, YOLOv3 uses a single neural network 43,44 .YOLOv3 can achieve high accuracy in object detection while remaining fast due to its functional pyramidal network and prediction engine.In addition, it offers excellent speed for detecting objects of different sizes, in a wide range of settings and scenarios, which is crucial in cell detection.General architecture YOLOv3 was chosen to perform microglia detection since it has been designed to be fast and efficient 34 , making it rather ideal for the task.6500 cells were manually labelled to train the model.To benchmark our detection approach, we compared it against ImageJ, machine learning-based tool ilastik, and manual detection.The model achieved F1 score of 92% and significantly outperformed other approaches.In addition, DCNN output showed high correlation compared to the manual microglia counting, which demonstrates its validity.Notably, the F1 score of the human expert was 4% units lower than YOLOv3 (88% vs 92%).We consider that the intra-observer accuracy indicates the complex nature of microglia.
We also want to remark that DAB-based staining of cells results in a significantly wider staining intensity between the samples than fluorescent dyes.Intensity inhomogeneity is a significant issue in the analysis of medical images and can greatly undermine the performance of image analysis processing and segmentation 45 .Several approaches are generally used to overcome this issue from magnetic resonance images 46,47 .In this work, the high performance of the proposed approach has been obtained without any intensity normalisation.Kyriazis et al. and Stetzik et al. also used DCNN model to detect microglia 29,30 .However, Kyriazis's method could correctly recognise only 70% of cells.The authors used only 300 cells for training the DCNN model.The authors expected to improve performance with higher volume of training data.Stetzik et al. implemented the user-friendly commercial software Aiforia™, where the main drawback is that the computational time for cell recognition is hundred times slower compared to ours.In addition, the Aiforia™ platform is also costly, limiting its scalability in an academic setting.
Our research has some limitations that require addressing in future studies.Firstly, all materials were obtained from rat opioid models, so the validity and applicability of the proposed method in other organisms and models should be confirmed.Additionally, the default deep convolutional neural network architecture was utilised in the project, and further optimisation of the hyperparameters and increasing the number of annotated examples should further improve the model's performance.YOLOv3, as a larger network, requires high-performance hardware for excellent performance and has a fixed input image size.Compared to region-based convolutional neural networks, the algorithm has a poorer ability to recognize object positions and a lower recall rate 48 .However, YOLOv3 performs better in detecting complex samples 49 .
In conclusion, our novel approach for microglia detection has demonstrated high performance in detecting microglial cells with significant variation in appearance, size, and shape.Our experiments have shown that our method outperforms several widely used approaches.The automated detection process provides a quick and reliable quantification of microglia, without the need for any user-defined parameters.Moving forward, we plan to further train our model to recognise fluorescently and DAB-stained cells and extract morphological features of microglia to gain insights into their precise mechanisms and regulatory functions.This tool has the potential to significantly advance our understanding of microglia and their role in various neurological conditions.

Figure 2 .
Figure 2. Microglia detection in OIH/OIT and CTR groups.(a) Detection results ratio OIH group to CTR group.(b) Spearman correlation between the DCNN model and manual counting.
+ X 2 www.nature.com/scientificreports/fiveresidual blocks.The residual network number of each residual block is 1, 2, 8, 8, and 4. Residual blocks are connected by the downsampling convolution.During training, all hyperparameters were set: learning rate is 0.001; momentum is 0.9; weight decay is 0.0005; batch size is 32.