Automatic section thickness determination using an absolute gradient focus function

Authors


Lawrence O. Hall, Computer Science and Engineering, 4202 E. Fowler Ave., ENB 118, University of South Florida, Tampa, FL 3620-5399, U.S.A. Tel.: 813-974-4195; fax: 813-974-5456; e-mail: hall@cse.usf.edu.

Summary

Quantitative analysis of microstructures using computerized stereology systems is an essential tool in many disciplines of bioscience research. Section thickness determination in current nonautomated approaches requires manual location of upper and lower surfaces of tissue sections. In contrast to conventional autofocus functions that locate the optimally focused optical plane using the global maximum on a focus curve, this study identified by two sharp ‘knees’ on the focus curve as the transition from unfocused to focused optical planes. Analysis of 14 grey-scale focus functions showed, the thresholded absolute gradient function, was best for finding detectable bends that closely correspond to the bounding optical planes at the upper and lower tissue surfaces. Modifications to this function generated four novel functions that outperformed the original. The ‘modified absolute gradient count’ function outperformed all others with an average error of 0.56 μm on a test set of images similar to the training set; and, an average error of 0.39 μm on a test set comprised of images captured from a different case, that is, different staining methods on a different brain region from a different subject rat. We describe a novel algorithm that allows for automatic section thickness determination based on just out-of-focus planes, a prerequisite for fully automatic computerized stereology.

Introduction

Current computerized stereology systems require trained users to carry out several manual steps in order to generate design-based estimates of first- and second-order stereological parameters of biological interest. Existing autofocus functions for brightfield microscopy locate the optimal focal plane, that is, the plane at which biological microstructures appear at maximal focus as determined by a trained observer (Santos et al., 1997; Sun et al., 2004; Hilsenstein, 2005; Liu et al., 2006; Shen et al., 2008). For the purpose of automatic stereological analysis using computerized systems, one prerequisite is location of the optical planes that correspond to the out-of-focus planes above and below the stained tissue sections. A second requirement is that any approach for automatic section thickness determination must be robust across a range of conditions, including healthy versus diseased tissue; tissue from different species; and, tissues stained with a variety of techniques (Mouton, 2002; Mouton & Gordon, 2010, Mouton, 2011a, b). A critical obstacle to the full automation of feature recognition algorithms to enable automatic recognition of biological structures of interest (Mouton et al., 2005) is the requirement to locate the boundaries between in-focus and out-of-focus optical planes at the upper and lower surfaces of stained tissue sections. Using current, nonautomated approaches, section thickness determination is carried out by manual adjustments using the microscope's fine focusing mechanism to locate ‘just-out-of-focus’ optical planes above and below the cut surfaces of the tissue. Computerization of this process with an autofocus algorithm represents a significant advance toward fully automated applications of design-based stereology to biological tissue.

The goals of this research were 3-fold. The first goal was to develop a function to automatically locate the top and bottom surface of a routine section of stained tissue, and then repeat this process at multiple XY locations within an anatomically defined reference space. Locating the top and bottom surface enables correct automatic placement of geometric probes for stereology, for example disector, as well as automatic determination of the section thickness. Using a brightfield microscope at high magnification (100× objective), the upper and lower surfaces of the tissue section were defined as the ‘just out of focus’ optical planes, that is, above and below the first in-focus optical planes. The desired level of accuracy for an automated function was to be within 1.0 μm of the top and bottom ‘just out of focus’ optical planes, on average, compared to the manually measured surface location (ground truth). With a typical step size of 1.0 μm between optical planes in the Z-axis, this level of accuracy translates to ±1 optical plane from the ground-truth plane. No attempt was made to interpolate between Z-stack images to locate a more refined boundary.

The second goal was to develop a method for training the automated surface location algorithm across a range of threshold parameters to optimize the performance of each focus function. The locations of 36 tissue surfaces within 18 Z-stacks were manually identified for use as the training set for these studies. Incorporating a focus function into an autofocus algorithm requires thresholding the focus function output, that is, focus measure, also known as the focus threshold. In addition, the focus functions were divided into two categories: (1) functions with a pixel-to-pixel contrast threshold (thresholded functions); and, (2) functions with no contrast threshold (nonthresholded functions). For thresholded functions, the Nelder Mead simplex optimization method (Press, 1988) for two dimensional parameter spaces was used to find the optimal pixel-to-pixel contrast threshold, which was paired with the total image focus threshold to yield the focus function with the lowest average error rate. For nonthresholded functions, the golden ratio optimization method (Press, 1988) was used to locate the best focus threshold.

Finally, because the morphological and histological characteristics of biological microstructures vary within and between tissue sections (Mouton & Gordon, 2010; Mouton, 2011a), focus function threshold parameters typically require retraining for different data sets. The ideal focus function would have thresholds that perform well across data sets, without retraining; for different hardware; across the range of biological variation in microstructures; and for different staining methods used to process tissue sections for computerized stereological analysis. Thus, the third goal of this research was to evaluate the robustness of the threshold selection for different data sets collected across a range of actual conditions.

A significantly less complete version of this work was published in Elozory et al. (2011). Here, seven more existing focus functions are evaluated and we introduce two new functions. There are seven functions (vs. 1) fully evaluated for automated surface location. In this paper, an extra test set was acquired from the hypocampus region and which is completely different than the training set. This allows for the much more extensive evaluation done here.

Materials and methods

Data collection equipment

These studies were carried out using the Stereologer system (Stereology Resource Center, Inc., Chester, MD, USA) that consists of a Zeiss Axioskop 20 brightfield microscope with a range of low (Zeiss Plan Neofluar 2.5×) to high (Zeiss Plan-Apochromat 100× oil immersion, numerical aperture 1.4) magnification objectives equipped with digital imaging and interfaced to a motorized X-Y-Z stage (ASI, Eugene, OR, USA) for both manual and automated modes via the system software. The digital camera (Microfire, Optronics, Goleta, CA, USA) was capable of capturing 800 × 600 pixel images in 8-bit by three channel (RGB) colour mode. The charged-coupled device (CCD) for the camera was a single 2/3” 1600 × 1200 pixels array with 7.4 μm × 7.4 μm pixel size using a Bayer mosaic filter array to capture colour information. This common Bayer filter placed a mosaic filter over the CCD such that each 2 × 2 pixel square had an RGB (25 Red, 50 Green, 25 Blue) colour filter. The Stereologer software was compatible with both iMac G4 platform (32-bit 1.25GHz, OS10.6) and Dell Optiplex GX280 (32 bit 3.20 GHz Intel Pentium4) running Microsoft Windows 7 Enterprise version.

Depth of field (DOF) was calculated to be 0.43 μm using Eq. (1), where: λ is the wavelength of illuminating light (0.55 μm for average visible light); η is the refractive index (1.516 for immersion oil); NA is the objective numerical aperture; M is the lateral magnification; and, e is the lateral resolution power (constrained to a minimum of 0.24 μm by Abbe diffraction limit).

image(1)

The second term becomes insignificant at high magnification and high numerical aperture (100× oil immersion, NA 1.4). Finally, the proper choice of objective is used to achieve the practical light microscope minimum DOF. A shallow DOF results in a shallow depth of focus that is desirable as reducing depth of focus is equivalent to enhancing axial resolution (Yuste & Konnerth, 2005), for example, DOF of less than 1.0 μm is required to achieve 1.0 μm precision.

Data sets

Tissue for these studies provided by the Stereology Resource Center (SRC, Chester, MD, USA) included sections stained with two common approaches to reveal microstructures of biological interest: tyrosine hydroxylase (TH) immunocytochemistry to reveal dopaminergic neurons in the rat substantia nigra; and, Nissl histochemistry (cresyl violet) to stain pyramidal neurons in the CA region of the hippocampus. The sections are cryostat and not plastic embedded. The cut section thickness, that is, block advance, for the tissue was 40 microns, while the final section thickness after all tissue processing was about 20 microns. This tissue shrinkage of about 50% is expected for tissue staining protocols that include a dehydrating alcohol series. A Z-stack was defined as a series of images captured at incremental (0.1 μm) steps in the Z plane. Three separate data sets (Table 1) consisting of Z-stacks of images were acquired at high magnification (100×, 1.4 n.a.) with the XY plane and Z-axis perpendicular and parallel, respectively, to the camera axis. The Stereologer captured Z-stacks using the following procedure:

Table 1.  Characteristics of data sets used for evaluation.
Data setDescriptionNumber of Z-stacksNumber of images
Training SetCryostat 010610 Substantia Nigra Rat C1 Sec: 05,07,08,0918455
Test Set #1Cryostat 010610 Substantia Nigra Rat C1 Sec: 05,07,08,0916373
Test Set #2Nissl 041696 Hippocampus Rat1018490
  • 1Anatomically defined reference spaces (the substantia nigra and the hippocampus) were outlined by manual user clicks at low magnification (2.5× objective).
  • 2After switching to high magnification, the Stereologer automatically selects a series of XY locations within the reference space in a systematic-random manner.
  • 3The user locates the top and bottom optical planes at each XY location by clicking the location of interfaces between unfocused and focused images at the top and bottom of the tissue section.
  • 4The user sets step increment and buffer in Z-axis to ensure acquisition of unfocused images above and below tissue.
  • 5The Stereologer system automatically acquires Z-stack at that XY location.
  • 6With user assistance, the Stereologer system collects multiple Z stacks by repeating steps 3, 4 and 5 at different systematic-random locations through the XY plane of the reference space.

The acquired Z-stacks were divided into three data sets —a training set and two test sets. The training set and test set #1 included Z-stacks from sections through a single brain region (substantia nigra) and stained with TH immunocytochemistry from the brain of a single rat. A second test set (test set #2) included Z-stacks acquired from sections though the brain of a different rat, from a different brain region (hippocampus), and stained with a different procedure (Nissl histochemistry).

Focus functions

Common thresholded focus functions

A total of 18 focus functions were analysed, including 14 published functions from the literature of microscopy autofocusing. The remaining four functions resulted from modifications to the thresholded absolute gradient function which had the lowest error in locating the ‘just out of focus’ optical plane as described in the proceeding. The first six functions, as well as all four modified functions, required selection of a threshold. Threshold selection adds a level of complexity, yet enables ‘fine tuning’ of the function. Equation (2), used in the thresholding equations that follow, returns a given value when the given value exceeds the specified threshold.

image(2)

Six previously developed thresholded focus functions, as shown in Eq. (3) through (8), were tested

image(3)

(Groen et al., 1985; Vollath, 1987; Krotkov, 1988; Santos et al., 1997, Sun et al., 2004, Sun et al., 2005, Liu et al., 2006; Hamm et al., 2010; Elozory et al., 2011).

image(4)

(Groen et al., 1985; Vollath, 1987; Santos et al., 1997; Pech-Pacheco et al., 2000; Sun et al., 2004; Sun et al., 2005; Liu et al., 2006; Elozory et al., 2011).

image(5)

(Brenner et al., 1976; Firestone et al., 1991; Santos et al., 1997; Sun et al., 2004; Sun et al., 2005; Liu et al., 2006; Hamm et al., 2010; Osibote et al., 2010; Elozory et al., 2011).

image(6)

(Groen et al., 1985; Firestone et al., 1991; Santos et al., 1997; Pech-Pacheco et al., 2000; Sun et al., 2004; Sun et al., 2005; Liu et al., 2006).

image(7)

(Groen et al., 1985; Santos et al., 1997; Pech-Pacheco et al., 2000; Sun et al., 2004; Sun et al., 2005; Liu et al., 2006).

image(8)

(Groen et al., 1985; Firestone et al., 1991; Santos et al., 1997; Pech-Pacheco et al., 2000; Sun et al., 2004; Sun et al., 2005; Liu et al., 2006).

Common nonthresholded focus functions

A total of eight conventional, nonthresholded focus functions were evaluated, as shown in Eqs (9) through (16). These less complex nonthresholded focus functions do not require a preselected threshold.

image(9)

(Tenenbaum, 1970; Krotkov, 1988; Santos et al., 1997; Sun et al., 2004; Bueno-Ibarra et al., 2005; Hilsenstein, 2005; Sun et al., 2005; Liu et al., 2006; Huang & Jing, 2007; Hamm et al., 2010; Osibote et al., 2010).

image(10)

(Groen et al., 1985; Krotkov, 1988; Sun et al., 2004; Sun et al., 2005; Liu et al., 2006; Huang & Jing, 2007; Osibote et al., 2010).

image(11)

(Groen et al., 1985; Krotkov, 1988; Santos et al., 1997; Sun et al., 2004; Sun et al., 2005; Liu et al., 2006; Huang & Jing, 2007; Elozory et al., 2011)

image(12)

(Groen et al., 1985; Firestone et al., 1991; Santos et al., 1997; Sun et al., 2004; Sun et al., 2005; Liu et al., 2006; Hamm et al., 2010; Osibote et al., 2010; Elozory et al., 2011).

image(13)

(Vollath, 1987; Santos et al., 1997; Sun et al., 2004; Hilsenstein, 2005; Liu et al., 2006; Sun et al., 2005; Hamm et al., 2010; Osibote et al., 2010; Elozory et al., 2011).

image(14)

(Santos et al., 1997; Sun et al., 2004; Sun et al., 2005; Liu et al., 2006; Hamm et al., 2010; Elozory et al., 2011).

image(15)

(Firestone et al., 1991; Santos et al., 1997; Sun et al., 2004; Sun et al., 2005; Liu et al., 2006).

image(16)

(Firestone et al., 1991; Krotkov, 1988; Santos et al., 1997; Sun et al., 2004; Sun et al., 2005; Liu et al., 2006).

New focus functions

The initial testing of the above 14 functions [Eqs (3) through (16)] identified Eq. (3), the thresholded absolute gradient, as superior to all others in determining tissue surface location in terms of overall rank based on minimum error. Four modifications were made in an effort to achieve greater performance from this function. Intermediate functions below [Eqs (17) through (19)] simplify the descriptions of Eqs (20) through (23). Equation (17) is an indicator function that signifies whether the current pixel location (i,j) is high contrast, and returns 1 if this is true or 0 otherwise. High contrast for this function occurs when the absolute value of the difference between the current pixel and either its neighbouring pixel to the right or directly below is greater than or equal to the designated threshold value. Equation (18) describes the binary 3 × 3 median filter used in functions represented by Eqs (22) and (23). Equation (18) determines the number of the eight immediate neighbouring pixel locations with high contrast, while Eq. (19) returns the thresholded absolute gradient contrast strength in both the horizontal and vertical direction for a given pixel location (i, j).

image(17)
image(18)
image(19)

Equations (20) through (23) represent the four new focus functions introduced by the present work (Elozory, 2011). The modified absolute gradient (MAG) function [Eq. (20)] is a rotationally invariant form of the absolute gradient function [Eq. (3)]. The modified absolute gradient count (MAGC), Eq. (21), is rotationally invariant with a simple count of high contrast pixels, as determined by Eq. (17). Equations (22) and (23) reduced spurious noise through applications of a 3 × 3 median filter to the MAG function [Eq. (20)] and the MAGC function [Eq. (21)].

image(20)
image(21)
image(22)
image(23)

Using a Z-stack of images as input, each of the above functions generated a focus curve. Acquisition of Z-stacks of images started at the optical plane above the top surface of the tissue and proceeded to a focal plane below the bottom surface. A low incremental step-size (1 μm) through the Z-axis ensured identification of the boundary between unfocused and focused regions within an acceptable error rate. For locating the depth of focus of a tissue surface, the just out of focus image was defined as the boundary between unfocused and focused regions, with no interpolation between images.

The primary goal of the present study, to locate the just out of focus planes, is an important distinction compared to traditional approaches, for example, the work of Osibote et al. (2010), which was designed to locate the optical plane of peak focus. These earlier approaches are based on the idea that focus functions behave like Gaussian curves near their peaks (Nayar & Nakagawa, 1994), and based on the knowledge that the logarithm of a Gaussian is quadratic, enable fitting of a parabolic curve between adjacent images to determine optimal peak focus along the focus curve. In contrast, the just out of focus area of the focus curve targeted by the present study does not approach a Gaussian or any other well-defined function; therefore, no interpolation or curve fitting was carried out.

To locate the just out of focus images, the ideal focus curve should differentiate three regions in each Z-stack:

  • 1The unfocused images above the tissue sample.
  • 2The in-focus images within the tissue sample.
  • 3The unfocused images below the tissue sample.

The two unfocused regions on either side of the in focus region were assumed to behave in a similar manner, that is, these regions of the focus curve response would be zero with no points of focus in the image. In practice, these regions would be at, or close to, a minimum and relatively flat compared to the in-focus region, with no assumption that these regions would be monotonic. The only requirement for an in-focus region is that the bounding images would have a higher focus measure than every image from the unfocused regions. Note, even the bounding planes of the in focus regions cannot be expected to have the same measure of focus since the number and size of object surfaces cut by the optical plane are expected to vary. Finally, there was no assumption of unimodality in the region and no requirement for all these images to yield higher focus measures than the unfocused images.

Automated surface location algorithm

We developed an algorithm to locate the top and bottom tissue surfaces of a Z-stack of images using a specified focus function. Within the in focus regions, there is no expectation of symmetry. There are two main reasons: (1) slices contain different structures and so vary from slice to slice, and (2) slices closer to the bottom are imaged through more and more semi-transparent slices above and, hence, have different pixel intensities. The algorithm uses a training set of Z-stacks with manually determined tissue surfaces to optimize the focus function threshold parameters. Pseudo-code is shown in Appendix A. Automating the thresholded functions require optimization of a two-dimensional parameter space. The Nelder Mead simplex optimization method (Press, 1988) was selected on the basis of computational simplicity—no need to calculate function derivatives—and ability to adjust the traversal rate by expanding or contracting the step size as needed. Automation of the nonthresholded functions requires optimization in a single dimensional parameter space. The golden ratio optimization method (Press, 1988) was used on the basis of simplicity and efficiency. Once the algorithm was trained and the optimized thresholds determined, Z-stacks were analysed to find the top and bottom focal planes for automatic section thickness determination. The automated surface-locating algorithm started at the top of the Z-stack and moved down the Z-stack one image at a time. Focus of the first image was assessed over the trained focus threshold, and repeated for each consecutive image with each previous image designated as the just-out-of-focus optical plane, that is, the top surface boundary. Second, the algorithm started from the bottom of the Z-stack and moved up the Z-stack, one image at a time, until the first image with focus measure over the trained focus threshold was located, with the previous image designated as the bottom tissue surface boundary. Except for the first image on either side of the in-focus region, no images within the in-focus region were analysed.

Results

Figures 1–5 show the focus curves for each of the 14 common functions analysed using a typical Z stack in the training set. Figure 6 indicates the focus curves for the four modified functions for the same Z-stack. All functions were optimized over the training set to minimize deviation from the top and bottom surfaces located in a manual manner (i.e., ground truth). The two vertical bars in every figure represent ground truth and separate each focus curve into three regions: the middle region between the ground truth bars, that is, the in-focus region; and the two out-of-focus regions on either side of the in focus region that include the ground truth bars. When possible to select correct focus thresholds, the range of acceptable thresholds is shaded horizontally across the figure to separate the focus curve at the ground truth bars (see Figs 1, 3b and 6).

Figure 1.

Thresholded gradient focus curves from a typical Z stack in the Cryostat Training Set (Rat C1 Sec09 XY02). The two red vertical bars depict the manually determined surface depth. The green region depicts the range of threshold values that correctly identify the surface depth by partitioning the Z-stack into a focused region bounded by an unfocused region on either side.

Figure 2.

Zoomed in thresholded intuitive focus curves. Little variation can be seen using full scale so these functions were plotted with the vertical scale magnified to better show curve characteristics.

Figure 3.

Nonthresholded gradient focus curves. As in Fig. 1, the green region depicts the range of threshold values that correctly identify the surface depth by partitioning the Z stack into a focused region bounded by an unfocused region on either side.

Figure 4.

Nonthresholded statistical focus curves.

Figure 5.

Histogram based functions.

Figure 6.

Modified absolute gradient focus curves. These functions were modified in an attempt to better locate the surface depth. As in Figure 1, the green region depicts the range of threshold values that correctly identify the surface depth by partitioning the Z-stack into a focused region bounded by an unfocused region on either side.

Of the 18 focus functions analysed, the thresholded gradient-based functions (Figs 1 and 6) were the only functions to achieve the performance requirements as defined in the first goal of this study. These seven focus functions were each independently incorporated into the automated surface location algorithm, and each trained to find the top and bottom tissue surfaces within an average tolerance of 1.0 μm using the arbitrarily selected training set (Table 2). With trained threshold parameters, all seven functions identified the top and bottom tissue surfaces within 1.0 μm on a test set of similar Z-stacks, Test set #1 (Table 3); and, on a Test set #2 that represents a set of Z-stacks from a different rat brain case study (Table 4).

Table 2.  Automated focus determination training set optimization.
Eq.FunctionContrast thresholdFocus thresholdAverage error from G.T.Standard deviation from G.T.
(μm)Rank(μm)Rank
(3)Absolute Gradient167000.7210.806
(4)Squared Gradient119197 8780.8971.567
(5)Brenner Gradient486130 4440.7540.795
(20)Modified Absolute Gradient182390.7210.693
(21)Modified Absolute Gradient Count18180.7540.681
(22)Filtered Modified Absolute Gradient171180.7210.774
(23)Filtered Modified Absolute Gradient Count16100.7540.681
(6)Content96159 1394.22162.7617
(8)Pixel Count4213 4292.56112.6514
(7)Image Power80695 994 6404.33172.6915
(9)Tenenbaum GradientN/A517 555 0081.50102.138
(10)Energy LaplaceN/A393 364 4551.1782.2310
(11)VarianceN/A9482.86122.6313
(12)Normal VarianceN/A89 5052.97132.5112
(13)AutocorrelationN/A6 027 9491.4492.159
(14)Standard Deviation Based AutocorrelationN/A758 447 3044.50182.6916
(15)RangeN/A1803.31152.9518
(16)EntropyN/A6.84843.00142.4411
Table 3.  Automated focus determination, test set #1.
Eq.FunctionContrast thresholdFocus thresholdAverage error from G.T.Standard deviation from G.T.
(μm)Rank(μm)Rank
(3)Absolute Gradient167000.6340.422
(4)Squared Gradient119197 2390.6960.537
(5)Brenner Gradient486130 3410.7880.486
(20)Modified Absolute Gradient182300.6650.411
(21)Modified Absolute Gradient Count18180.5610.433
(22)Filtered Modified Absolute Gradient171180.5930.433
(23)Filtered Modified Absolute Gradient Count16200.5610.433
Table 4.  Automated focus determination test set #2.
Eq.FunctionContrast ThresholdFocus ThresholdAverage Error from G.T.Standard Deviation from G.T.
(μm)Rank(μm)Rank
(3)Absolute Gradient167000.4220.716
(4)Squared Gradient119197,2391.0070.716
(5)Brenner Gradient486130,3410.5360.685
(20)Modified Absolute Gradient182300.4740.651
(21)Modified Absolute Gradient Count18180.3910.651
(22)Filtered Modified Absolute Gradient171180.4740.651
(23)Filtered Modified Absolute Gradient Count16200.4430.674

Ranking the algorithms by both average error rate as well as standard deviation from the ground truth showed that the MAGC function outperformed the others by finding tissue section surfaces within 0.56 μm on average for test set #1, and within 0.39 μm on average for test set #2. Surpassing the tolerance goal of ±1.0 μm for each surface, tissue thickness was also determined within ±1.0 μm on average. Because two surface locations for each Z-stack are required to determine each section thickness measure, the two test sets were combined to determine tissue thickness. On the resulting set of 34 tissues samples, six of the seven thresholded gradient functions yielded an error rate of less than 1.0 μm (Table 5). Once again, the MAGC function had the lowest error rate (0.76 μm).

Table 5.  Automated tissue thickness determination for test sets #1 and #2 combined.
Eq.FunctionContrast ThresholdFocus ThresholdAverage Error from G.T.Standard Deviation from G.T.
(μm)Rank(μm)Rank
(3)Absolute Gradient167000.8531.136
(4)Squared Gradient119197 2391.4171.136
(5)Brenner Gradient486130 3410.9451.045
(20)Modified Absolute Gradient182300.9450.982
(21)Modified Absolute Gradient Count18180.7611.004
(22)Filtered Modified Absolute Gradient171180.8840.961
(23)Filtered Modified Absolute Gradient Count16200.8220.993

Supervised sets of Z-stack images stored as portable grey scale maps (pgm files) on hard disk were used to develop a training method to optimize the automated surface location algorithm. The automation of the thresholded gradient functions required selection of two thresholds: The pixel-to-pixel contrast threshold to determine whether to include the contrast between two pixels in the function summation; and, the total image focus threshold to decide whether an image is in focus or not. Since the Nelder Mead optimization outcome is dependent on the initial selection of simplex coordinates (Press, 1988), the method was run three times for each focus function, with a different initialization each time. The automated surface location algorithm used each of the hundreds of threshold pairs selected by Nelder Mead with each focus function to locate 36 tissue surfaces within 18 Z-stacks consisting of a total of 480 images. This analysis led to seven focus functions that located correct tissue surfaces within the desired error rate tolerance after application of the optimized thresholds.

Test set #2, a set of rat brain coronal sections taken from a different study than the rat brain coronal sections from the training set, was used to analyse the robustness of the optimized thresholds. Importantly, both the histochemical stain (cresyl violet) and reference space (hippocampus) for sections in test set #2 differed markedly in appearance from that of the training set obtained from TH-immunostained sections through the substantia nigra in test set #1. Nonetheless, using threshold parameters optimized on the training set, the same seven focus function that performed well on test set #1 performed to the same level on test set #2 (see Table 4), with the MAGC function outperforming others with an average error rate of 0.76 μm.

To test the statistical significance of these findings, the success rate of all seventeen focus functions were compared to the MAG. Success was defined as automatic identification of a tissue surface within 1 μm of the tissue surface location determined by the user in a manual manner. The seven thresholded gradient functions attained this goal, while the remaining functions did not. When one looks at which of the seven functions is more likely to find the right boundary with the paired t-test one finds the MAGC stands out. The paired t-test (Tamhane & Dunlop, 2000) confirmed that the MAGC function was statistically different than all the other gradient functions, except the MAG, with regard to accurate determinations of tissue surfaces locations with a confidence interval of 95% compared to the mean difference from ground truth (Elozory, 2011). Now, if you look at both top and bottom or slice thickness, the MAGC function found the correct tissue thickness relative to ground truth in a more consistent manner than all other functions, with a confidence interval of 99% or more (see Table 6).

Table 6.  Paired t-test measuring statistical significance.
Paired t-test with likelihood [confidence interval (CI,%)] that modified absolute gradient count (Eq. 21) is statistically different than other thresholded gradient functions with regard to accurate location of tissue surfaces
Eq.AlgorithmTrainingTest Set 1Test Set 2Thickness Test Set
t (35 df)CIt 31 dfCIt (35 df)CIt (33 df)CI
  1. df, degrees of freedom.

(3)Absolute Gradient2.02972.10982.38993.02100
(4)Squared Gradient3.021004.001007.321008.07100
(5)Brenner Gradient2.71994.611003.421004.31100
(20)Modified Absolute Gradient1.43921.44922.09982.6699
(22)Filtered Modified Absolute Gradient1.00841.79961.78962.6699
(23)Filtered Modified Absolute Gradient Count1.78961.79962.38993.19100

The distribution of the deviation of the automated location of tissue surfaces from the ground truth is shown in Tables 7–10. The deviation is the positive difference between the automated surface location algorithms determination of surface location and the ground truth. This difference is measured in whole micrometres. Since the step size through the Z-stacks was 1 μm, this difference is the number of images from the correct just out of focus image returned by the algorithm. On Test set #1 and Test set #2 the MAGC function was never more than two images away, that is, within 2 μm, from the ground truth. 94% of the tissue surfaces determined by the MAGC function were within a single image from the ground truth. For thickness determination, this was not the case, since measuring thickness requires measurement of both the upper and lower surfaces, and therefore requires a higher tolerance level. Nonetheless, tissue thickness was determined within 1 μm by the MAGC function 78% of the time, and never greater than 3 μm from than ground truth.

Table 7.  Distribution of deviation on training set.
Distribution of deviation of automated surface location from manual surface location Training set of 18 Z-stacks (36 Surfaces Located)
Eq.Function0 μm1 μm2 μm>2 μm
Count%Count%Count%Count%
(3)Absolute Gradient1747133651413
(4)Squared Gradient174714393826
(5)Brenner Gradient1644143951413
(20)Modified Absolute Gradient1542164451400
(21)Modified Absolute Gradient Count1439174751400
(22)Filtered Modified Absolute Gradient1644154241113
(23)Filtered Modified Absolute Gradient Count1439174751400
Table 8.  Distribution of deviation on test set #1.
Distribution of deviation of automated surface location from manual surface location Test Set #1: 16 Z-stacks (32 Surfaces Located)
Eq.Function0 μm1 μm2 μm>2 μm
Count%Count%Count%Count%
(3)Absolute Gradient154714443900
(4)Squared Gradient1547123851600
(5)Brenner Gradient1238154751600
(20)Modified Absolute Gradient144415473900
(21)Modified Absolute Gradient Count175312383900
(22)Filtered Modified Absolute Gradient165013413900
(23)Filtered Modified Absolute Gradient Count175312383900
Table 9.  Distribution of deviation on test set #2.
Distribution of deviation of automated surface location from manual surface location Test Set #2: 18 Z-stacks (36 Surfaces Located)
Eq.Function0 μm1 μm2 μm>2 μm
Count%Count%Count%Count%
(3)Absolute Gradient236412330013
(4)Squared Gradient925195371913
(5)Brenner Gradient195316440013
(20)Modified Absolute Gradient215813362600
(21)Modified Absolute Gradient Count236412331300
(22)Filtered Modified Absolute Gradient215813362600
(23)Filtered Modified Absolute Gradient Count226112332600
Table 10.  Distribution of deviation on combined test sets.
Distribution of deviation of automated tissue thickness determination from manual thickness determination Combined test sets #1 and #2: 34 Z-stacks
Eq.Function0 μm1 μm2 μm>2 μm
Count%Count%Count%Count%
(3)Absolute Gradient1647113241239
(4)Squared Gradient5151750721515
(5)Brenner Gradient123516473939
(20)Modified Absolute Gradient1338123572126
(21)Modified Absolute Gradient Count1647123541226
(22)Filtered Modified Absolute Gradient1338144151526
(23)Filtered Modified Absolute Gradient Count1441144141226

Discussion and conclusions

The novel finding in this study is the introduction of the MAGC function that allows automatic location of tissue surfaces, which enables automatic placement of geometric probes as well as accurate measurement of section thickness. We note that all methods to determine the just-out-of-focus optical planes using the MAG function with a precision equal to ±1.0 micron (one optical plane) require the use of a high resolution oil objective-immersion oil combination with depth of focus less than 1 micron. The MAGC function located tissues surfaces within 1 μm of ground truth on average and determined tissue thickness within 1 μm of ground truth on average. To optimize the function parameters, a training algorithm was developed using a set of tissue surfaces identified by a trained user. With optimized parameters, the automated surface location algorithm using the MAGC function meets the criteria for automatic section thickness determination, as required for computerized stereology applications across a range of different studies using different tissues and a variety of staining techniques. The processes automated by the MAGC function are currently performed manually, even in state-of-the-art computerized stereology systems. Automation of these processes using the MAGC function has the potential to dramatically increase throughput of studies to quantify morphometric parameters using unbiased stereological approaches.

Absolute gradient, squared gradient and Brenner gradient were the only three of the 14 common functions tested at the start of this study to achieve the goal of locating tissue surfaces with an average tolerance of 1.0 μm relative to ground truth. Furthermore, only two of these conventional functions—absolute gradient and Brenner gradient—measured tissue thickness with an average tolerance of 1.0 μm. Of these two functions, the absolute gradient function achieved the superior performance, as evidenced by the function rankings in Tables 2–5.

Three modifications to the absolute gradient threshold function led to further enhancements in the performance of the absolute gradient function. Addition of pixel-to-pixel comparison in the vertical and horizontal directions improved performance through rotational invariance. For weighting improvement, the squared gradient gave higher weight to relatively high contrast pixels than absolute gradient; nevertheless, absolute gradient performed better than squared gradient. To test whether the performance of absolute gradient could be further improved by eliminated weighting of higher contrast pixels, a simple count function enumerated pixels over the absolute contrast threshold. Under the reasoning that isolated high contrast pixels were most likely 'salt and pepper' noise, rather than actual points of focus, a median filter was applied to the intermediary binarized image of the MAG function.

Modifications to the absolute gradient function generated four new functions (see Fig. 6), all of which achieved the average tolerance goal of ±1.0 μm for surface location with similar test and training sets. These four functions met the robustness goal by achieving the same tolerance goal for a dissimilar test set; all four modified functions determined tissue thickness within ±1.0 μm average. Thus, the MAGC function achieved higher performance, as assessed by lowest error rate and greatest robustness across different training sets.

The computational complexity to determine focus of an image using the modified functions is O (n2), where n is the number of rows or columns of the image. For rotational invariance, the vertical comparison is done in parallel with the horizontal comparison with no increase in complexity. The median filter, however, requires a second pass through the image raster, with the second pass pipelined one row and column behind the first pass, with only a slight constant time increase. With current processing speeds of standard computers, a Z-stack is captured and analysed in real time, with the step motor speed of the automated stage as the time limiting factor.

With regard to practical application, the 'Absolute Gradient Focus Function' is designed to locate the 'just-out-of-focus' focal plane at the upper and lower surfaces of the tissue section with an error that is directly proportional to the resolving power of the objective and the contrast (signal:noise ratio) of stained microstructures in the tissue. While fluorescent immunostaining highlights cells with specific antigens, the approach fails to stain general proteins as required for identification of top and bottom surfaces of cut sections. For this reason the 'Absolute Gradient Focus Function' requires a light general counterstain, for example, cresyl violet, for automatic measurement of the top and bottom of the sections. Higher resolution objectives, for example, 100× oil, NA 1.4, provide thinner focal planes and enhanced contrast as compared to lower resolution objectives. For all objectives the advantage of the automatic computerized function over the manual approach is higher measurement precision (higher repeatability) by the same and different investigators, that is, higher intra- and inter-rater reliability.

Acknowledgments

This study is supported by a Small Business Innovative Research (SBIR) from the National Institutes of Health (U.S. Public Health Service), with Dr. Mouton as the Principal Investigator, to develop an automatic approach for the PI's computerized stereology system (Stereologer), which is commercialized and supported by the Stereology Resource Center, Inc. (Peter R. Mouton, Ph.D., Owner and President). Authors Dmitry Goldgof, Lawrence Hall, Peter R. Mouton, Kurt Kramer are named on a patent application filed by the University of South Florida that covers the work described in this study.

Appendix

APPENDIX A

Algorithm pseudo-code:

  • 1Capture images automatically using Stereologer.
  • 2Start with training Z stacks which have manually determined tissue surfaces.
  • 3Optimize focus parameters using Nelder mead for thresholded functions and Golden Ratio for non thresholded focus functions.
  • 4Determine top and bottom focal planes.
  • 4.1 Start from top of the stack and move down. Focus of the first image was assessed against the trained focus threshold, and this was repeated for each consecutive image with each previous image designated as the just-out-of-focus image until the threshold is exceeded.
  • 4.2 The algorithm starts from the bottom of the Z-stack and moves up the Z-stack, one image at a time, until the first image with a focus measure over the trained focus threshold was located.

Ancillary