Keywords

1 Introduction

In nature, some species of terrestrial plants establish symbiotic relationships with fungi, known as mycorrhiza, to gain nutrients and exchange carbon, the metabolic resource essential for fungi growth [1]. The mycorrhizae create underground connections between plants creating a network called Common Mycorrhizal Network (CMN). Since CMNs often extend through forests forming large networks with a structure that recalls the World Wide Web, CMNs have also been named the Wood Wide Web [2, 3].

Due to their role in carbon recycling, the symbiotic relationship between plants and fungi has increasingly attracted researchers’ interest [4, 5]. Controlled experiments conducted in a laboratory setting are critical for better understanding the role and functional mechanisms behind the plant-fungus symbiotic relationship. Laboratory experiments can guarantee controlling specific parameters to help identify and characterize their effects on the organisms’ growth. Prior to this is the analysis of the spores in the medium.

In order to automate the quantification of fungal spores, several computational approaches have been proposed, specifically involving digital image analysis. In 1993, Paul et al. proposed an image analysis method to automate the assessment of spore viability and germination characteristics in the mold fungus P. chrysogenum. In their work, images of spores were acquired with a monochrome microscope. The images were binarized through manual thresholding, and diverse morphological filtering operations were applied to remove undesired objects and to separate spore and germination parts [6]. Computational tools to count the spores in a petri dish sample through image analysis have been proposed in [7,8,9,10,11]. Melo et al. (2019) proposed a two-step approach. First, circular objects are detected with the Circular Hough Transform (CHT), a commonly used algorithm for detecting circular image features [7]. Then, an artificial neural network removes false positives based on their RGB colors [7]. Vidal et al. (2019) proposed a semi-automated approach with an interface allowing users to apply different operations. In particular, the user sets two thresholds to perform double thresholding. Then, diverse morphological filters can be applied, removing objects that are too big, too small, or too elongated [8]. Xu et al. (2009) proposed a series of filtering operations for segmenting and counting isolated pathogenic spores in an image [9]. Tahir et al. (2017) collected pathogenic airborne spores onto glass slides using an air sampling unit and then used a support vector machine model trained with hand-crafted features and histogram-oriented gradient features to detect the spores [11].

Additionally, several studies have proposed techniques for the automated identification of airborne pathogenic spores. Wang et al. proposed a machine learning-based approach for classifying captured spore species using diffraction features [12]. Tahir et al. (2018) utilized a dataset of 40,800 labeled images of five species of pathogenic fungi sampled with an air sampling unit on an adhesive, transparent tape, to train and cross-validate a deep learning-based classifier [13, 14]. Using model-based object recognition, Perner et al. (2004) classified airborne pathogenic spore species photographed on a microscopic slide [15]. Zhao et al. (2019) collected a dataset of 40,000 anthrax bacterial spores that were cultivated, filtered, and photographed on a glass slide. A deep learning-based classifier was trained and validated using these labeled images to segment the spores [16]. However, all the mentioned studies on automated spore quantification work on 2D images.

Despite their reduced dimensions ([30–140] µm of diameter) [17], spores are 3D objects that can lose important features if acquired in a single focal plane. In microscopy, this is done by acquiring the sample at multiple focal depths in a Z-stack, multiple planes over the depth axis, and combining them into an extended depth-of-field (EDF) image [18]. The various techniques for creating EDF images assess the value of a certain criterion, called focus measure (FM), to determine the plane in which the sample is more focused [18]. The most used techniques are Gradient-based FMs that emphasize prominence of the edges in the image [19], Laplacian-based FM that emphasize the quantity of edges in the image [19], and Wavelet-based FM that utilizes wavelet transforms to analyze and enhance all the frequency components of an image [15]. Both Gradient based and Laplacian based FMs may constitute good options to estimate the depth of spores, however, they may include edges that are not of our interest (hyphae, morphological artifacts). In this study, we aimed at defining an FM adapted to spores, by considering the prominence of the border of the spore, which becomes more defined when the spore is in focus.

In this work, we leverage spore information by employing Z-stacked microscope images. Specifically, we propose a method for automatic 1) detection and quantification of spores of Rhizophagus irregularis, a widely studied mycorrhizal fungus, in a live sample, 2) estimation of each spore’s relative centroidal Z-position, and 3) acquisition of in-focus image patches of all the spores in the sample. The paper is structured as follows. We present sample preparation, acquisition, and the image analysis process developed (Sect. 2). We show the results of the spore detection and count, compare the proposed Z-stack-leveraged method to the results obtained by applying the detection algorithm to a single Z-plane, and show a qualitative comparison between our FM and some well-known general-purpose FMs (Sect. 3). Finally, we discuss some aspects regarding the validity of our tool for observing and quantifying fungal spores, discuss some future perspectives for spore vitality assessment (Sect. 4), and conclude with final remarks (Sect. 5).

2 Methodology

2.1 Sample Preparation

Spores of Rhizophagus irregularis (MUCL 41833), formerly Glomus intraradices, were purchased from GINCO (http://www.mbla.ucl.ac.be/ginco-bel).

Spores were cultured in Petri dishes (12 × 12 cm2) containing minimal medium (M), with pH 5.5, and gelling agent (gellan gum 3000 mg/l). The M medium is a culture medium with minimal nutrient content explicitly developed for spores germination by Bécard and Fortin (1988) [20]. The medium was sterilized by autoclaving at 121 ℃ for 15 min and then poured into Petri dishes in an aseptic environment under the laminar-flow hood. After the medium was solidified, 100 manually counted spores were sucked up from a vial with deionized water and placed in each petri dish with a micro-pipette. The spores were cultured in axenic condition and maintained in the dark at 28 ℃ for five days before the image acquisition.

Since, after deposition, the water unevenly distributed and evaporated over the medium, the spores dispersed unevenly over the surface. Because of this, we could acquire more than one sample image from each petri dish, one for each spot.

To manually count the spores, we placed the sample under a vertical microscope (Nikon Eclipse Ni, Nikon Instruments Inc.) and used the Annotations and Measurements tool available with the NIS-Elements D software (Nikon Instruments Inc.) to visualize and mark elements in the sample. Each sample was counted three times with consistent results. The Root Mean Square (RMS) error was estimated to compare automated vs. manual count.

2.2 Image Acquisition

Images were acquired with a Nikon AZ100M microscope equipped with an Andor Zyla sCMOS camera (VSC-10642), AZ Plan Fluor 5 × objective, and a white backlight. The microscope has a motorized stage to move the sample over a large area (up to 25 cm × 25 cm) and Z-stack motion. The microscope can be controlled through the NIS-Elements software (Nikon Instruments Inc.), which allows the acquisition of a single frame, a large image through stitching, and Z-stack automatized acquisitions.

As the samples are intrinsically 3D, we ran the Z-stack acquisition with a plane interval of 2 µm to capture the third-dimension information. The starting plane was set closest to the camera, and the end plane farthest from the camera. In one case, where an area larger than 25µm2 (max field of view of the optic) was imaged, the interval was increased to 5 µm.

2.3 Image Processing

The image analysis program was coded in MATLAB 2022 [21]. As input, it takes a set of Z-stacked grayscale images of R. Irregularis spores and mycelium. The process follows the steps in Algorithm 1.

The spores were typically circular and within a known size range (between 30 and 140 µm), so the CHT proposed in [22] was utilized for spore detection. This technique also allows estimating the radius of each identified object, and it is robust against overlapping objects. We used the implementation provided with the function imfindcircles in MATLAB [23].

The scale bar assigned by the microscope software was segmented through global thresholding and used to convert pixels to millimeters. This information was used to set the circle size limits. The scale bar was removed from the image by setting the scale bar pixels to correspond to the mean grayscale intensity to not interfere with the circle detection. To speed up computation, the images were resized using the function imresize so that the lower radius limit in millimeters corresponded to six pixels, which is the lowest limit for the circle detection algorithm to remain stable [23].

figure a

As each sample was acquired in Z-stack, the same spore was often detected at different Z-planes. Because of camera distortions, each spore associates with more than one coordinate (one for each plane) (Fig. 1). For this reason, we applied the clustering algorithm Density Based Spatial Clustering of Applications with Noise (DBSCAN) [24] to group centers belonging to the same spore. We utilized the implementation in the function dbscan in [25]. The DBSCAN algorithm takes two parameters: the minimum number of points in a cluster and a maximum distance threshold (ε) to search neighboring elements. We set the minimum number of elements to five and ε to the number of pixels corresponding to 3.5 µm as the maximum Euclidean distance between centers to fall into the same cluster.

Fig. 1.
figure 1

The same spores are detected in several Z-planes. All the centers detected are shown with a blue dot. The small misalignment is the effect of camera distortion.

Because multiple spores can be present in the same image, and that they can distribute at any depth, it was necessary to estimate the plane where the spore was more focused and extract its Z-position. To this purpose, we propose an FM adapted to fungal spores, merging gradient-based and Laplacian features. To assess the FM of each spore, we looped over each candidate in a cluster. The candidate element has associated a center, a radius, and a Z-plane. For each candidate, a squared region of interest (ROI) was extracted around the center with a side length corresponding to the spore diameter plus a margin of five pixels. An ad-hoc FM was calculated for each ROI. Figure 2 shows visualizations of a single spore in three different set planes.

Fig. 2.
figure 2

Images of the same spore: (A) before entering focus, (B) in focus, (C) after moving past focus. (D-F) Edges identified by Canny operator. (G-I) Patch image gradient magnitudes.

Specifically, Fig. 2A–C shows the considered spore in three different planes, where the most defined edge is the one that separates the spore from the background. We applied the Canny edge detector [26] with the edge function [23] (Fig. 2D–F). Besides computing the image gradients, the Canny edge detector applies local-maximum suppression, double thresholding, and hysteresis to obtain the edge in the image [26]. The median gradient magnitude (Fig. 2G–I) of the detected edge pixels represents the sharpness of the edge around the spore and is adopted in this study as FM. In Fig. 2G-I we see that, when the spore is in focus (Fig. 2H), the gradient magnitudes have higher values than the gradient magnitudes shown in Fig. 2G and in Fig  2I in the thin circle corresponding to the spore’s edge. The Canny operator may identify some lines deriving from the spore’s internal structure (Fig. 2D–E). However, since the median is considered, this does not represent an issue as long as these pixels are in minority.

Thus, we identified the in-focus plane and, consequently, the depth of each spore by selecting the plane associated with the maximum FM. Finally, a new image comprising all in-focus spores is obtained by stitching the in-focus ROI. Figure 3 illustrates an example of depth estimation within an all-in-focus image (Fig. 3A) and compares a zoom-in of the same sample with a single plane acquisition, where only a few spores are in focus (Fig. 3B), and a montage of all spores in focus (Fig. 3C). This resultant image offers a 2D view with an optimal definition of each spore border and texture, features essential for evaluating the state and vitality of the spores, which can be done manually or automatically.

Fig. 3.
figure 3

(A) Detected spores with encircling color depending on estimated relative depth. (B) Single Z-plane with one spore (in blue) in focus and other spores (in red) out of focus. (C) Montage with all spores in focus.

3 Results

3.1 Spore Detection

We collected 16 samples with different numbers of spores, totaling 1338 spores according to our manual count, and 1277 spores with our tool. The mean diameter of the spores evaluated with the automatic analysis was 66.1µm (σ = 16.2 µm), with a median of 65µm (see Fig. 4A).

To assess the validity of our tool, we compared a manual count with the automatic count gained from our analysis (Fig. 4B). The tool can detect and count the spores with a maximum relative error of 7.15%, and the RMS value of the relative error was 3.25%.

Fig. 4.
figure 4

Summary of results achieved with the automatic tool. (A) Spores diameter distribution. (B) Spores count yielded with the automatic analysis compared with a manual count.

Among the samples, two were particularly dense, with a spore density of over 30 spores per mm2, where many spores were partially overlapped (Fig. 5A-B). These samples are particularly challenging to analyze either manually or with the automatic tool. From a manual count, they contained 349 and 551 spores. The automatic count yielded 332 (4.9% error) and 513 (6.9% error).

For the five samples with the highest spore count in our set, we compared the manual count, the automatic spore count derived from the all-in-focus image, and the result obtained from analyzing a single plane in the middle of the Z-stack. Figure 5C reports the results and highlights that, for samples with a high quantity of spores, using Z-stacked images improves the detection substantially with respect to a single plane analysis, reducing the distance with a manual count. Indeed, for the Z-stack method, the relative error for the five largest samples was between 2.5%–6.9%, with a median of 4.5%, while for the single plane method, it was between 6.8%–33.4%, with a median of 13.4%. The two errors result significantly different from a 1-factor ANOVA test (p-value = 0.043 with significance level 0.05).

Fig. 5.
figure 5

Difference between the single plane image and full Z-stacked image. (A) Spore cloud #4. (B) Spore could #5. (C) Comparison of manual count, automatic count including all Z-planes, and Automatic Count with a single Z-plane.

3.2 Focus Plane Selection

Figure 6 shows the optimal focus planes attributed to some example spores. We observe that CONT and GDER tend to select more in-depth planes than the others; they appear less focused in the first row than the other FMs, and the WAVS performs worse in the third row than the others.

Fig. 6.
figure 6

Optimal focus of diverse spores, according to (from left to right): our FM, LAPM, WAVS, CONT, GDER, and LAPV. The resulting optimal Z-plane obtained from each FM is reported in the upper left corner of each image patch.

Generally, our FM tends to identify a plane closer (or the same, last raw Fig. 6) to the ones obtained with LAPM, WAVS, and LAPV methods, then to GDER, CONT. This suggests that our FM selects the plane where the border sharpness is maximized while at the same time neglecting artifacts like the partially overlapping spore in the first row of Fig. 6.

4 Discussions

4.1 Spore Detection

Our results demonstrate that the automatic detection produces an RMS error of 3.25% that increases with spores number (Fig. 4B), in our case, up to a maximum relative error of 7.15%. The main factor increasing the error is that large spore samples tend to become denser, with more overlapping spores. The Z-stack solution overcomes the problem of overlapping spores to some extent. However, if samples are extremely dense, having a single observation point imposes a limitation. A linear regression applied to the relative error estimated a coefficient of 0.00012, implying that the relative error can be expected to grow by 1.2 percentage points per 100 spores. However, for samples with ≫ 500 spores, the error likely would grow much faster due to the lack of visibility. Spores stacked on each other led to detect spore coordinates belonging to different spores close to each other, causing the clustering algorithm to merge them falsely. Further reducing the distance threshold (ε) could generate more clusters than actually present. Consequently, ε is a sensible parameter. Table 1 shows the outcomes of a sensitivity analysis (SA) performed with different values of ε. The SA demonstrates that the spore count varies in very dense samples. A future perspective of this work may consist of embedding robustness against such faulty mergers or divisions of clusters.

Table 1: Sensitivity of the clustering distance threshold in high spore density samples. The spore count is provided for different ε values. The accuracy significantly reduces with the crowdedness of the sample.

Spores surrounded by other spores represent another factor affecting the discrepancy between manual and automatic spore count. They may have insufficient edge contrast. Hence, a more sensitive detection algorithm may improve the detection performance. A detector with higher sensitivity and specificity may be obtained through machine learning techniques, such as a convolutional neural network, as in [14, 16]. However, such models require large training data sets (e.g., over 40,000 annotated examples were utilized in both studies).

4.2 Focus Measures

Objectively determining when an object in an image is in focus is a difficult task. Pertuz et al. (2013) aimed to estimate an object’s depth and compare this measurement to a ground truth of known distances [19]. The method proposed by Pertuz et al. (2013) does not apply to our analysis because the spores’ positions are unknown a priori. The evaluations of the FMs were conducted on five example spores, one with very weak texture, one partially overlapped, one with hyphae growing behind it, one with broken cell wall, and one more typical. Thus, even though the evaluated set of spores was small, a diverse range of cases is considered. While other FM techniques used in [19] generally analyze the entire region of interest to estimate the depth for all the objects, our approach considers only a small subset of the pixels in the examined patch. For this reason, we could assume that most detected edge pixels correspond to the edge of interest; thus, it is not a general-purpose focus measure. However, it may be suitable for some applications where the object is detected before evaluating the FM value. In Fig. 6, we can observe that the resulting optimal spore images all seem to be close to each other. Indeed, the largest observed difference in identified Z-plane for a given spore is only 15 planes, corresponding to 30 µm, which is less than the radius of an average spore.

4.3 Vitality Assessment

This study offers a first step toward automatizing several labor tasks. Among these, assessing spores’ vitality is a critical analysis to be performed prior to experimentation. Figure 7 shows spores displaying different features because of their different vital state. From left to right, we can see one vital spore (A), perfectly round, with a clear contrast with the background, an intact and sharp wall, and a peculiar internal texture induced by the presence of lipids. One spore with a broken cell wall (B), with fragmented edges and irregular color. Another spore is empty (C), characterized by transparency induced by the loss of lipids. And the last spore (D) was subjected to excessive thermal stress due to being autoclaved. Its shape is less circular than the vital one, and the internal texture seems equalized.

Fig. 7.
figure 7

(A) Healthy spore. (B) Spore with a broken cell wall. (C) Empty spore. (D) Spore exposed to excessive thermal stress.

In Vidal et al. (2019), the geometry of spores is assessed by first segmenting them through manual hysteresis thresholding and then computing the diverse geometric properties of each connected component in the image [8]. The spore detection algorithm presented in this paper detects and estimates the radius for all the spores shown in Fig. 7. However, the non-circular aspects are not accounted for yet, and it needs further elaboration for determining spore vitality.

5 Conclusions

This paper presents a methodology for automatically detecting, quantifying and obtaining an in-focus image of fungal spores, which considers Z-stack acquisitions of the biological sample. By incorporating depth information into the analysis, the proposed approach intends to improve the performance of spore detection and enhance the accuracy of the results.

We developed a fully automated program to count spores in the sample through the detection and clustering of the spores over multiple planes. It also estimates the Z-plane where the spore is more in focus with a custom FM, which is preliminary investigated to preserve relevant features of the spore, e.g., border and texture, useful for further sample analysis.

Here, we assessed the validity of our process by comparing automatic spores count with a manual count performed by an operator. We demonstrated that our method detects the spores with a relatively small error (RMS of 3.25%) and that the Z-stacked image acquisition can yield a significantly (p-value = 0.043) more accurate result than a classic 2D image analysis (median relative error of about a) 13.4% for manual vs. single plane and b) 4.5% for manual vs. Z-stack). Additionally, we propose a specialized focus measure to determine the Z-position of spores and qualitatively compare its performance with other general-purpose focus measures primarily used in the literature. Whereas the proposed FM is able to localize a plane where relevant features (borders and texture) are preserved, further improvements and analyses are required to better assess the performance.

Possible future works include developing a more sensitive segmentation technique for crowded samples to automate additional operations that are labor-intensive for an operator, including assessing the spore vitality.