 Research
 Open Access
 Open Peer Review
 Published:
An automated pipeline for bouton, spine, and synapse detection of in vivo twophoton images
BioData Mining volume 10, Article number: 40 (2017)
Abstract
Background
In the nervous system, the neurons communicate through synapses. The size, morphology, and connectivity of these synapses are significant in determining the functional properties of the neural network. Therefore, they have always been a major focus of neuroscience research. Twophoton laser scanning microscopy allows the visualization of synaptic structures in vivo, leading to many important findings. However, the identification and quantification of structural imaging data currently rely heavily on manual annotation, a method that is both timeconsuming and prone to bias.
Results
We present an automated approach for the identification of synaptic structures in twophoton images. Axon boutons and dendritic spines are structurally distinct. They can be detected automatically using this image processing method. Then, synapses can be identified by integrating information from adjacent axon boutons and dendritic spines. In this study, we first detected the axonal boutons and dendritic spines respectively, and then identified synapses based on these results. Experimental results were validated manually, and the effectiveness of our proposed method was demonstrated.
Conclusions
This approach will helpful for neuroscientists to automatically analyze and quantify the formation, elimination and destabilization of the axonal boutons, dendritic spines and synapses.
Introduction
Synapses were first discovered in the 1890s, when Sir Sherrington, through his pioneering work on motor reflexes, wrote that synapse is the way of neuronal communication in the nervous system [1]. There are two major types of synapses: chemical and electrical. In the mammalian central nervous system, the vast majority of the synapses are chemical. Chemical synapses, especially excitatory synapses, typically consist of presynaptic axon boutons and postsynaptic dendritic spines. The structural plasticity of boutons and spines underlies functional synaptic plasticity, widely accepted as the neural basis of learning and memory. Brain imaging can be used to characterize changes occurring in a brain during very different timescales [2]. The advent of boutons and spines can be imaged in live animals over days or even months, allowing observation of structural changes in vivo, often in direct association with learning [3–11].
Manual validation is extremely timeconsuming, and error prone. Meanwhile, different criteria may lead to different results. Therefore, manual methods are not suitable for the processing of largescale data. The recent advances in biomedical imaging have allowed the initial development of computeraided semiautomatic or automatic approaches to detect dendritic spines based on image analysis. In [12], Xie et al. proposed an algorithm for automatic neuron reconstruction. The algorithm can handle complex structures adaptively and optimize the localization of bifurcations. In [13], an automated scheme to perform segmentation in a variational framework was proposed to trace neurons from confocal microscopy images. The segmentation framework, referred to as “tubularity flow field (TuFF)”, performs directional regional growing guided by the direction of tubularity of the neurites. In [14], a robust automatic neuron segmentation and morphology generation algorithm was proposed. The algorithmTree2Tree uses a local medial tree generation strategy in combination with a global tree linking to build a maximum likelihood global tree. It is a reliable technique to compare various of neurons for tracing evaluation and neuron retrieval. Gonzalez et al. presented an approach to fully automated delineation of tree structures in noisy 2D images and 3D image stacks. It is able to eliminate noise while retaining the right tree structure [15]. Besides, in [16], Gonzalez et al. showed that using steerable filters to create rotationally invariant features that include higherorder derivatives, and training a classifier based on these features allows us handle such irregular structures. Rodriguez et al. developed an opensource software NeuronStudio to aid the neuroscientist in the task of reconstruction of neuronal structures from confocal and multiphoton images [17]. It is a selfcontained software package that is free, easy to use. The focus of previous work mentioned above varies, with some focusing on neuronal tracking, segmentation and others on specific situations.
They inspired us to explore 3D tracking, segmentation and extraction of synapses both in 2D and 3D based on the detection results of our automatic detection method. Therefore, it is of interest to explore methods of automatic detection and quantification of synapses, dendrites and axons.
In addition to examining boutons and spines separately by twophoton microscopy, it is also possible to visualize synaptic connections with identified boutons and spines that are in close proximity. Although the resolution of light microscopy is larger than the size of the synaptic cleft, previous studies have showed that over 85% of putative synapses identified in deconvoluted confocal images were true synapses confirmed using electron microscopy [18]. Light microscopy can still provide useful information. Given that boutons and spines originated from different brain regions or of different cell types can be labeled using different fluorescent proteins, observation of synaptic connections using twophoton microscopy provides a valuable method for researching longrange and celltype specific synaptic plasticity in vivo [19]. Therefore the automated detection of synapses will be of tremendous help for this kind of data analysis.
In this paper, we focus on the detection of axonal boutons, dendritic spines and synapses from the in vivo twophoton image stacks. As described above, a synapse typically consists of one axonal bouton and one dendrite spine, with the exception of multibouton and multispine synapses. A reasonable strategy to locate the synapses is to first detect axonal boutons and dendritic spines, then to search for synaptic contacts composed of bouton and spine pairs. A robust Gaussian model was used in order to enhance the morphology of axonal boutons and dendrites respectively, while effectively inhibiting noise. Before the enhancement operation, we performed deconvolution on axon images as a preprocessing method for noise reduction. And the regions with relatively higher values are regarded as axonal boutons with great possibility. For the detection of dendritic spines, we performed onethreshold segmentation to obtain the structure of the dendrites based on the enhanced images of dendrites, which followed by an efficient thinning algorithm. After we extracted the centerline of the dendrites, the dendritic spines were determined by finding the bifurcation points and endpoints.
Material and method
Figure 1 illustrates the workflow of our proposed approach for detection of synapses. We will give a detailed description of each procedure of the method after the introduction to the image stack in this paper.
Materials
The image data used in this study was obtained from Institute of Neuroscience, State key Laboratory of Neuroscience, Chinese Academy of Sciences, Center for Excellence in Brain Science and Intelligence Technology. The transgenic mice (YFPH line), both male and female, were imaged using a twophoton microscope (Sutter), controlled by Scanimage (Janelia). Auditory cortex of mice was exposed surgically and covered with glass cranial window for repeated twophoton imaging in vivo. Surgical details refer to Y. Yang [19]. Image stack was acquired from the cortical surface to 100–150 μm depth with 0.7 μm intervals. A 25 × objective with 1.05 numerical aperture was used (Olympus). A Ti:sapphire laser (SpectraPhysics) was used as the light source, and tuned to 92 nm for imaging. YFP (Yellow Fluorescent Protein) and GFP (Green Fluorescent Protein) signals were collected using filters 495/40 and 535/50 (Chrome). The 535/50 filter (Channel 1) collected both GFP and YFP signals, and the 495/40 filter (Channel 2) collected GFPonly signals. By subtracting the GFP signals from Channel 1 signals, the YFPonly images were obtained [19].
The dualcolor images, as shown in Fig. 2, are the twophoton images, where the red section and green section represent YFP (containing dendrites and axons) and GFP images (contains longrange projecting axons only) respectively and the spinebouton pairs are thought to be synapse. The xy resolution and the z resolution of the image data are 137 nm/pixel and 700 nm/pixel respectively, and the image size (xy) is 512by512.
Detection of axonal boutons
In this section, we provide algorithmic details for axonal bouton detection. The proposed algorithm is divided into three parts. First, a 3D deconvolution operation is required due to the noise in the original image stacks. Next, we enhanced the bright swellings in the deconvolved images and segmented them. Finally, we identified true axonal boutons based on a series of criteria. The whole workflow for detecting axonal boutons is shown in Fig. 3.
3D deconvolution
Although confocal microscopy images are known to be sharper than standard epifluorescence ones, they are still inevitably degraded by Poisson noise and residual outoffocus light due to photonlimited detection [20]. Thus, several deconvolution methods have been proposed. In this study, we adopt the Deconvolution Approach for the Mapping of Acoustic Sources (DAMAS), which decouples the array design and processing influence from the noise being measured using a simple and robust algorithm [21]. The details of 3D deconvolution operation implemented in ImageJ [22] are shown in Appendix.
One deconvolved axon image is depicted in Fig. 3 b. To demonstrate the performance of the 3D deconvolution operation, we show an axonal bouton indicated by the red rectangle in Fig. 3 b. We then show two different states of this image in Fig. 3 c, with the deconvolved one on the top and the original one on the bottom. A significant difference can be seen from the detailed comparison, showing that the 3D deconvolution operation helps to identify the axonal boutons.
Enhancing bright swellings
The thresholding on a deconvolved image does not necessarily ensure perfect segmentations, or even good ones. This is because the range of the intensity of different axonal boutons can vary dramatically. A low threshold will reserve the bright axon shaft, but a high threshold will eliminate weak axonal boutons. To avoid the loss of data, we first enhanced the bright swellings.
By the statistics carried on the corresponding electron microscope data, the average diameter of terminal boutons is 1.0 μm. By setting the pixel size to 137 nm, we find the average radius of an axonal bouton is about 4 pixels. We randomly select an axonal bouton as shown in Fig. 4 a and show the plot of its corresponding intensity image in Fig. 4 b. Note that the axonal bouton is a “rounded” profile. We can see that the image in Fig. 4 b looks very similar to the threedimensional Gaussian surface plotted in Fig. 4 c, suggesting it is reasonable to model the intensity of axonal bouton using a threedimensional Gaussian surface,
where C is a constant corresponding to the coordinate of the maximum magnitude point (x _{0},y _{0}), and δ is the variance of the Gaussian surface. A very small part of the axonal boutons can be approximated by a ridge, we then construct a Hessianbased ridge detector. Let m=(x−x _{0})^{2}+(y−y _{0})^{2}. The intensity of enhanced image is set as additive inverse of the eigenvalue with minimum absolute, i.e. [Appendix A],
Here we analyze in three cases:

: m=0,λ(m)=1/δ ^{3};

: \(m = 2{\delta ^{2}},\lambda (m) =  \sqrt 3 /({\delta ^{3}} \times e),\) where e is the Euler’s number;

: m→∞,λ(m)=0.
For the parabolic line profile, the magnitude of the second derivative of the extracted position is always maximum at the line position [23]. We can conclude that the relationship between the variance δ and the radius r of the axonal bouton is \(\delta =r/\sqrt 3\) [Appendix B]. Combined with the radius of axonal boutons, we set the variance as \(\delta =r/\sqrt 3\) in this study.
To allow visual interpretation, we plot the chosen eigenvalue of model (1) in Fig. 5, from which we can see that the central region is enhanced while the surrounding region weakens gradually. This provides the theoretical basis for image enhancement and segmentation. Inspired by [23–25], we select the above variance. Figure 3 depicts the enhanced image of one bright swelling, whose variation tendency consistently conforms to that of Fig. 3 almost everywhere, supporting the correctness of our theoretical analysis. Compared to the image in Fig. 3 b, the enhanced image shown in Fig. 3 d has an advantage for weaker axonal boutons because of its more obvious profile. The following work is based on the enhanced image in Fig. 6, and the detail is stated in Algorithm 2.
Obtaining axonal boutons
As discussed in last section, the application of a relatively lower threshold will inevitably generate false positives. Fortunately, the shapes of the axonal boutons are homogeneous and each has a sole maximum point. Therefore, we first find local maximum points as candidate points for axonal boutons, a simple but effective strategy. The detail is stated in Algorithm 1.
We then evaluate whether each region in the resulting segmentation contains a local maximum points and we delete the regions lacking local maximum points. On this basis, we compute some statistical characteristics including the eccentricity, major axis, and minor axis. Then we reserve the regions that exhibit statistical characteristics similar to a disk. Finally, we record the location of the reserved regions and determine whether the peak intensity of each region is more than three times brighter than its axon shaft in the original image [19]. The final result of axonal boutons analysis is shown in Fig. 3 e.
Detection of dendritic spines
In this section, we explicate the details of our method for the detection of dendritic spines. Dendritic spines are small with spine head volumes ranging from 0.01 μ m ^{3} to 0.8 μ m ^{3}. According to the shape, dendritic spines can be classified into following types: thin, mushroom, and stubby, as shown in Fig. 7 [26]. The variable shape of these spines is related to the strength and maturity of the synapses [27]. Thus, based on the forms, it is reasonable to locate the dendritic spines by looking for the spur pixels that are connected to the bifurcation points.
The proposed algorithm consists of three parts: enhancement of the line structure in the images after pretreatment; segmentation of dendrites and extraction of their skeletons; and identification of the dendritic spines based on the dendritic skeletons. The workflow is shown in Fig. 8 and Algorithm 4.
Enhancing line structure
Before performing other operations, we first normalize the images to reduce the impact of noise by using the following formula:
where I(x,y) is the intensity value in I at (x,y), I _{ max } and I _{ min } represent the maximum intensity and minimum intensity value of the image respectively.
Next, we enhance the linear structure. As shown in Fig. 9, the intensity value of each section of the dendritic linear structure can be modeled as a Gaussian curve [23], which can be written as
where x ^{′} is the abscissa on Cartesian coordinate system X ^{′} Y ^{′}; x,y are the abscissa and ordinate on Cartesian coordinate system XY, respectively; C _{ den } is the maximum pixel value of the cross section; σ is the variance of the Gaussian curve, and θ is the angle between the cross section and the main direction of the linear structure, which is shown in Fig. 9 a. According to [23], we can obtain the relationship between the variance σ and the radius of the lines structure w [Appendix C]: \(\sigma = w/\sqrt 3\).
The average diameter of the dendritic spine of the part is less than 0.9 μm, while the xy resolution is 137 nm/pixel, so the average radius w is equal to 3 pixels.
As in previous part, we construct a Hessianbased ridge detector and take the additive inverse of the eigenvalue with maximum absolute value as the intensity of the enhanced image [Appendix D]:
The approach for enhancing line structure can be summarized as follows:
Extracting skeleton and finding branch points
We use the following Algorithm 6 to get the dendritic skeleton C (Fig. 8 (5)) at the basis of the binary image B (Fig. 8 (4)), which is obtained by segmenting the enhanced image I (Fig. 8 (3)) using a suitable threshold [28]:

1.
In the first subiteration, delete pixel p if and only if the condition (a), (b), (c) are all satisfied.

2.
In the second subiteration, delete pixel p if and only if the condition (a), (b), (d) are all satisfied.

Condition (a): X _{ H }(p)=1
where \({X_{H}}(p) = \sum \limits _{i = 1}^{4}{b_{i}}\), \({b_{i}} = \left \{ {\begin {array}{*{20}{c}} { 1,~if~x_{2i1} = 0~\text {and}~(x_{2i} = 1~or~x_{2i+1} = 1)}\\ { 0,~\text {otherwise}} \end {array}} \right.\) x _{1},x _{2},…,x _{8} are the values of the eight neighbors of p, starting from the east neighbor and numbered in counterclockwise order.

Condition (b): 2≤ min{n _{1}(p),n _{2}(p)}≤3,
where \({n_{1}}(p) = \sum \limits _{k = 1}^{4} {{x_{2k  1}} \cup {x_{2k}}}\), \({n_{2}}(p) = \sum \limits _{k = 1}^{4} {{x_{2k}} \cup {x_{2k + 1}}}\).

Condition (c): \(({x_{2}} \cup {x_{3}} \cup {\overline x_{8}}) \cap {x_{1}} = 0\)

Condition (d): \(({x_{6}} \cup {x_{7}} \cup {\overline x_{4}}) \cap {x_{5}} = 0\)
The two subiterations together make up one iteration of the algorithm and the iterations are repeated until the resulting image stops changing. The approach for extracting skeletons can be summarized as follows:
In this study, the operation for finding branch points is a twodimensional convolution of the binary image of skeletons and a 3by3 filter, with an intensity value of 0 for 4 vertices and 1 for the rest positions. The points with an intensity value equal or greater than 4 are considered as branch points. Figure 8 (6) illustrates the branch point detection results.
Locating dendritic spines
We locate the suspected dendritic spines as follows: 1 〉 Remove spur pixels of the dendritic skeletons. The removed pixels are the putative locations of the dendritic spines. 2 〉 In a bifurcationcentered and properly sized region of skeleton, if there is an alternative point connected with the branch point, we consider the alternative point indicates the position of dendritic spine. This process is illustrated in Fig. 10 and the detail is stated in Algorithm 4.
Filtering points on axons
The transgenic mouse used in this study is YFPH line, in which a subset of layer 5 cortical neurons express YFP. Therefore, YFP signals in these images contain both dendrites and axons. When searching for dendritic spines, it is essential to determine whether these points are on an axon. For each of the structures that centered on suspected spines with a proper size, illustrated in Fig. 11, we take the ratio of its area to its perimeter and average intensity as judging criteria.
As shown in Fig. 12, the positions marked with red circles are the results before screening and the positions marked with green plus sign are results after screening. The positions only marked with red circle are likely locations of axons, rather than spines. The detail is presented in Algorithm 7.
Detection of synapses
Through the discussion in the previous two sections, we obtained the position of the axonal boutons and dendritic spine in the twophoton image stacks. As mentioned in above section, the presynaptic part is located on an axon and the postsynaptic part is located on a dendrite in mostly synapses. Then, it is reasonable to get the locations of the synapses on 2D by integrating the locations of the axon boutons and dendritic spines. Specifically, we calculate the distance between the axon and dendritic spine to determine whether the two are overlapping. Furthermore, we can count the synapses on 3D based on the detection in continuous 2D images. As shown in Algorithm 8, for each synapse in the 2D image, find its nearest synapse in the next layer. If this synapse is also the nearest of the synapse in the next layer, and the distance between them is close enough, these two synapses are the same synapse in the view of 3D.
Experimental results
In order to demonstrate the effectiveness of the proposed algorithm, we show two axon images corresponding to layer 1 and layer 20, with the axonal boutons indicated by red circles marked by experienced neurobiologists in Fig. 13 a and b. The corresponding experimental results detected by our algorithm are shown in Fig. 13 c and d. The ground truth of synapses, axons and dendrites were redundantly marked by three students, and disagreements are decided by another biologist.
The manual annotation process lasts about 2 days. The roundlike structures and the structures shown in Fig. 7 were labeled as axonal boutons and dendritic spines respectively, while the spinebouton pairs were marked as synapses.
We conducted some experiments on other layers and recorded the number of axonal boutons in ground truth. By comparing the detected result with the corresponding ground truth, we respectively determined the number of redundant and missing axonal boutons in different layers as listed in Table 1.
To illustrate the effectiveness of the proposed algorithm, we show partial results of the dendritic spines detection from Layer 1 to Layer 25 in Fig. 14.
As shown in Table 2, we recorded the number of dendritic spines in ground truth and the number of false positive and missing dendritic spines, which were obtained by comparing the detected result with the corresponding ground truth, for several layers.
In Fig. 15, we can see that one axonal bouton indicated by green rectangles arises in layers 510 but is only marked in layer 5. Analogously, two axonal boutons are respectively indicated by red rectangles and yellow rectangles are solely marked in layer 8. This method can count the axonal boutons precisely in 3D because it considers the multilayer information. A specific example in Fig. 16 can account for it.
The partial results of synapse detection from Layer 1 to Layer 26 are shown in Fig. 17 and the experimental results of synapse detection are shown in Table 3. The green ellipses mark the location of false negatives and the red arrows point to the location of false positives.
We have integrated the proposed method of identifying axonal boutons, dendritic spines and synapses with TrakEM, a plugin of ImageJ. This automates synapse analysis process. The left subgraph in Fig. 18 shows the 2D synapse positions, in which synapses are marked by yellow circles. It also provides interactive function, which makes it easy to proofread the detection results. Furthermore, we marked the positions located by the automatic method and by manual annotation with blue triangles and a yellow triangle respectively. The right subgraph of Fig. 18, which was extracted from the left subgraph, and shows the manually marked position (marked by a yellow triangle) with a value of 1.
Discussion
In vivo twophoton microscopy has been widely used to study structural plasticity of axonal boutons and dendritic spines in live animals. Recently, Yang et al. [19] simultaneously labeled and imaged longrange projecting axons and local dendrites, and studied the turnover dynamics of boutons, spines, and synaptic contacts. This dualcolor twophoton imaging method allows in vivo examination of synaptic dynamics in specific neural pathways. However, manual annotation of synaptic contacts is timeconsuming and prone to bias. The efficiency of synapse detection will be greatly improved by replacing the manual method with automatic method. The automated method can also be used for bouton and spine detection.
As can be seen from the original image in Fig. 1, the structures of axons and dendrites are not significant enough to cause them to be confused with the ambient noise. Therefore, it is necessary to carry out image enhancement to improve the accuracy of detection.
There are 140 twophoton images in total, each of which is 512by512 in size with a xyz resolution of 137 × 137× 700 nm/pixel. The time spent on manually checking the results of the automatic algorithm and manual annotation are shown in the following bar graph in Fig. 19. We can notice that our approach is much more efficient than manual annotation, especially advantageous if the data volume is larger.
Besides, we have tested our method to another data provided by Beijing Normal University (refered to as Data B) and obtained satisfactory detection results. This dataset provides twophoton image data from neurons in the tbasal ganglia of aeniopygia guttata. The volume of the dataset is 53.3 μ m×53.3 μ m×5.6 μ m and slice thickness is 0.2 μ m. The size of per image in 2D is 1024 pixels×1024 pixels. Some of the detection results are shown in Fig. 20, in which the green part are axons and the red part are dendrites. The positions of the candidate synapses detected using our pipeline are denoted by blue circles, while the probable missing synapses are indicated by yellow arrows. We detected all 12 synapses in 3D precisely.
Applying our method to a new dataset requires determining the parameters of image enhancement, ie. the radius of axonal bouton and the radius of lines structure of dendrites.
In [29], Yi Zuo et al. found that, using in vivo twophoton imaging, experienceddependent elimination of postsynaptic dendritic spines in the cortex was accelerated in ephrinA2 knockout mice and ephrinA2 regulates experiencedependent, NmethylDaspartate (NMDA) receptormediated synaptic pruning through glial glutamate transport during maturation of the mouse cortex. In [30], Ajmal Zemmar et al. tested the effects of NogoA neutralization on synaptic plasticity in the motor cortex and on motor learning in the uninjured mature Central nervous system (CNS). According to a series of statistics, such as numbers of dendrites, spines and axons, they concluded that antiNogoAmediated enhancement of structural and functional synaptic plasticity enlarges the memory capacity per synapse, leading to improved motor learning in vivo. Data analysis in these studies can benefit from our proposed method. Our approach will greatly facilitate data analysis related to dendrite, axon and synapse imaging.
Conclusion
We presented a novel strategy for identifying axon boutons, dendritic spines, and synapses in in vivo twophoton images. For continuous sequence image stack, we can also count the amount of them in 3D by analyzing the context cues of the detected synapses. This approach will help neuroscientists automatically analyze and quantify the formation, elimination and destabilization of the axonal boutons, dendritic spines and synapses. But it is not yet possible to extract the morphology of synapses. One of our future directions is to get synaptic shapes in 3D.
Appendix 3D deconvolution
The 3D deconvolution operation implemented in ImageJ [22] consists of the following steps:

1.
Download the software ImageJ. Then download the following files: Diffraction_PSF_3D.class, Diffraction_PSF_3D.java, Iterative_Deconvolve_3D.class, and Iterative_Deconvolve_3D.jave. Next, put files in the plugins folder;

2.
Run ImageJ and load the original axon image stacks;

3.
Open the Diffraction PSF 3D plugin. Fill the form with the related parameters and compute the pointspread function (PSF);

4.
Open the Iterative Deconvolve 3D plugin. Select the generated PSF and original axon image stacks, then input the iteration times and generate the deconvolved axon image stacks.
Appendix A
Model the intensity of axonal bouton using a threedimensional Gaussian surface:
The partial derivatives R _{ xx },R _{ xy },R _{ yx },R _{ yy } can be computed as follows:
Then the eigenvalues λ _{ a }(x,y) of the Hessian matrix are solved as follows:
Appendix B
For clarity of presentation, we choose the cross section of y=y _{0}. The Gaussian curve corresponding to the pixel value of cross section y=y _{0} is
And the edge point (x ^{∗},y _{0}) satisfies
Additionally by the definition in [23], the edge point (x ^{∗},y _{0}) in (8) also satisfies the equation R ^{′′′}(x ^{∗},y _{0})=0. After some lengthy calculations, we have
A suitable solution is
According to Eqs. (9) and (11), we conclude that \(\delta =r/\sqrt 3 \) is a good choice to identify the axonal boutons.
Appendix C
According to [23], the magnitude of the second derivative of the extracted position is always maximum at the line position. Then, for a fixed y=y _{0}, the third derivative of Formula(4)
can be written as:
Then we can obtain
With additional efforts, as illustrated in Fig. 9(a), we can obtain the relationship between the variance σ and the radius of the linear structure w:
Appendix D
For I as shown in Formula(4), the partial derivatives I _{ xx },I _{ xy },I _{ yx }, and I _{ yy } can be computed as follows:
Then we can get the eigenvalues of \(H(x,y) = \left ({\begin {array}{cc} {{I_{xx}}(x,y)}&{{I_{xy}}(x,y)}\\ {{I_{yx}}(x,y)}&{{I_{yy}}(x,y)} \end {array}} \right)\):
Appendix E. Comparison of segmentation with and without image region enhancement
To justify the use of the image region enhancement on boutons, some useful experiments are conducted. We use three different thresholds, 1000, 2000, 3000, for direct segmentation. Above figures provide direct segmentation results without image region enhancement on boutons. Below figures reserve the final segmentation regions containing local maximum value. From these figures, we conclude that a small threshold will reserve the bright axon shaft, whereas a big threshold will eliminate the weak axonal boutons. For these reasons, we propose to use the image region enhancement method to extract the disklike structure. The original experiment results demonstrated the effective of our proposed method.
Appendix F. Process of finding branch points
We show the process of finding branch points in the following figure. The kernel is a 3by3 filter with an intensity value of 0 for 4 vertices and 1 for the rest positions. And the points on the convolution result, with an intensity value equal or greater than 4 are considered as branch points.
Abbreviations
 CNS:

Central nervous system
 DAMAS:

Deconvolution approach for the mapping of acoustic sources
 GFP:

Green fluorescent protein
 NMDA:

NmethylDaspartate
 PSF:

Pointspread function
 YFP:

Yellow fluorescent protein
References
 1
Sherrington C. The integrative action of the nervous system. J Nerv Ment Dis. 1907; 34(12):801–hyhen.
 2
Tohka J, Ruotsalainen U. Imaging brain change across different time scales. Front Neuroinformatics. 2012; 6:29.
 3
Paola, 1 VD, Svoboda1 K, et al. Cell typespecific structural plasticity of axonal branches and boutons in the adult neocortex. Neuron. 2006; 49(6):861–75.
 4
Becker N, Nägerl UV, et al. Ltd induction causes morphological changes of presynaptic boutons and reduces their contacts with spines. Neuron. 2008; 60(4):590–7.
 5
Karube F, Kubota Y, Kawaguchi Y. Axon branching and synaptic bouton phenotypes in gabaergic nonpyramidal cell subtypes. J Neurosci Off J Soc Neurosci. 2004; 24(12):2853–65.
 6
Grillo FW, Song S, et al. Increased axonal bouton dynamics in the aging mouse cortex. Proc Natl Acad Sci. 2013; 110(16):1514–23.
 7
LeDoux JE. Emotion circuits in the brain. Focus. 2009; 7(7):274–4.
 8
Bourne JN, Harris KM. Balancing structure and function at hippocampal dendritic spines. Ann Rev Neurosci. 2008; 31:47.
 9
Sherrington C. Estructura de los centros nerviosos de las aves. Revista Trimestral de Histología Normal y Patológica. 1888; 1:1–10.
 10
Segal M. Dendritic spines and longterm plasticity. Nat Rev Neurosci. 2005; 6(4):277–84.
 11
Fan J, Zhou X, et al. An automated pipeline for dendrite spine detection and tracking of 3d optical microscopy neuron images of in vivo mouse models. Neuroinformatics. 2009; 7(2):113–30.
 12
Jun X, Ting Z, et al. Anisotropic path searching for automatic neuron reconstruction. 2011; 15(5):680–9.
 13
Mukherjee S, Condron B, Acton ST. Tubularity flow field–a technique for automatic neuron segmentation. IEEE Trans Image Process. 2015; 24(1):374–89.
 14
Basu S, Condron B, Aksel A, Acton ST. Segmentation and tracing of single neurons from 3d confocal microscope images. IEEE J Biomed Health Inform. 2013; 17(2):319–35.
 15
González G, Türetken E, Fua P, et al. Delineating trees in noisy 2d images and 3d imagestacks. In: Computer Vision and Pattern Recognition (CVPR), 2010 IEEE Conference On. San Francisco: IEEE;2010. p. 2799–806.
 16
González G, Aguet F, Fleuret F, Unser M, Fua P. Steerable features for statistical 3d dendrite detection. Medical Image Computing and ComputerAssisted Intervention–MICCAI 2009. 2009;625–32.
 17
Rodriguez A, Ehlenberger DB, Dickstein DL, Hof PR, Wearne SL. Automated threedimensional detection and shape classification of dendritic spines from fluorescence microscopy images. PLoS ONE. 2008; 3(4):1997.
 18
Gabriele R, Qi G, Dirk F. Synaptic microcircuits in the barrel cortex. 2015;59–108.
 19
Yang Y, Liu DQ, Huang W, Deng J, Sun Y, Zuo Y, Poo MM. Selective synaptic remodeling of amygdalocortical connections associated with fear memory. Nat Neurosci. 2016; 19(10):1348–1355.
 20
Li W, Zhang D, Xie Q, Chen X, Han H. An automated detection for axonal boutons in vivo twophoton imaging of mouse. In: Eighth International Conference on Graphic and Image Processing. Tokoyo: SPIE (the international society for optics and photonics);2017. p. 102250Q.
 21
Dougherty RP. Extensions of damas and benefits and limitations of deconvolution in beamforming. AIAA paper. 2013; 11:2961.
 22
Schmid B, Schindelin J, et al. A highlevel 3d visualization api for java and imagej. Bmc Bioinformatics. 2010; 11(1):1–7.
 23
Steger C. An unbiased detector of curvilinear structures. IEEE Trans Pattern Anal Mach Intell. 1998; 20(2):113–25.
 24
Lindeberg T. Edge detection and ridge detection with automatic scale selection. Int J Comput Vis. 1998; 30(2):117–54.
 25
Steger C. Extracting curvilinear structures: A differential geometric approach. In: 4th European Conference on Computer Vision. Cambridge: Springer;1996. p. 630–41.
 26
Wang S, Chen M, et al. Detection of dendritic spines using waveletbased conditional symmetric analysis and regularized morphological sharedweight neural networks. Comput Math Meth Med. 2015; 2015(2):1–12.
 27
Yoshihara Y, Roo MD, Muller D. Dendritic spine formation and stabilization. Curr Opin Neurobiol. 2009; 19(2):146–53.
 28
Lam L, S W Lee CYS. Thinning methodologiesa comprehensive survey. IEEE Trans Pattern Anal Mach Intell. 1992; 14(9):869–85.
 29
Yu X, Wang G, Gilmore A, Yee AX, Li X, Xu T, Smith SJ, Chen L, Zuo Y. Accelerated experiencedependent pruning of cortical synapses in ephrina2 knockout mice. Neuron. 2013; 80(1):64–71.
 30
Zemmar A, Weinmann O, Kellner Y, Yu X, Vicente R, Gullo M, Kasper H, Lussi K, Ristic Z, Luft AR, et al. Neutralization of nogoa enhances synaptic plasticity in the rodent motor cortex and improves motor learning in vivo. J Neurosci. 2014; 34(26):8685–98.
Acknowledgements
Not applicable.
Funding
The financial support of Special Program of Beijing Municipal Science & Technology Commission (NO. Z161100000216146), Science and Technology Development Fund of Macau (044/2015/A2), Scientific research instrument and equipment development project of Chinese Academy of Sciences (YZ201671), Strategic Priority Research Program of the CAS (NO. XDB02060001), Institute of Automation, CAS, for the 3D Reconstruction of Brain Tissue at Synaptic Level (NO. Y3J2031DZ1) and National Natural Science Foundation of China (NO. 61673381, NO. 61201050, NO. 61306070, No. 31472001) is appreciated.
Availability of data and materials
The data and source code in this paper is available upon request.
Author information
Ethics declarations
Ethics approval and consent to participate
Not applicable.
Consent for publication
Not applicable.
Competing interests
The authors declare that they have no competing interests.
Publisher’s Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. The Creative Commons Public Domain Dedication waiver (http://creativecommons.org/publicdomain/zero/1.0/) applies to the data made available in this article, unless otherwise stated.
About this article
Cite this article
Xie, Q., Chen, X., Deng, H. et al. An automated pipeline for bouton, spine, and synapse detection of in vivo twophoton images. BioData Mining 10, 40 (2017) doi:10.1186/s1304001701615
Received
Accepted
Published
DOI
Keywords
 in vivo twophoton imaging
 Synapse
 Bouton
 Spine
 Image enhancement