Frontiers in Computational Neuroscience an Algorithm for Finding Candidate Synaptic Sites in Computer Generated Networks of Neurons with Realistic Morphologies

parameters. Recently, Luczak (2006) generates neuronal morphologies using a diffusion limited aggregation (DLA) approach. The simulator CX3D (Zubler and Douglas, 2009) aims at simulating cortical development in 3D space, including the morphology of single neurons. Cuntz et al. (2010) apply a minimal spanning tree principle in generating neuronal morphologies. Costa and Coelho (2005, 2008) generate 2D neuronal morphologies by statistically sampling a probabilistic model of neuronal geometry based on branch probabilities per branch level using a Monte Carlo approach, and form connections when neuronal trees overlap in 2D. The simulator NETMORPH (Koene et al., 2009) is based on biological growth principles of neurons by stochasti-cally modeling the elongation and branching of growth cones in developmental time. Spatial closeness between axonal and dendritic branches, typically determined by the dimensions of dendritic spines and axonal boutons, is considered as a prerequisite for synapse formation. Hellwig (2000) used reconstructed neurons for estimating connec-tivity between overlapping dendritic and axonal arborizations. To this end reconstructed neurons were transformed into voxel fields (with voxels of 1 μm side length) followed by counting the number of voxels containing both axonal and dendritic elements and obtaining a number of potential synaptic sites, thus adopting a distance criterion of 1 μm. Kalisman et al. (2003) used sets of 3D reconstructions of biocytin-stained cells to obtain axonal and dendritic statistical representations in order to calculate the probabilities of close appositions. Stepanyants et al. (2002) and Stepanyants and Chklovskii (2005) estimated the number of potential synaptic sites in terms of axonal and dendritic length densities per unit volume, typical dendritic spine IntroductIon Activity dynamics underlying cognition depends crucially on the patterns and strengths of synaptic connections between neu-rons. During development neurons grow out by elongation and branching of dendritic and axonal arbors. Synaptic connections can form when axonal and dendritic branches of neurons come sufficiently close to each other (Peters, 1979). The geometry of neuronal arborizations is therefore an important determinant of synaptic connectivity. How neuronal morphology shapes neuro-nal network connectivity is, however, still poorly understood. New developments in experimental and computational approaches make it now possible to shed light on this question. With multi-patch techniques experimentalists are now measuring connectivi-ties between the patched neurons using electrophysiological and anatomical criteria (e. Computational approaches make it possible to assemble a number of neurons (reconstructed or algorithmically generated) in a 3D geometrical arrangement and to study the emerging synaptic connectivity by searching the …

parameters. Recently, Luczak (2006) generates neuronal morphologies using a diffusion limited aggregation (DLA) approach. The simulator CX3D (Zubler and Douglas, 2009) aims at simulating cortical development in 3D space, including the morphology of single neurons. Cuntz et al. (2010) apply a minimal spanning tree principle in generating neuronal morphologies. Coelho (2005, 2008) generate 2D neuronal morphologies by statistically sampling a probabilistic model of neuronal geometry based on branch probabilities per branch level using a Monte Carlo approach, and form connections when neuronal trees overlap in 2D. The simulator NETMORPH (Koene et al., 2009) is based on biological growth principles of neurons by stochastically modeling the elongation and branching of growth cones in developmental time.
Spatial closeness between axonal and dendritic branches, typically determined by the dimensions of dendritic spines and axonal boutons, is considered as a prerequisite for synapse formation. Hellwig (2000) used reconstructed neurons for estimating connectivity between overlapping dendritic and axonal arborizations. To this end reconstructed neurons were transformed into voxel fields (with voxels of 1 μm side length) followed by counting the number of voxels containing both axonal and dendritic elements and obtaining a number of potential synaptic sites, thus adopting a distance criterion of 1 μm. Kalisman et al. (2003) used sets of 3D reconstructions of biocytin-stained cells to obtain axonal and dendritic statistical representations in order to calculate the probabilities of close appositions. Stepanyants et al. (2002) and Stepanyants and Chklovskii (2005) estimated the number of potential synaptic sites in terms of axonal and dendritic length densities per unit volume, typical dendritic spine IntroductIon Activity dynamics underlying cognition depends crucially on the patterns and strengths of synaptic connections between neurons. During development neurons grow out by elongation and branching of dendritic and axonal arbors. Synaptic connections can form when axonal and dendritic branches of neurons come sufficiently close to each other (Peters, 1979). The geometry of neuronal arborizations is therefore an important determinant of synaptic connectivity. How neuronal morphology shapes neuronal network connectivity is, however, still poorly understood. New developments in experimental and computational approaches make it now possible to shed light on this question. With multipatch techniques experimentalists are now measuring connectivities between the patched neurons using electrophysiological and anatomical criteria (e.g., Feldmeyer et al., 1999Feldmeyer et al., , 2002Feldmeyer et al., , 2006Le Bé et al., 2007;Frick et al., 2008). Computational approaches make it possible to assemble a number of neurons (reconstructed or algorithmically generated) in a 3D geometrical arrangement and to study the emerging synaptic connectivity by searching the sites where potential synapses may occur. For instance, neuroConstruct (Gleeson et al., 2007) is a modeling tool for creating neuronal networks in 3D space using imported neuronal morphologies. The simulator L-Neuron creates virtual neurons using an L-systems approach by iteratively sampling experimental distributions of neuronal shape parameters (Senft and Ascoli, 1999;Ascoli and Krichmar, 2000;Samsonovich and Ascoli, 2007). Similarly, the simulator tool NeuGen (Eberhard et al., 2006) generates neuronal networks in 3D with morphologically realistic neurons by sampling experimental distributions of morphological shape An algorithm for finding candidate synaptic sites in computer generated networks of neurons with realistic morphologies small-world properties (e.g., Watts and Strogatz, 1998;Stepanyants et al., 2002;Hilgetag and Kaiser, 2004;Stepanyants and Chklovskii, 2005). Other studies emphasize the hierarchy in neural network connectivity (e.g., Kaiser et al., 2010) or different spatial scales (e.g., Passingham et al., 2002;Sporns et al., 2005;Stam and Reijneveld, 2007). An interesting aspect during development of network connectivity is the critical phenomenon of percolation when the largest cluster of connected neurons makes an abrupt transition in size toward a giant cluster as studied by Costa and Manoel (2002) and Coelho (2005, 2008), who also showed the dependence of this phenomenon on the morphology of the developing neurons. Many of these studies rely on methods for estimating synaptic connectivity between axonal and dendritic arborizations, underscoring the need for algorithms that estimate the connectivity as realistic as possible.
The paper describes an algorithm for testing the proximity between chains of line pieces on the basis of crossing properties of line piece pairs. The paper includes a Section "Materials and Methods" with the derivation of geometrical conditions for crossing line pieces using a classical geometry approach (applying a series of 3D transformations). In the Section "Results" the outcomes of the synapse detection model are shown without and with the crossing requirement. A study of the multiplicity of the connections (the number of synapses between two connected neurons) is included. The paper includes an "Rotations in 3D" of Appendix summarizing the 3D rotation matrices, "Relative Position of Point D of the Perpendicular From Point C to Opposite Side AB in a Triangle ABC" of Appendix with some basic triangular geometry, "Expressing the Crossing Conditions in Terms of the Original Coordinates" of Appendix formulating the crossing conditions in the Section "Crossing Line Pieces" in terms of the original coordinates, and "Summary of Calculations and Crossing Conditions" of Appendix summarizing the calculations and the crossing conditions. For reason of completeness, "Analytical Approach" of Appendix includes a different approach using analytical geometry and based on an algorithm taken from literature (Dan Sunday, http://softsurfer. com/Archive/algorithm_0106/algorithm_0106.htm), which also includes the shortest distance between non-crossing line pieces.

ProxIMIty-based search of candIdate synaPtIc locatIons
The search in a 3D network of neurons with complex axonal and dendritic arborizations for locations where axonal and dendritic branches are sufficiently close can proceed by searching the shortest distance between any two branches from the axonal and dendritic arborizations. The shortest distance between two straight infinite lines is at the site where they are crossing and determined by the length of the orthogonal connection line ( Figure 1A). Axonal and dendritic branches in neuronal reconstructions, however, are not infinite straight lines, but composed of many line pieces in sequence with varying orientations and lengths. Then the distance between any line piece pair from the axonal and dendritic branch must be determined and tested against the criterion value. As illustrated in Figure 1B several pairs of nearby line pieces may meet the distance criterion resulting in a cluster of potential synaptic sites. In addition the number of "nearby" line pieces is dependent on the length scale of the line pieces which may influence the outcome for length and average angle between axonal and dendritic branches. Amirikian (2005) used the concept of synaptic clouds (density fields) as representation of the complex structure of axonal/dendritic arbors for studying connectivity between different cell classes.
With the recently developed simulator NETMORPH, assemblies of neurons can be generated with realistic 3D morphologies and realistic morphological variability in any arbitrary 3D arrangement (Koene et al., 2009). The emerging connectivity in these networks can be determined by searching the locations where axons and dendrites are sufficient close to each other for synapse formation, thus identifying the sites of candidate synapses. Both in experimentally reconstructed neurons and in algorithmically generated neurons (such as by NETMORPH) axons and dendrites are approximated by piecewise-linear structures, i.e., represented by chains of line pieces or cylinders. Testing the proximity of axonal and dendritic branches then implies the search for pairs of individual dendritic and axonal line pieces that are closer to each other than a given criterion distance. When an axonal and dendritic branch are sufficiently close in space, the application of just a distance criterion, however, may result in several pairs of nearby line pieces obeying the proximity criterion and thus may fall into a cluster of candidate synaptic sites (see Figure 1B). In addition, the number of sufficiently close line piece pairs appears to depend on the typical length scale of the line pieces in the dendritic and axonal representation. As the clustering and the length scale dependency were considered to be artifacts of this approach a method was needed to identify uniquely the location where an axonal and dendritic branch are closest in space. To this end an additional requirement was introduced by searching for that line piece pair from an axonal and dendritic chain of line pieces that cross in space and taking the shortest (orthogonal) distance for that pair as the shortest distance between the axonal and dendritic branch (see Figure 1C). This shortest distance is subsequently subjected to the distance criterion for candidate synapses. Note that in the case of cylinders the distance is taken between their axial center lines.
The characterization of network connectivity has also become an important area of research. Graph-theoretical studies of brain connectivity focus amongst others on the presence of hubs and (1) Transformation II -first rotation of q, r, and s around Z-axis toward 1 q, 1 r, and 1 s, respectively, such that 1 q is in the XZ-plane The rotation around the Z-axis, see the number of potential sites (see Figure 1B). This length scale in the piecewise-linear approximation of the neuronal morphological representation relates to morphological reconstruction procedures in experimental approaches, and to the time step parameter in computer simulation approaches.
To avoid clustering of candidate synaptic sites and length scale dependencies, a synapse allocation criterion was needed to identify uniquely locations where axon and dendrite chains of line pieces are closest to each other and where this shortest distance is smaller than the given criterion value. Extending the idea of the unique crossing point of infinite lines, it is proposed to search for the crossing point between an axon and dendrite chain of lines pieces. Such a crossing point can be searched for by testing the crossing condition for any pair of line pieces from the axon and the dendrite chain of line pieces and taking the orthogonal distance for this line piece pair to evaluate the distance condition ( Figure 1C).

crossIng lIne PIeces
Line pieces do cross when they are in a certain geometrical position to each other, i.e., when the projection of line piece (1) onto the plane through line piece (2) and parallel to (1) intersects line piece (2), as is illustrated in Figure 2B. Only then can an orthogonal connection line be drawn whose length is the shortest distance between both line pieces. Figure 2A illustrates an arrangement of nearby, but non-crossing line pieces.
In the following an algorithm is introduced for testing whether or not two line pieces do cross. If they do, the algorithm provides the length of the orthogonal connection and the coordinates where this connection line intersects the two line pieces. Applying this algorithm to all pairs of line pieces of an axonal and dendritic branch will test the existence of a crossing pair, and whether the shortest distance in this pair meets the distance criterion. algorIthM for deterMInIng whether two lIne PIeces are crossIng Given are two line pieces PQ and RS and the coordinates of the points P(x, y, z), Q(x, y, z), R(x, y, z) and S(x, y, z). A "classical" geometry approach is used in which a series of 3D transformations is applied on the two line pieces in order to bring them in such a geometric arrangement that the condition for crossing can easily be applied. These transformations include one translation and three rotations around the three axes of the orthogonal coordinate system.   By this rotation, point Q is rotated onto the X-axis, thus giving point 2 q zero y-and z-coordinates and making the x-coordinate equal to the length of line piece PQ.
The rotations of 1 r and 1 s toward 2 r and 2 s proceed similarly via respectively, and we obtain 2 1 1 1 1 r r r r l r q PQ r q r q r q PQ x x z using the expressions for 1 r x and 1 r z . Because the expression for 2 r x will occur frequently in following expressions we will assign it a special symbol C R = 2 r x .
using the expressions for 1 r x and 1 r z, followed by further elaboration.
In a similar way we obtain for 2 s Here, l denotes the length of the projection of Oq onto the XY-plane with

Transformation III -Second rotation of 1 q, 1 r, and 1 s around Y-axis into 2 q, 2 r, and 2 s, respectively, such that 2 q is on the X-axis, thus making the line piece O 2 q to coincide with the X-axis
The rotation around the Y-axis, see Because also the expression for 2 s x will occur frequently in following expressions we have assigned it the special symbol C S = 2 s x Transformation IV -third rotation of 2 q, 2 r, and 2 s around X-axis into 3 q, 3

r, and 3 s such that the rotated line piece 3 r 3 s runs parallel to the ZX-plane, thus with 3 r and 3 s having equal y-coordinates
With the original line piece PQ transformed to coincide with the X-axis, the final rotation will be around the X-axis in order to position the original line piece RS parallel to the ZX-plane (Figure 6).
The rotation around the X-axis proceeds via 3 r = Rot X (α). 2 r and 3 s = Rot X (α). 2 s or  The rotation angle α can be obtained by the following geometrical considerations. Let 2 r′ 2 s′ and 3 r′ 3 s′ be the projections of 2 r s s and 3 r 3 s onto the YZ-plane. Evidently the squared length of the projections of the respective line pieces in the YZ-plane.
With the fraction f v the y-and z-coordinates of point V can be calculated as When both line pieces PQ and RS are in one plane and are running parallel, then line piece 2 r 2 s runs parallel to the X-axis, the projection points 2 r′ and 2 s′ coincide and the length l r s 2 2 ′ ′ is zero. Then the coordinates V y and V z coincide with those of 2 r′ and 2 s′ With the length of the line piece OV l Concerning the rotation angle α, vector OV needs to be rotated toward the positive Y-axis implicating a rotation over −δ, thus The rotations in Eq. 17 3 r = Rot X (α). 2 r and 3 s = Rot X (α). 2 s can now be made explicit as

Applying the conditions for crossing line pieces
After the series of transformations the line pieces O 3 q and 3 r 3 s are in the geometrical positions of O 3 q coinciding with the X-axis, and 3 r 3 s running parallel to the ZX-plane (Figure 7). Now it can easily be determined whether they are crossing. With 3 r 3 s running parallel to the ZX-plane, its projection 3 r′ 3 s′ onto the XY-plane runs parallel to the X-axis. If (A) 3 r 3 s intersects the XY-plane, and (B) if this intersection point u of 3 r 3 s with the XY-plane has an x-coordinate within the length of 3 p 3 q ( 3 p x ≤ u x ≤ 3 q x ) then O 3 q and 3 r 3 s are crossing line pieces and the perpendicular line of u onto X-axis ut is the orthogonal shortest distance between the line pieces.
Condition A: Line piece 3 r 3 s crosses the XY-plane if the product of the z-coordinates of 3 r and 3 s is negative or if one or both of them equals zero, thus if and similarly 3 2 By the rotation the points 3 r and 3 s have obtained equal y-coordinates.
Line pieces PQ and RS in one plane. When both line pieces PQ and RS are in one plane but not parallel they (or their elongations) have an intersection point, the line piece 2 r′ 2 s′ has an orientation through the origin (i.e., the line piece 2 r′ 2 s′ or its elongation intersects the X-axis), and the length of line piece OV is equal to zero. Then the projections of both points have equal ratios for their Z-and Y-coordinates of the line piece RS. The orthogonal distance between two crossing line pieces thus is between the point T(x, y, z) on PQ and the point U(x, y, z) on RS and is equal to In the final step the orthogonal distance TU is tested against a given proximity criterion value.

alternatIve aPProach for testIng crossIng of lIne PIeces
The approach followed in this paper was first to test the crossing property of line pieces, followed by the calculation of the orthogonal distance. An alternative approach was introduced by Dan Sunday in his algorithm on the softsurfer.com website (http://softsurfer.com/ Archive/algorithm_0106/algorithm_0106.htm). This algorithm first determines the crossing point of the infinite lines through the line pieces, followed by a test of whether or not the orthogonal connection line intersects the line pieces themselves and if so, followed by the distance calculation. The procedure of Sunday is described in "Analytical Approach" of Appendix and includes an algorithm for calculating the shortest distance between two noncrossing line pieces, i.e., when the line piece extensions appear to cross outside the range of the line pieces.

results
The "old" synapse formation model based on distance only and the "new" one based on crossing and distance have been applied to a network of 25 Layer 2/3 pyramidal neurons, with their cell bodies generated within a sphere of radius 43 μm with minimum neuron separation of 20 μm. The neurons were generated using the NETMORPH simulator (Koene et al., 2009) based on growth parameter values optimized on a data set of reconstructed rat cerebral cortex L2/3 pyramidal neurons made available by Svoboda through the www.neuromorpho.org website . Examples are illustrated in Figure 8.
Outcomes of the "old" and "new" synapse formation model are illustrated in Figures 9A-D. The figures show the axons (green), dendrites (red) and the synapse locations (small blue spheres). Figures 9A,B show the locations of candidate synapses when the crossing condition was not applied and only the shortest distance If both coordinates are zero, line piece 3 r 3 s runs parallel to O 3 q and is in the XY-plane. If one of the coordinates is zero, line piece 3 r 3 s has one point in the XY-plane.
Condition B requires first (B1) an overlap of x-coordinates of O 3 q and 3 r 3 s, thus when As O 3 q originates from the transformed line piece PQ its length equals that of PQ, thus 3 q x = PQ. Using the symbols C R and C S , Eq. 30 can also be phrased as The final condition (B2) requires that the intersection point is within the length of O 3 q, thus The fractions of the line pieces where the orthogonal connection intersects the line pieces is independent of the transformations applied and therefore we can derive the crossing point T on PQ to be at a fraction in Figure 9A, 111104 in Figure 9B, 1188 in Figure 9C, and 1555 in Figure 9D, respectively. Comparing these numbers as well as the pictures in the top and bottom row makes clear how the distancebased approach (top row) results in a strong clustering of synapses and how this is prevented by applying the crossing condition (bottom row). Comparing the synapse numbers as well as the pictures for "long" (left column) and "short" line pieces (right column) illustrates that the synapse formation model based on distance only is highly between line pieces was tested, using the algorithm based on Sunday's approach (Shortest Distance Between Two Non-Crossing Line Pieces). Figures 9C,D show the locations of candidate synapses when the crossing condition was applied and the orthogonal connection was subjected to the distance criterion. In all four panels the distance criterion was 4 μm. The results in Figures   (i.e., synapses were formed when an axon and a dendrite came within 2 μm of each other, a distance criterion also used by Stepanyants and Chklovskii, 2005). The new synapse formation model has been applied with distance criteria of 2, 4, and 6 μm, respectively. The results of these simulations are shown in Figure 10, summarizing the distributions of the number of synaptic contacts per connection. The left column of Figure 10 shows the distribution of number of contacts/connection versus frequency for a synapse formation model based only on distance (see Shortest Distance Between Two Non-Crossing Line Pieces). The distributions illustrate the large number of contacts per connection as a result of the clustering effect when only a distance criterion is used. The distributions in the second, third, and fourth column are obtained with the new synapse sensitive to the length scale (with synapse numbers 32799 versus 111104, respectively) while the synapse formation model based on crossing and distance grossly reduced this dependency (with synapse numbers 1188 versus 1555, respectively).
With the new synapse formation model, a first series of simulations have been performed on the number of synaptic contacts per connection between neuron pairs. To this end networks were generated with the NETMORPH simulator of 250 layer 2/3 pyramidal neurons arranged in a sphere with a radius of 93 μm with realistic density of 75,000 mm −3 (Hellwig, 2000). The minimum separation between somata was 20 μm. Both the old synapse formation model based on distance only, as well as the new one based on crossing and distance, were used. For the old model a distance criterion of 2 μm was used Algorithm for proximity-based connectivity evaluating proximity of all pairs of line pieces that constitute both neuronal structures. Note that proximity is here taken between the axial center lines and that a criterion of proximity should consider both the branch diameters and the distance between the branch exteriors (such as spine and bouton lengths). The disadvantage of a straightforward distance criterion is that it may be met by several combinations of nearby line pieces, resulting in clusters of candidate synaptic sites. Additionally, this number appeared to be sensitive to the length scale of the individual line pieces. The procedure introduced in this study aimed at representing the places where axonal and dendritic branches are sufficiently close by a single candidate synaptic site. To this end the line piece crossing criterion was introduced in addition to the distance criterion. This was based on the notion that the shortest distance between two infinite lines in 3D is determined by the length of the orthogonal connection line at the unique site of crossing of the infinite lines. Also two chains of line pieces will generally contain only one unique pair of mutual line pieces that fulfills the geometrical condition of crossing and identifies the unique location of shortest distance between the two chains of line pieces. For this reason, the crossing condition was introduced in addition to the distance criterion to eliminate the clustering artifact and to reduce the length scale dependency.
The paper describes the derivation of the crossing conditions by applying a series of 3D transformations to the line piece pair to bring them in such a 3D position that crossing can easily be determined. The conditions for crossing are finally summarized in a series of tests to be applied to all dendritic and axonal line piece pairs of two neuronal representations. The performance of the "new" synapse detection method has been illustrated visually in tests of the "old" and the "new" method, and quantitatively in terms of distributions of the number of contacts between connected neuron pairs. The obtained mean number of contacts per connection appeared to be in excellent agreement with the available experimental data. The frequency distributions for the number of contacts per connection had a monotone decreasing shape. Because of the small number of observations in experimental data this prediction is still waiting validation. The present outcomes clearly demonstrated that the new synapse detection model based on crossing and distance eliminated the clustering effect of the old model based on distance only, and reduced significantly the dependence on the length scale of the line pieces.
Although two chains of line pieces will generally contain only one unique pair of crossing line pieces, more than one crossing pair may occur under certain geometrical conditions. For instance, when a certain line piece A1 of chain A is orthogonal and intersects the plane formed by two subsequent line pieces B1 and B2 of another chain B, then both B1 and B2 may cross the A1 line piece. If so, and if the orthogonal connection in both pairs is meeting the distance criterion, then they result in two nearby candidate sites. Another case is when two line piece chains are running more or less in parallel. Then, crossing line piece pairs may occur at varying distances along both chains and, when they meet the distance criterion, result in as many candidate synaptic sites.
Axonal and dendritic branches may follow straight courses but may also meander strongly. Deviations from a straight line influence the way axons and dendrites are filling space. The probability of sites of near proximity is therefore expected to depend on the tortuosity of axonal and dendritic branches. It is an interesting question formation model based on distance and crossing. The 2nd column was obtained with the same distance criterion of 2 μm as the 1st column and comparing these columns shows how the additional crossing criterion reduces the number of contacts per connections to realistic values by eliminating the clustering effect. The third and fourth column are obtained for larger values of the distance criterion. As expected the number of contacts per connection increases with this criterion as the likelihood for sufficient proximity also increases, with mn(sd) values of 2.0(1.8), 3.4(3.9), and 5.1(6.5) contacts per connection for distance criteria of 2, 4, and 6 μm, respectively, and for using a time step of dt = 20 s (top row).
Experimental data for the number of synaptic contacts per connection show an average value of mn(sd) 2.8(0.7) (n = 8 pairs) between L2/3 pyramidal neurons in the barrel cortex of juvenile rats (Feldmeyer et al., 2006), an average value of 4.5(0.5) (n = 13 pairs) between juvenile rat barrel cortex L4 spiny neurons and L2/3 pyramidal cells (Feldmeyer et al., 2002), an average of 3.4(1.0) (n = 11 pairs) between spiny rat somatosensory cortex L4 neurons (Feldmeyer et al., 1999), and an average number of 3.5 ± 1.8 putative contacts per connection between juvenile rat somatosensory cortex L5A pyramidal cells (Frick et al., 2008). Hellwig (2000) estimated the number of synapses per connection from the overlap of voxelized images for nearby neurons to be about 2.5 for L2-L2 connections and about 1.2 for L3-L2 connections. The voxel size used of 1 × 1 × 1 μm 3 , effectively implemented a distance criterion of 1 μm. Although the experimental data originate from a variety of cell types and cortical areas, experimental numbers are in a rather restricted range of 2.5-4.5 contacts per connection. The values obtained with our new synapse formation model are in the range of 2.0-5.1 contacts per connection (for dt = 20 s) when using distance criteria of 2, 4, and 6 μm. It is a remarkable result that the simulation outcomes overlap so nicely the range of experimental data. Stepanyants and Chklovskii (2005) estimated the number of potential synapses from a presynaptic neuron onto a postsynaptic neuron on the basis of reconstructed neurons (lower layer-4 spiny stellate neurons or layer 3 pyramidal neurons from cat visual cortex) as a function of the relative positions of their cell bodies and found numbers in the range of 0-6 potential synapses. Our findings are also in good agreement with these estimated numbers.
An additional outcome of our present simulations is that the frequency distributions are monotone decreasing with the number of contacts per connection, a property that is not yet experimentally observed due to the low numbers in the published distributions. The monotone decreasing distribution may not be surprising as the probability of having two contacts per connection is expected to be the square of the probability of having one contact per neuron pair.

dIscussIon
Axons and dendrites can make synaptic connections at those locations where they come sufficiently close to each other, typically within a distance determined by the length of dendritic spines and axonal boutons. The present study aimed at defining a procedure for finding such locations in networks of neurons whose 3D geometry is represented by piecewise-linear structures (line pieces or cylinders) as is the case in experimental reconstructions and in computer generated morphologies from neural simulators. Proximity of axonal and dendritic branches is then tested by whether in real nervous tissue strongly meandering axons and dendrites make relative more synapses in comparison with straight ones. In our computer generated networks this is certainly expected when the meandering of the branches is approximated by line pieces with varying orientations. In a given area in space one may expect more nearby line piece pairs to cross and meeting the distance criterion at small length scales then at large length scales of the line pieces. It is thus not surprising that a remaining length scale dependency was also found with the new synapse formation model.
The algorithm for testing crossing line pieces derived in this paper differs from the one of Dan Sunday (Analytical Approach) by first testing whether or not two line pieces are crossing, and if so, followed by the distance calculation. The algorithm of Sunday, in contrast, first calculates the site where the infinite lines through the line pieces cross, followed by a test of whether or not this site of crossing coincides with the line pieces and if so, also followed by the distance calculation. This difference makes the present algorithm about 20% faster than Sunday's algorithm, when implemented in FORTRAN code on a Linux system.
The procedure described in this paper identifies the location where an axonal and a dendritic branch are sufficiently close by a single candidate synaptic site, and is purely based on geometrical considerations. Whether or not in the biological tissue at these sites synapses will actually form and in which number is a question not addressed in this paper. Dendrites may be covered by spines in high density suggesting that a nearby axon may form more than one synapse close in space. Such a clustering of synapses between a single axon and dendrite then has a biological origin and is thus principally different from the artifactual clustering caused by the search procedure that gave rise to this study. Nearby spines may of course also be contacted by axonal branches from different neurons. When they all meet the crossing and distance criteria, a clustering of candidate synaptic locations between a single dendritic branch and these different axons will then still occur. In the case of skewed triangles (lowest two triangles in Figure A2), the orthogonal lines CD on AB do not end any more on the line piece AB itself and the relative positions f(D | AB) and f(D | BA) can get values outside the range of [0, 1]. The relative position of the perpendicular ending in a triangle was used in Figure 6B to obtain the position of point V (see also Eq. 18). In a skewed triangle this point V would not be within the line piece 2 r s s in Figure 6B, implicating that after rotation line piece 3 r 3 s does not intersect the XY-plane. Thus a skewed triangle already indicates that the line pieces are not crossing. exPressIng the crossIng condItIons In terMs of the orIgInal coordInates Some crossing conditions as described in the previous section still need to be expressed in terms of the coordinates of the original points P, Q, R, and S, or their relative coordinates, p, q, r, and s Next, the quantities 3 r x , 3 s x , 3 r z , and 3 s z can be expressed in terms of the coordinates of the original points P, Q, R, and S, with the subsequent calculation of u x . Equations 23 and 24 give us the expressions for these quantities as , and For the numerator in the expression for u x (Eq. 31) we obtain and for the denominator in the expression for u x (Eq. 31) with

Constants:
q q q q q q q q r q r q r q r q s q s q s q Lines A and B cross each other where the distance between points on both lines is the shortest, say at A(s c ) and B(t c ). The vector  w c between these points then is orthogonal to line A and line B, and we obtain Let us define: then we obtain If finally condition B2 is also fulfilled, then the line pieces are crossing and therefore proceed 9. Ratios f T and f U :

AnAlyticAl ApproAch
An alternative approach uses an algorithm taken from the site http://softsurfer.com/Archive/algorithm_0106/algorithm_0106. htm by Dan Sunday.

Shortest distance between two infinite lines
In this analytical geometry approach the shortest distance between the two infinite lines through the line pieces PQ and RS is first been determined, followed by the test whether the orthogonal connection line intersects the line pieces PQ and RS, respectively. The infinite line A through the points P and Q can be described as For the corresponding points A s P s u ( ) = + ⋅  and B t R t v ( ) = + ⋅  , it has subsequently to be determined if they are located on the line segments PQ and RS, respectively.

Shortest distance between two non-crossing line pieces
The procedure for calculating the shortest distance between two line pieces PQ and RS is based on an algorithm of Dan Sunday (http://softsurfer.com/Archive/algorithm_0106/algorithm_0106. htm) and is taken as the shortest distance between any two points on these line pieces, respectively.
A line piece PQ is given by the points on the line A ( Figure  Line pieces are running parallel. When the two line pieces (and their infinite extensions) are running parallel the two equations in (Eq. A5-9) are dependent with the denominator (Eq. A5-10) being zero. The distance between the parallel lines can be determined by taking for instance an arbitrary value for s c , say s c = 0, and then solving (Eq. A5-9) resulting in t c = d/b = e/c, followed by the calculation of the distance using (Eq. A5-11). By running parallel, an infinite number of orthogonal connections can be drawn between both lines. Additional tests are now needed to determine whether both line pieces share a range where they intersect both these orthogonal connection lines.
If not, then both line pieces are not crossing. If yes, then a choice need to be made for a particular orthogonal connection line and the intersection points at both line pieces (in order to locate a synaptic connection); see the choice made in Eqs. 32 and 33.
Line pieces are not parallel but in one plane. When the two line pieces are not parallel but still in one plane then they intersect and a solution exists for the equality A(s) = B(t). Then, using Eqs. A5-1 and A5-2 we obtain P s u R t v + ⋅ = + ⋅   or P R s Q P t S R − + ⋅ − − ⋅ − = ( ) ( ) 0