Perfect Detection of Spikes in the Linear Sub-threshold Dynamics of Point Neurons

Spiking neuronal networks are usually simulated with one of three main schemes: the classical time-driven and event-driven schemes, and the more recent hybrid scheme. All three schemes evolve the state of a neuron through a series of checkpoints: equally spaced in the first scheme and determined neuron-wise by spike events in the latter two. The time-driven and the hybrid scheme determine whether the membrane potential of a neuron crosses a threshold at the end of the time interval between consecutive checkpoints. Threshold crossing can, however, occur within the interval even if this test is negative. Spikes can therefore be missed. The present work offers an alternative geometric point of view on neuronal dynamics, and derives, implements, and benchmarks a method for perfect retrospective spike detection. This method can be applied to neuron models with affine or linear subthreshold dynamics. The idea behind the method is to propagate the threshold with a time-inverted dynamics, testing whether the threshold crosses the neuron state to be evolved, rather than vice versa. Algebraically this translates into a set of inequalities necessary and sufficient for threshold crossing. This test is slower than the imperfect one, but can be optimized in several ways. Comparison confirms earlier results that the imperfect tests rarely miss spikes (less than a fraction 1/108 of missed spikes) in biologically relevant settings.


INTRODUCTION
In the last decade, considerable work has been devoted to improve the accuracy of simulators that are capable of efficiently simulating large networks of spiking neurons (Hansel et al., 1998;Mattia and Del Giudice, 2000;Shelley and Tao, 2001;Dehaene and Changeux, 2005;Morrison et al., 2007;Brette, 2007;D'Haene et al., 2009;van Elburg and van Ooyen, 2009;Zheng et al., 2009;Hanuschkin et al., 2010).The field is driven by the ideal of combining the capability to cope with the high-frequency of synaptic events arriving at a neuron in nature with a mathematically accurate implementation of the threshold process a wide class of neuron models is based on.
Two classical schemes to simulate neuronal networks are the time-driven and the event-driven schemes (Fujimoto, 2000;Zeigler et al., 2000;Ferscha, 1996).Both schemes describe the state of the neurons by a set of variables and the action potentials as events that mediate the interaction between them.
In a time-driven scheme, the state of a neuron is updated on a time grid defined by the simulation step (for a review see Morrison and Diesmann, 2008).After all neurons are updated, their membrane potential is checked for threshold crossings.If the membrane potential of a neuron is above the threshold at this checkpoint, a spike is delivered to all neurons it is connected to.Subsequently, a new iteration step begins.The step size stipulates how frequently occurrences of threshold crossings are inspected during the simulation.The choice of the step size a trade-off between spike accuracy and the speed of the simulation Morrison et al. (2007).Such grid-constrained simulations force each spike event to a position on the equidistant temporal grid spanned by the step size and therefore induce artificial synchronization of the network dynamics (Hansel et al., 1998;Shelley and Tao, 2001;Morrison et al., 2007;Brette, 2007;van Elburg and van Ooyen, 2009;Hanuschkin et al., 2010).
In an event-driven scheme, the state of a neuron is updated only when it receives a spike.A central queue of events is maintained and each spike is inserted into this queue with its own time stamp.Upon update a neuron predicts when its next spike will occur in the absence of further input.This preliminary event is inserted into the queue and confirmed if it becomes due or removed when invalidated by further input.Efficient and elegant predicition methods have been developed for classes of neuron models without invertable dynamics (Brette, 2007;van Elburg and van Ooyen, 2009;D'Haene et al., 2009;D'Haene and Schrauwen, 2010;Ferscha, 1996).However, maintaining a central queue in a distributed simulation is challenging and may compromise the time performance of the simulator (Hanuschkin et al., 2010, for a detailed review see).
A hybrid scheme circumvents the shortcomings of both these schemes by embedding a locally eventdriven algorithm for each neuron into a globally time-driven scheme (Morrison et al., 2007).The arrival of a spike at a neuron introduces one additional update and check point.The dynamics of a given neuron is then propagated from incoming spike to incoming spike and eventually to the end point of the global timestep.If the membrane potential of a neuron is above the threshold at a local or global check point, the precise point of threshold crossing is determined in continuous time, and a spike is emitted.Next to their location on the time grid, in this scheme spike events carry a floating point offset.Thus, in contrast to an event-driven scheme, the hybrid scheme does not predict future spike times but identifies threshold crossings only retrospectively.Hanuschkin et al. (2010) demonstrate that the latter scheme is equally accurate as the former at lower computational costs.
The hybrid scheme still has a loophole, however: spikes can be missed.The reason is that, as in the time-driven scheme, crossing of the threshold voltage is tested by inspecting whether the membrane potential of the neuron is above threshold at the end of a checkpoint (see Figure 1 for an illustration of the scenario).Nevertheless, the membrane potential V , evolved by the subthreshold dynamics, can be below threshold θ at two consecutive checkpoints t and t + h while a double, quadruple, etc. threshold-crossing occurred in between.The first crossing constitutes a missed spike.Symbolically, Figure 1.Illustration of undetected threshold crossing between two consecutive checkpoints t and t + h on the time grid.The short black vertical bar represents an incoming spike which causes an increase in the membrane voltage of the neuron, leading to a threshold crossing at t θ .The subthreshold dynamics, however, brings the voltage under threshold again at the next checkpoint.Since the test V (t + h) ⩾ θ yields false, the outgoing spike at t θ is missed.The red dots indicate points where the values of state variables are known.
so the test V (t + h) ⩾ θ is a sufficient but not a necessary condition for the occurrence of a threshold crossing during the time interval ]t, t + h].For future reference we call this test "standard test".
The conceptual question therefore remains whether a globally time-driven scheme can formulated such that it detects every threshold crossing.Although Hanuschkin et al. (2010) argue that the loss of spikes of the standard test is not of practical relevance in natural parameter regimes, the availability of a method perfect by construction would free the researcher from inquietude and costly controls when faced with previously unexplored neuron models or network architectures.
In this work we propose a new spike-detection method, which we term "lossless method" or "lossless test" because it is a necessary and sufficient condition for threshold crossing to occur in a given time interval.The method is based on state-space analysis and works with any neuron model with affine or linear subthreshold dynamics.It consists of a system of inequalities -some linear, some non-linear in the state-space variables -that together determine whether the initial state of a neuron will or will not reach threshold within the time interval until the next checkpoint.The lossless method replaces the standard test (1) in the time-driven and the hybrid scheme.Alone, it does not solve the problem of artificial synchronization the time-driven scheme suffers from.Hence the method is most meaningful within the hybrid scheme.Thanks to its perfect spike detection the lossless method can in fact be used to benchmark the hybrid scheme based on the standard test; Hanuschkin et al. (2010) use the method of D' Haene et al. (2009) for this purpose.
In Section 2 we present the idea behind the lossless method for a general neuron model with an affine or linear dynamics, and develop its mathematical construction.Parts of this construction must be addressed on a case-by-case basis; therefore in Section 3 we provide a concrete implementation of the lossless method for the leaky integrate-and-fire model with exponential synaptic currents (Fourcaud and Brunel, 2002a), within the hybrid scheme.The method can be algorithmically expressed in different ways.We explore two alternative cascades of inequalities and assess their costs in terms of time-to-completion relative to each other and to the hybrid scheme based on the standard test (1).For the latter scheme we also assess the number of missed spikes in commonly considered network regimes.The hybrid scheme based on the lossless method delivers the desired exact implementation of the mathematical definition of the neuron model without any further approximation up to floating point precision.
Preliminary results have been published in abstract form (Kunkel et al., 2011;Krishnan et al., 2016).The technology described in the present article will be made available with one of next major releases of the open-source simulation software NEST.The conceptual and algorithmic work described here is a module in the long-term collaborative project to provide the technology for neural systems simulations (Gewaltig and Diesmann, 2007).

Idea: moving a surface backwards instead of a point forward
Let us summarize the problem mentioned in the previous section.We assume that a neuron's state evolves according to three different dynamics: (a) an integrable subthreshold dynamic as long as the neuron's membrane potential is below threshold and there are no changes in input currents; (b) discrete jumps in the subthreshold dynamics at predetermined times, corresponding to incoming spikes or to sudden changes in external currents; these can be formally incorporated into the subthreshold dynamics (a) via delta functions; and (c) a "spike", i.e. an instantaneous jump of the membrane potential from threshold to a reset value, as soon as the potential reaches the threshold value.The jump may be followed by a refractory period in which the membrane potential remains constant at the reset value.Then the integrable dynamics takes place again.
The advantage of the integrable dynamics is that the state of the neuron at a time t + h can be analytically determined by that at time t; here h can be negative or positive.The evolution can thus be calculated in discrete time steps, in particular in between times at which jumps (b) occur.The spike part of the dynamics, however, forces us to check whether the membrane potential V reached a threshold value θ within the timestep interval ]t, t + h].We call this event threshold crossing (by "crossing" we also mean tangency).A sufficient condition for threshold crossing is that the membrane potential be above threshold at the end t + h of the time step: by continuity, it must have assumed the threshold value at some time in the interval ]t, t + h].But this condition is not necessary: during the time step the potential may touch or surpass the threshold value and then go below it again, as in Figure 1, an even number of times.Its value is then below threshold at both ends of the time step, t and t + h.A test that only relies on the sufficient condition V (t + h) ⩾ θ -the standard test (1) -can therefore miss some spikes, leading to an incorrect dynamics.We need a test based on a necessary and sufficient condition.
A necessary and sufficient condition for threshold crossing is that the trajectory of the state during ]t, t+h] intersect the hypersurface "membrane potential = threshold value".Translated into analytic geometry this means finding the solutions of a system of parametric equations -one representing the threshold hypersurface, the other the trajectory -and to test whether its solution set is empty (no threshold crossing) or not (threshold crossing).This idea is illustrated in Figure 2A for a two-dimensional state space.This system is usually transcendental and its solutions have to be found numerically.Unfortunately, numerical solutions typically rely on bisection algorithms (Press et al., 2007, ch. 9), involving an increasingly finer timestepping of the dynamics.This nullifies the advantage of having an integrable dynamics with coarse-grained time steps.
The problem is that the test of intersection between trajectory and threshold tells us not only whether a threshold crossing occurs, but also the time at which it does.The test's high computational cost partly comes from delivering this additional information.This problem is avoided if we formulate a different geometric test that tells us whether a threshold crossing occurs but does not deliver the crossing time.
Mathematics often offer non-constructive proofs: "there exists a solution to the problem, but we do not know what the solution is".It turns out that this ignorance is exactly what we need in our problem.
Instead of evolving the state of the neuron forwards in time, tracing a trajectory in state-space, and checking if and when it crosses the threshold hypersurface, we can evolve the threshold hypersurface backwards in time, sweeping a hypervolume, and check if and when it "crosses" the initial neuron state, which is a point.In other words we are testing whether a point belongs to a particular state-space region.The test for the intersection of a 1-dimensional curve with an (N − 1)-dimensional surface is replaced by the test for the membership of a point in an N -dimensional volume.This idea is illustrated in Figure 2B for a two-dimensional state-space.
Mathematically the latter test translates into a system of inequalities that the initial state at t must satisfy if it does not cross threshold within ]t, t + h].Even if transcendental functions appear in this system, we do not need to find their roots: we only need to test whether the inequalities are satisfied by simply inserting the value of the state-space variables in the functions.
The equations corresponding to these inequalities represent the piecewise-differentiable boundary between the set of states that will cross the threshold within the timestep h -which we call spike region -and the set of those that won't -which we call no-spike region.Finding these inequalities in explicit form is the most important point of this method, and can be achieved with this heuristic procedure: I. Find the hypervolume swept by the threshold, in parametric form.This is done by representing the backpropagation of the threshold in state-space as a map between two manifolds: the product manifold threshold × time, and the state-space manifold.II.Find the boundary of the hypervolume, in parametric form.This is done by determining the placement of the images of the boundaries of the product manifold and, most important, of the images of the critical points of the map.The latter are the points at which the map becomes singular, thus mapping hypervolume elements into hypersurface elements (Spivak 1999, ch. 2;Choquet-Bruhat et al. 1996, § II.A.1).III.Transform the equations of the boundary above from parametric to implicit form.If this is not possible, the boundary can still be approximated by a triangularization, as finely as we please.IV.Finally, exclude the parts of the boundary that lie in the interior of the hypervolume (so technically not a boundary).Some guidelines to achieve this can be given based on the the convex properties of the hypervolume.
In the following analysis we mathematically develop the first two steps in a general way for any neuron model with an affine dynamic.Let us point out that they can be generalized to other kinds of dynamics.
The procedure for the last two steps depends on the particular neuron model, so we can only give general guidelines.Section 3 provides a concrete example of all steps.An advantage of this procedure is that it can be geometrically explained and needs to be carried out only once for any given neuron model.
The advantage of this novel test is that its computational cost is distributed differently from the approach where the trajectory of the initial point is followed.In hand-waving terms, in the trajectory-based test the crossing time is immediately available from the parametrization of the orbit; the threshold-crossing condition is represented by computationally costly inequalities, because the crossing time, when it exists, can be read from them immediately.In the novel test the crossing time is a more complicated function of the hypervolume parametrization; the threshold-crossing condition in this case is represented by inequalities that are computationally less costly, because they do not explicitly deliver the crossing time.Knowledge of the latter requires an additional computational cost.The novel test thus allows us to avoid this extra cost when we check for the existence of a threshold-crossing; we only need to pay it if the crossing does occur.
Illustration of two exact methods to check whether an initial state (red dot) crosses the threshold (blue horizontal line) during the evolution from t to t + h.Upper panel: the idea of a root-finding method is to evolve the state forwards in time by a step ∆t = +h, and to check whether its trajectory (light-red curve) intersects the threshold.Such a method informs us of where the intersection occurs on the threshold, and at which time.Lower panel: the idea of the lossless method is to evolve the whole threshold "backwards in time" from t = h to t = 0 by a step ∆t = −h and to check whether its trajectory, which is a volume in state-space (light-blue region), contains the initial state, which is kept fixed.The threshold shifts and rotates as it evolves, and the trajectories of its individual points are unknown: this method does not inform us of when and where on the crossing it occurs, and is therefore computationally faster.
From a mathematical point of view the two approaches are equivalent.The state-space technique is just a useful reformulation of the conventional trajectory view that is obtained by suitable mathematical manipulations.The conceptual device of propagating the threshold backwards in time is useful because it performs those manipulations in a transparent manner and gives them an intuitive dynamical meaning.
The state-space S of a neuron has a natural vector-space structure (an affine-space structure would also suffice), inherited from the physical quantities that define it: the membrane potential V and other N − 1 physical quantities I whose exact number and definition depend on the specific neuron model (e.g., I could represent currents or additional voltages, for example of different compartments).For our purpose it is useful to consider S as an N -dimensional differential manifold: its points {s} are the neuron states, and the quantities (I, V ) are coordinates V : S → R and I : S → R N −1 e.g., the membrane potential of a state s is V (s).These coordinates respect the vector structure of the state-space, i.e.V (s 1 + s 2 ) = V (s 1 ) + V (s 2 ) and likewise for I.
Every hyperplane in the state-space is defined by an affine equation k ⊺ s = −κ, the covector k ⊺ being the normal to the hyperplane, and −κ being the affine term.The inequality k ⊺ s > −κ defines one of the two half-spaces delimited by the hyperplane.The threshold hyperplane is especially important: it is the set of states s whose membrane potential has the threshold value: (2) An affine transformation of the state-space onto itself, where M is a linear transformation and m a state, maps each hypersurface and half-space k ⊺ s ⩾ κ to a hypersurface and half-space (the transformation of the normal k ⊺ shows why it is a covector rather than a vector).
We now show that the integrable part of the neuron dyamics within a finite time step h is an affine transform.Similarly, the integrable part of of the neuron dynamics we consider an affine evolution determined by the equation In a time interval h, this dynamics propagates an initial state s 0 at time t into the final state This, for each h, is an affine transformation of the form (4).In coordinates (I, V ) the linear operator A and vector q have the block form where B is an (N − 1, N − 1) matrix, α and β numbers, and the dimensionalities of the rectangular matrices c ⊺ , d follow accordingly.

Derivation of the threshold-crossing condition
Let us mathematically summarize the first threshold-crossing test discussed in Section 2.1.We said that the state evolution ( 7) can be efficiently used in a time-step scheme in numerical simulations, but we need to test whether a threshold crossing occurred at some time t ∈ ]t, t + h].A necessary and sufficient condition would be the existence of solutions of the trascendental equation in t which corresponds to the intersection of the trajectory ( 7) and the threshold hyperplane (2); but it is a costly condition to test.
We now develop the second kind of threshold-crossing test discussed in Section 2.1, according to the steps I-IV.Steps I and II are performed in full generality for an affine dynamics.Steps III and IV have to be solved on a case-by-case basis, so their analysis below is only a guideline; a concrete example on how to perform them is given in Section 3.3.3and Section 3.3.4.

Hypervolume in parametric form
Consider the threshold hyperplane V (s) = θ as an (N − 1)-dimensional manifold with coordinates x.It is embedded in state-space via the map x → (I, V ) = (x, θ). (10) Each state (x, θ) on the threshold, when propagated backwards in time for an interval h, traces a curve in state-space (the yellow lines of Figure 3).
The union of these curves is an N -dimensional product manifold, called the extrusion (Bossavit, 2003) of the threshold hyperplane.We can use coordinates (x, t) ∈ (R N −1 × [0, h]) on this manifold.Its mapping into state-space is given, with the help of eq. ( 7), by where t > 0 is the direction of the past.This map is analytic, but generally not an embedding because it can have self-intersections.We will see the significance of this in Section 2.4.It is not an immersion either because it can have singular points; these will be especially important for us because they constitute part of the boundary between spike and no-spike regions.See Figure 3 for a two-dimensional example.
For fixed t, the map x → E(x, t) is affine, and its image is a hyperplane representing the states on the threshold propagated backwards in time for an interval t.Combining it with eqs (3)-( 5) we find that the backpropagated threshold has t-dependent normal and affine terms The inequality k ⊺ t s < κ t determines the backpropagated half-space, which is below threshold.

Hypervolume boundary in parametric form
We must now find the boundary of the image of the map E. The latter is a closed set, being the image of a closed set under a continuous map; its boundary must therefore be the image of some points of the domain.Such points must either lie on the boundaries of the domain, R N −1 × {0} and R N −1 × {h}, or be critical points of E, or both, because E is differentiable.See the example of Figure 3.
The images of the boundary are easily found from (11): one (image of t = 0) is the threshold hyperplane, the other (t = h) is the hyperplane k ⊺ h s = κ h , with coefficients given by ( 12).Explicitly, in coordinates (I, V ), Let us find the image of the critical points of E. The tangent map of E at a point (x, t) is The tangent map is also denoted E * in some differential-geometry texts.
Its determinant is the inverse ratio between a volume element at that point and its image in state-space (the sign determines their relative orientation).Hence this ratio vanishes at points where volume elements are mapped onto area elements (in other words, N linearly independent vectors in the domain are mapped onto N linearly dependent vectors), which is a feature of the boundary.See the two-dimensional example of Figure 3.
Let us look for points where det TE(x, t) = 0.In eq. ( 15), the determinant of the exponential never vanishes, so we only have to consider the determinant of the matrix on the right.This is easily calculated by Laplace expansion along the last row, whose elements all vanish except the last.The cofactor of the last element is det I (modulo a sign).Hence and the coordinates (x, t) of critical points satisfy This equation says that one of the coordinates x has an affine dependence on the remaining ones; let us call these y.For example, if c N −1 ̸ = 0, the equation above has the parametric solution Denote this affine dependence by x(y).By taking the derivative of eq. ( 17) with respect to y we have a property we will use later.
The locus of critical points in state-space is then given parametrically by a map Γ , found by substitution of eq. ( 18) in ( 11): This locus has four important interrelated features: First: from the form of eqs ( 17) and ( 20), the locus of critical points is flat along N − 2 dimensions -corresponding to a fixed value of the coordinate t -and is curved normally to the direction t: it is an (N − 2)-ruled surface.
Second: the points on the locus corresponding to fixed t belong to a hyperplane with coefficients (12), as is easily checked by substitution.In other words, the locus of critical points is the envelope of the backpropagated threshold hyperplanes k ⊺ t s = κ t , eq. ( 12), at different times t, and its tangent hyperplanes have normals k ⊺ t given by ( 12).Third: considering the feature above for t = 0, the locus of critical points is tangent to the threshold hyperplane.
Fourth: comparing the dynamics (6), the map for the threshold hyperplane (10), and the critical-point condition (17), we notice that the latter is also the condition for the trajectory (7) of a state s 0 = (x, θ) on the threshold hyperplane to have an extremum in the membrane potential V .Hence, the locus of critical points is the trajectory of the intersection between the threshold and the V -nullcline.
In view of the second property above, let us call the locus of critical points envelope, for brevity.

Hypervolume boundary in implicit form
The next step is the elimination of the parameters (y, t) to express the envelope Γ as one or more implicit equations χ(s) = 0 defined on domains D χ for the state-space coordinates s.This step can involve a transcendental equation, therefore we cannot give a general solution for it.In this regard, a criticism might be raised, which we immediately address: it looks like we have already taken great care in avoiding to solve eq. ( 9), only to face another difficult transcendental equation?The current problem is more manageable for three reasons.First, we observe that the equations needed to re-express the curved surface in explicit form are generally easier to handle than (9).Section 3.3.3gives a concrete example.Second, the problem of finding the explicit form of the curved surface must be solved only once, whereas the solution of the original equation ( 9) has to be found for each initial state s 0 .Third, the equation for the curved surface is easier to approximate numerically than the original one (9), again because the approximations do not depend on an initial state.
Suppose we have found a function χ such that χ(s) = 0 is the envelope: The condition above leaves χ completely undetermined (apart from smoothness requirements) outside of the envelope.Therefore, if possible, it is useful to extend the condition as follows.Since χ(s) = 0 is the envelope of the backpropagated threshold hyperplanes k ⊺ t s = κ t , eq. ( 12), at different times t, it must be tangent to each of them.The inequalities k ⊺ t s − κ t < 0, for each t, correspond to the backpropagated below-threshold half-plane, and it is useful to choose χ in such a way that the inequality χ(s) < 0, s ∈ D χ , determines the side corresponding to the intersection of these half-spaces.An example is given in Section 3.3.3.The differential dχ then is a positive multiple of k ⊺ t (note that dχ and k ⊺ t are collinear because of the tangency condition).
For the following, let us assume that χ has been chosen this way.

Boundary intersections and final system
If a state does not cross the threshold hyperplane at any time t ∈ [0, h], then it must, by definition, belong for every t to the image of the half-space that lies below threshold, when this half-space is backpropagated by the time t.Mathematically, this is simply the statement of the equivalence established in Section 2.2, where M and m are the coefficients of the affine evolution by time t.
By construction in the previous subsection, the inequality χ(I, V ) < 0 defines the region of intersection of all such backpropagated half-spaces, bounded by the envelope χ(I, V ) = 0. We just need to join to it the condition for the boundaries corresponding to the times t = 0 and t = h, V < θ, k ⊺ h s < κ h , discussed in Section 2.3.1.
The states that do not cross the threshold during the time interval [0, h] belong therefore to the no-spike region defined, in coordinates, by and and Some inequalities in this system may turn out to be redundant, i.e. automatically satisfied if the remaining ones are, and can thus be dropped.Section 3.3.3illustrates such a redundancy.

The region of missed spikes
In the previous section we mentioned that the N -dimensional product manifold formed by the (N − 1)dimensional threshold hyperplane and the time interval [0, h] presents self-intersections when mapped to the state-space.Two-dimensional examples of such a region are shown in Figure 3, lower panel, and in Figure 5, the region called S 2 .
A state s in the self-intersection region corresponds to two or more different coordinates (x, t): Note that x ̸ = x ′ , t = t ′ is impossible for an affine transformation, since the first column of ( 15) can never vanish.The condition above simply means that s crosses the threshold at x after an interval t and at x ′ after an interval t ′ .By continuity of the dynamics (6), one of the two must be a crossing from above, and one from below: this is exactly the scenario of double threshold crossing illustrated in Figure 1.
Suppose we have a probability distribution for the initial states, for example one that is invariant under the dynamics (6).The probability of the self-intersection region P (X) is the probability that the initial state will lead to a double-crossing of the threshold, and therefore be missed.This fact will be used in Section 3.5.2 to estimate the number of spikes missed.

Convexity, approximations, optimization
The affine dynamics (7) preserves affine combinations of solutions -and therefore convex combinations as well.If s 1 , s 2 are two arbitrary initial states in the no-spike region, then their propagated states also satisfy V [s 1 (t)] < θ and V [s 2 (t)] < θ when 0 ⩽ t ⩽ h; and also the propagation of their convex combination λs i.e. it lies in the no-spike region.This proves that the no-spike region is convex.
Convexity is important for approximations.If transforming the parametric equation for the envelope (20) into an implicit form (21) turns out to be analytically impossible, we can numerically find some points on the envelope and then approximate the latter by simplices constructed on these points, as finely as needed.In other words we can triangularize the envelope.Owing to convexity, the triangularization can be done completely on the side of the no-spike region (the corners of the simplices touch the envelope), or completely from that of the spike region (the barycentres of the simplices touch the envelope).This way we can formulate a test with no false positives, or one with no false negatives, or both.
The envelope is moreover a ruled surface, as shown in Section 2.3.2.The triangulation on the side of the no-spike region can therefore be conveniently chosen in such a way that one face of each simplex fully lies on the envelope.

IMPLEMENTATION EXAMPLE: LEAKY INTEGRATE-AND-FIRE NEURON WITH
EXPONENTIALLY DECAYING POST-SYNAPTIC CURRENTS

The example model
In the previous section we mathematically developed the idea of propagating the threshold backward in time in order to check whether a threshold-crossing occurs in a time-stepped dynamics.The derivation, valid for an affine subthreshold dynamics, is general and therefore also quite abstract; moreover, it involves a couple of mathematical steps (III and IV in Section 2.1) for which no general formulae can be given.
To explain the idea in more concreteness and to give an example of how to face all its steps, we now apply the scheme to a simple but relevant model with a 2-dimensional state-space: the leaky integrate-and-fire neuron with exponentially decaying post-synaptic currents.This model has a homogeneous linear dynamics on a 3-dimensional state-space (Rotter and Diesmann, 1999), where the third coordinate is the input current.If this current is constant, the dynamics can be rewritten as a 2-dimensional affine one.
Leaky integrate-and-fire models, despite their simplicity, approximate the behavior of real neurons with high accuracy (Rauch et al., 2003).The model with exponential synaptic currents captures important properties of real neurons: The postsynaptic potential has a finite rise and decay time and the membrane potential is a continuous function of time.Continuity avoids artificial synchronization, present in simpler models.Moreover, the model is to some extent analytically tractable.For short synaptic time constants, the mean firing rate (Fourcaud and Brunel, 2002a) as well as the linear response to small inputs (Schücker et al., 2015) can be obtained analytically.

Mathematical preliminaries: terms in block form
The example model has a 2-dimensional state-space for a single neuron, defined by the post-synaptic current I and the membrane potential V , which are also our coordinates.Its subthreshold interspike dynamics (a) in Section 2 is affine: or in matrix form d dt where C is the membrane capacitance, τ is the membrane time constant, I is the synaptic input current and I e is the external input current.The membrane potential V is subject to dissipation with time constant τ and integrates the post-synaptic current I.The latter decays exponentially with time constant τ s .Typical values of the parameters are τ = 10 ms, C = 250 pF, τ s = 2 ms, and the threshold θ = 20 mV.
Incoming spikes are incorporated in the equation for the current as Dirac deltas, and the external current I e has jump discontinuities in time.In the timestepped evolution, such discontinuous events are implemented as instantaneous changes in the initial state s 0 at each timestep.Hence we do not need to consider them explicitly in the equations above (Rotter and Diesmann, 1999).
In terms of the block form of Section 2.2 we have The exponential of A is which determines the evolution of the neuron state s 0 by an affine map as in eq. ( 7).
Since the state space is 2-dimensional, the "hyperplanes" and "hypersurfaces" of Section 2 are straight lines and curves.In particular, the threshold hyperplane is a line; when propagated by a time t it maps onto a line with covector and affine term given by eq. ( 12), explicitly For this model, testing for threshold-crossing by checking the intersection of a propagated state and the threshold line means solving the following transcendental system in t, given the initial state s 0 = (I, V ): for which we cannot find a solution in analytic form; we would have to resort to bisection algorithms.

Hypervolume in parametric form
The product manifold "threshold line × time interval" is in this case 2-dimensional, with coordinates (x, t).Here x is the value of the current at threshold crossing and t the corresponding time point.Its mapping E, eq. ( 11), to the state-space is This map is shown in Figure 3: the x isocurves are yellow and in the lower panel they represent the trajectories of states terminating on the threshold; the t isolines are blue and represent the threshold line propagated at different times.Each area element dx ∧ dt in the domain -the small rectangles in the upper plane -is mapped into an area element dI ∧ dV in the image.Note how these area elements are rotated and sheared.The thicker green curve is the set of singular points where the determinant of the tangent map vanishes: det(TE) = 0.Such points are singular because around them the images of the area elements get flattened to one dimension.In 3.4 we discuss the region of self-intersection bounded by the thick light cyan line, the thick dark blue line, and the thick green curved line.

Hypervolume boundary in parametric form
The boundaries of the image of the map E must be, as explained in Section 2.3.3, a subset of the images of the boundaries of the domain, R × {0} and R × {h}, and of the envelope.
The images of the boundaries, with general equations ( 13) and ( 14), in terms of (I, V ) follow The set of critical points of the map E is in this case a 1-dimensional curve, given in parametric form by the coordinate y of the general form (20) do not exist in this case, because the threshold is 1-dimensional.Figure 3 visualizes the set by the green curve.

Hypervolume boundary in implicit form
The next step in our procedure is to convert the parametric equation (34) of the envelope into an explicit or implicit equation for the coordinates (I, V ).As Section 2.3.3 does not provide a general algorithm, below we illustrate the process using our example model.
By equating the first component of eq. ( 34) to the coordinate I and solving for t, we find subject to the condition for I required for 0 ⩽ t ⩽ h and a real logarithm.
Substituting eq.(35a) into the V coordinate of eq. ( 34) we find 11), in two dimensions.Upper panel: the abstract manifold with coordinates (x, t) corresponding to the values of current and time at threshold crossing.
Lower panel: the image of the map in state space.Thick green curve corresponds to the set of singular points where det(T E) = 0, eq. ( 9).Yellow lines, constant x, are trajectories of states ending on the threshold.Violet lines, constant t, are snapshots of the threshold moving "backwards in time".The thicker violet and blue lines correspond to the boundaries t = 0 and t = −h.For t = 0 we have I = x, V = θ.
subject to the condition (35b).Let us analyse this equation, in view of its extension to an inequality of the form χ(I, V ) < 0 as required in Section 2.3.3.First, we observe that The inequality can be proven by studying the derivative of the fraction with respect to t.The derivative is always negative in the range above and the only maximum of the fraction is the value unity assumed at t = 0.
Inspection of equation ( 36) and of its parametric form (34) shows that we must consider three cases: I e ⋚ θC/τ , i.e. whether the external current is smaller or larger than the rheobase current this is the current necessary to reach threshold in an infinite time starting from any state with I ⩽ 0.
• If I e < I θ , then I is restricted to In this case, using the inequality (37), the V component of the envelope ( 34) is always smaller than the threshold: • If I e > I θ , then I must be negative and restricted to In this case, using the inequality (37), the V component of the envelope ( 34) is always larger than the threshold: • If I e = I θ , the envelope degenerates to a point: Γ (t) = (0, θ), which is the limit point reached in infinite time from any initial point in the no-spike region; this is the geometric interpretation of the equality of external and rheobase currents.
The function representing the envelope, eq. ( 21) of Section 2.3.3, has in this case the explicit form If we calculate its differential, as discussed in Section 2.3.3,we find that the latter is a positive multiple of the differential of the backpropagated threshold for each t.This is true in each of the three cases above.Consequently, the inequality χ(I, V ) < 0, (I, V ) ∈ D χ always includes the no-spike region.
In summary, we arrive at an analytic, implicit equation for the curved boundary (43).The expression is a transcendental function in I, owing to the generally irrational exponent 1 − τ s /τ , but it is used in an inequality, hence we do not need to find its roots.This is in contrast to the original transcendental equation for the threshold-crossing condition (30), which requires a bisection algorithm to find its solution.

Boundary intersections and final system
We can now assemble the system of inequalities defining the no-spike region consisting of the boundaries (32) and ( 33), and the envelope (43).
With some rearrangements, simplifications, and the introduction of two new functions f , b, the condition reads: and and Figure 4 illustrates the system for the two cases I e < I θ and I e > I θ .In the former case all three inequalities are necessary; in the latter, as well as for I e = I θ , the last inequality is automatically enforced by the first because its right-hand side is larger than the threshold θ (see eq. ( 42)).

The region of missed spikes
In Figure 3, lower panel, the trajectories of several states during a timestep h and ending on the threshold line are represented by yellow curves.In that figure we can identify a region were such trajectories selfintersect: it is bounded by a segment of the thick light blue line, a segment of the thick dark blue line, and a portion of the thick green curved line.Trajectories with initial states in this region must therefore cross the threshold twice during the interval ]t, t + h].As explained in Section 2.4, their threshold-crossing is not detected by the sole condition V [s(t + h)] ⩾ θ.All states in this region thus generate spikes that are missed by the standard test (1).This region is crucial for the comparison of the performances of schemes implementing the present lossless method and schemes relying on the standard test (1).This comparison is quantitatively made in Section 3.5.3.44), determining the no-spike region.The colored areas represent the complementary inequalities of the system (44), so the solution of that system is the white area.The red region delimited by the horizontal line corresponds to the first equation of the system, the blue region delimited by the inclined line to the second, and the yellow region delimited by the curved line to the third.Upper panel: case I e < I θ , all inequalities necessary.Lower panel: case I e > I θ , the third inequality is redundant.

Numerical implementation and optimization
In the last section we arrived at the system of three inequalities (44) that determines whether or not the current state (V, I) will cross the threshold within the timestep h.The state will cross the threshold if the system is not satisfied, and it will not cross the threshold if the system is satisfied.This system of inequalities constitutes the lossless method in the present model.The system requires the current timestep h, state (V, I), and external electric current I e as inputs (cf.Section 2).The timestep h is the minimum between the global timestep and the time interval up to the next input coming from other neurons, hence it can differ every time the test is called.The external electric current I e may also vary, stepwise, during the simulation, hence it may also be distinct at each call of the test.
If the system of inequalities is satisfied, thus predicting the absence of a spike within a timestep h, then the state of the neuron is evolved by applying the propagator ( 7) with ( 27)-( 28), leading to a new state, and the procedure starts again.If the system is not satisfied, thus predicting the occurrence of a spike within h, it is then necessary to compute the time t θ at which the threshold is crossed.This calculation, explained in Appendix A, is made by interpolation between the current state and time, and the state and time t max at which the membrane potential would reach its maximum if allowed to increase above threshold.Once t θ is calculated, a spike is emitted, communicated to the postsynaptic neurons, and the membrane potential is reset to V reset for a refractory period.When this refractory period is over the procedure starts again.
In the evolution loop just described, the membrane potential is reset to a value below threshold as soon as it crosses the latter.Thus no initial state can have V ⩾ θ.This means that the first inequality (44a) in the system is always satisfied and can be dropped.Only inequalities (44b) and (44c) have to be assessed, leading to the reduced system V < f h,Ie (I), We first discuss the case I e < I θ ≡ θC/τ .
The geometric meaning of the inequalities above is illustrated in Figure 5.The figure shows four regions: NS 1 , NS 2 , S 1 , S 2 .The no-spike region is the union of NS 1 and NS 2 , the spike region the union of S 1 and S 2 .In the figure they are separated by a thick line, partly curved and black, partly straight and blue.Subregion S 2 is particularly important: it is the region of missed spikes discussed in Section 3.4, corresponding to the self-intersection region of Figure 3, lower panel.It contains those states that lead to spikes missed by schemes that rely on the standard test (1).
Region S 1 is separated from S 2 by a dashed blue line, and from NS 1 by a continuous blue line, the continuation of the dashed one.This partly dashed, partly continuous blue line corresponds to the equation V = f h,Ie (I).Hence if the inequality V < f h,Ie (I) is not satisfied then the initial state is in region S 2 or on its blue boundary, and there will be a spike.If the inequality is satisfied the state could be in S 2 -spike -or NS 1 ∪ NS 2 -no spike; an undetermined case.This inequality requires modest computational costs because it is linear in I and I e and involves exponentials of h.Regions S 2 and NS 2 are separated by a black curve: this is the envelope, corresponding to the equation V = b Ie (I) for I ∈ I θ − I e , e h τs (I θ − I e ) .Hence if the inequality V < b Ie (I) is not satisfied the initial state is in S 2 or on its boundary, and there will be a spike.
If the inequality is satisfied the initial state is either in NS 2 , or in NS 1 with I θ − I e < I < e   47): V < g h,Ie (I) (dot-dashed straight purple line).The spike region is S 1 ∪ S 2 , the no-spike region is NS 1 ∪ NS 2 .The subregion S 2 contains all states that emit spikes undetected by the standard test (1); they are detected by the lossless method.
The computationally most expensive inequality is V < b Ie (I) because it involves irrational powers of I and I e .It is advisable to avoid its direct computation as often as possible by pre-testing a linear inequality.In Section 2.5 we discussed how such a pre-test is indeed possible thanks to the convexity of the no-spike region.There, we argued that the curved envelope can be approximated by triangular hypersurfaces, which simply reduce to one straight segment in the present two-dimensional case: this is the dot-dashed red line in Figure 5, separating NS 1 and NS 2 .This line has equation V = g h,Ie (I) with and the corresponding inequality has the same computational costs as V < f h,Ie (I).
If the auxiliary inequality V < g h,Ie (I) is satisfied, the initial state is in NS 1 and V < b Ie (I) is also satisfied.It is therefore convenient to test the auxiliary inequality before the computationally costly one, which can be discarded if the test is positive.Figure 5 suggests that this test might be positive for the majority of initial states because region NS 1 is much wider than NS 2 .This possibility would be very advantageous, but we now argue that it should be verified by a dynamical analysis.
The system (45) can be translated into a computational algorithm in several different ways, depending on the order of evaluation of its two inequalities and of the auxiliary inequality (47).In simplified terms, such an algorithm consists in a sequence of tests -variously implemented as if, and, or constructsfor finding the initial state in space-time regions R 1 , R 2 , and so on.The order of these tests is important.The average time cost of the algorithm in a long simulation is given by i p i c i , where p i is the frequency with which states are found in region R i , which we call "occupation frequency", and c i is the cumulative time cost of the test for region R i .This time cost c i is cumulative in the sense that all tests up to the (i − 1)th must have been performed, with false outcomes, to arrive at the test for R i .The efficiency of an algorithm therefore depends on the mathematical form of the inequalities defining a region and on the occupation frequencies of the regions, determined by the dynamics.These two factors can be extrapolated by a theoretical analysis, or more practically measured by running long test simulations with typical network setups corresponding to the cases one is interested in.
We now try to determine the most efficient algorithm for the present case.Region S 1 is the least costly, because bounded by one line and therefore involving one inequality linear in I; then region NS 1 , bounded by two lines involving two linear inequalities; and finally regions NS 2 and S 2 , bounded by the curve that involves rational exponentiation.For this example model, we tried different orderings but show here only two possible extreme cases to illustrate that there is no significant difference in the computational cost.
Algorithm 1 is based on the assumption that the occupation frequency of a subregion is proportional to that subregion's relative size.If we check the two largest first, in the order NS 1 , S 1 , S 2 , NS 2 , we are therefore more likely to exit the test in its first if branches.The value of g h,Ie is used in two if branches, so it is computed just once and saved before the if sequence in order to save some computations.
Algorithm 2 uses a composite or-and condition rather than several ifs.Assuming left-to-right evaluation, the algorithm corresponds to testing first S 1 (left side of or), then S 2 (right side of or), either case leading to a spike.If neither is true, no further tests are necessary because the state must necessarily be in the no-spike region.The test for S 2 is made less costly on average by using the auxiliary inequality (47).This algorithm uses one test less overall than the previous one, but it may require one more test on average, if NS 1 is the region with highest occupation frequency.The left-to-right evaluation assumption does not always hold in modern processors, which build their own statistics to optimize the test order of logical constructs.The analysis assumed I e < I θ ≡ θC/τ .The reduced system (45) and the Algorithm 1 and 2 are, however, also valid in the case that I e ⩾ I θ , corresponding to the lower panel of Figure 4.In this case subregions NS 2 and S 2 do not exist below the threshold, and the inequalities V < b Ie (I) and V < g h,Ie (I) are always satisfied when V < θ; they always evaluate to true in both algorithms.Both algorithms therefore correctly distinguish spiking from non-spiking states in this case, although they become inefficient owing to the additional superfluous evaluations of b Ie (I) and g h,Ie (I) for spiking states.We decide not to modify them in the present work because the case I e ⩾ I θ is unusual in real applications.More efficient algorithms for this case can be designed by interested readers following the guidelines just given in this section.

Occupation frequencies
We want to measure the occupation frequencies in the typical case of a neuron embedded in a recurrent network, receiving fluctuating synaptic input.The setup for this simulation is illustrated in Figure 6A and its formulae explained in Appendix B. One neuron is coupled with strengths J and −J to an excitatory and an inhibitory Poisson generator and also receives a constant external current.The Poisson generators each mimic an excitatory and an inhibitory population.The neuron thus receives a fluctuating input current having average µ and variance σ 2 .In this instance the code of the simulation includes a subroutine that informs us of the current state every time the lossless method test is called, without altering the test or the dynamics.
Figure 7A gives a visual idea of the occupation frequencies for µ = 15 mV, σ 2 = 25 mV 2 , and J = 0.1 mV (all expressed in volts through multiplication by a resistance of τ /C = 40 MΩ), which correspond to the case I e < I θ .These values correspond to a composite average input of 250 000 spikes/s, and a total average input current of 400 pA.This presynaptic input makes the neuron fire at an average rate of 7 spikes/s.A sample of its membrane dynamics is shown in Figure 6B.Subregion NS 1 has the overwhelmingly largest occupation frequency.The other three subregions have actually very small p Figure 7. (A) Frequency density of states over state space at each call of the threshold-crossing test, for network parameters µ = 15 mV, σ 2 = 25 mV 2 , J = 0.1 mV.The colourbar is in units of 6 × 10 9 mV −1 pA −1 (obtained from total number of events × area element).The dotted purple line is the threshold θ.The only visible region in this plot is NS 1 .and the horizontal blue line is the boundary between no-spike and spike regions.The spike region S 1 ∪ S 2 and subregion NS 2 are not visible on this scale because of the exceedingly small average timestep h = 4 × 10 −3 ms.To discern them we need to zoom in, as done in upper panel (B): the curved envelope and the two straight lines that separate S 1 , S 2 , and NS 2 extend horizontally and vertically for just about 1 pA and 10 −5 mV.(B) lower panel.In contrast, for a much larger timestep h = 5 ms the three boundaries would have a larger extension, about 5 500 pA and 20 mV, and be discernible in plot (A).
areas, as clear from the axis ranges of Figure 7B, owing to the very small value of the average timestep, h = 4 × 10 −3 ms, given by the inverse of the input rate in this hybrid scheme.
A more precise comparison of the occupation frequencies of the four regions N S 1 , N S 2 , S 1 , S 2 is shown in Figure 8 for several combinations of three network parameters, producing different dynamic regimes.The parameters are the average µ, the variance σ 2 of the input current, and the presynaptic coupling strength J (all expressed in volts through multiplication by a resistance of τ /C = 40 MΩ).The values of the parameters (µ, σ 2 , J) include typical realistic cases as well as some extreme cases, like unusually high coupling strengths.Each panel of Figure 8 shows the occupation frequencies for a set of dynamical regimes with constant J, β and several σ 2 .The panels in the last row correspond to the case I e ≡ µC/τ ⩾ I θ ≡ θC/τ , or µ ⩾ θ, in which subregions NS 2 and S 2 do not exist below threshold.
It is important to remember that the boundary and size of the regions of Figure 5 vary with the timestep h, which is a parameter of the simulation scheme, not of the dynamics per se.In an event-driven or hybrid scheme, this step varies inversely with the event input rate, which for Poisson input generators is proportional to σ 2 /J 2 .As a consequence, the frequencies displayed in Figure 8 are not determined by the Liouville distribution of the dynamics (26) alone, but also by the details of the numerical-implementation scheme.The dependence of the boundaries on h is illustrated in Figure 7B.As h decreases, the line V = f h,Ie (I) and the auxiliary line V = g h,Ie (I) gets closer to the threshold, and the subregions S 1 , S 2 , NS 2 disappear.This is plausible since in the limit of h = 0 we are not evolving the initial state at all.As h increases the point of tangency between the envelope V = b Ie (I) and the line V = f h,Ie (I) moves to increasingly lower voltages and higher currents; subregion S 2 takes over S 1 and subregion NS 1 becomes wider.For typical timestep values of several milliseconds, though, subregions S 1 , S 2 , NS 2 are still very small.
A rough estimate of the dependence of the areas of the bounded regions S 2 and NS 2 on the parameters (µ, σ 2 , J), for µ < θ, can be obtained by looking at Figure 8 (49) When τ s ≲ τ and J 2 ≲ σ 2 a Taylor expansion in J 2 /σ 2 to fourth order gives a good approximation, with a relative error below 10 %: This approximate formula shows that subregions NS 2 and S 2 grow with the square of the input mean µ and with the third or fourth power of the ratio J 2 /σ 2 .Recall that these regions do not exist for µ ⩾ θ.The occupation frequencies do not depend on the areas alone, however, but also on the dynamics, as explained in the previous section.We can identify several other dynamical mechanisms for their dependence on the parameters (µ, σ 2 , J): • an increase in mean input µ leads to more frequent threshold crossings, thus frequently bringing the voltage to its reset value, underneath subregions NS 2 and S 2 .The occupation frequencies of these subregions may therefore decrease with µ even though their areas grow with µ; • for low mean input µ, an increase in variance σ 2 means a higher chance of high-V regions, and thus an increase in the occupation frequencies of NS 2 and S 2 , even though their areas shrink with σ 2 ; • for mean input µ close to the threshold, an increase in the variance σ 2 leads to more frequent threshold crossings, and may thus increase occupation frequency of S 2 with σ 2 , even though its area shrinks with σ 2 .
The occupation frequency of subregion NS 1 (green circles) dominates all others, varying from 90 % to 100 % depending on the network parameters.Subregion S 1 (yellow crosses) follows in order of frequency and is the most frequently visited between the two spike subregions.Subregions NS 2 (blue squares) and S 2 (red stars) are scarcely visited for lower synaptic amplitudes, with frequencies from 0 to 10 −6 ; and slightly more often at higher synaptic amplitudes (frequencies from 0 to 10 −2 ).

Time performance and accuracy of a hybrid scheme based on the lossless method
The average time costs of Algorithm 1 and Algorithm 2 within a hybrid scheme can be assessed by real-time simulation measurements.The average time cost of a hybrid scheme based on the standard test (1) can also be assessed in the same way for comparison.We therefore compare the two algorithms of the lossless method and the sufficiency test in this section.  .Occupation frequencies of the four subregions NS 1 (green circles), S 1 (yellow crosses), NS 2 (blue squares), S 2 (red stars) of Figure 5, for various sets (µ, σ 2 , J) of input-current mean and variance, and synaptic strength.Each panel shows the frequencies vs current variance for fixed current mean and synaptic strength.The columns have the same J, ranging from 0.1 mV (leftmost) to 5 mV (rightmost).The rows have the same µ, ranging from 10 mV (top) to 22 mV (bottom).The frequencies were measured from N samples, depending on (µ, σ 2 , J).The dotted lines in each plot show the inverse number of samples 1/N for that network regime.The thickness of the segments connecting the data points equals one standard deviation.The shaded regions show where the limiting frequencies (N → ∞) are expected to lie with 87 % probability, using a Johnson-Dirichlet model with parameter k = 0.05 determined by posterior maximization (Johnson, 1932;Zabell, 1982;Good, 1966;Bernardo and Smith, 2000, § 3.2.5).The frequencies of region S 2 (red stars) are particularly important: they are the frequencies of spike-misses of the standard test (1).
The basic setup is the same as for the frequency analysis of 3.5.1,explained in Appendix B, with network parameters (µ, σ 2 , J).The only difference is that in the present case the code does not include the subroutine that informs us of the frequencies, which would otherwise increase and bias the real-time durations of the simulations.Three instances of the basic setup are prepared: in the first the neuron is modelled by a hybrid scheme with lossless method Algorithm 1, in the second the neuron is modelled by a hybrid scheme with lossless method Algorithm 2, and in the third the neuron is modelled by a hybrid scheme with the standard threshold-crossing test (1).The various random-number-generator seeds of the three instances are exactly the same, so that the three neurons receive exactly the same input, spike-for-spike; this is essential for a fair comparison between the three schemes.The three instances are run for a long time (2 × 10 6 ms) and repeated (in parallel) for several times (10), enough to collect reliable statistics.The statistics are collected for the same sets of (µ, σ 2 , J) values as in the frequency analysis.The total real-time length of a simulation depends, in all three schemes, on how often the checkpoints and threshold-crossing tests occurs, and this in turn depends on the presynaptic input frequency, as already discussed.
Rather than showing the results for all sets of parameters (µ, σ 2 , J), which in this case are not very informative, we show in Figure 9 those with the (J, µ) values that yield the slowest and fastest performances.The average computation costs of Algorithm 1 and Algorithm 2, which embody the lossless method, turn out to be very similar -within each other's standard deviations -and basically identical in comparison with the cost of the scheme based on the standard test (1).Both are slower than the hybrid scheme with the standard test: from around 33 % slower in the case of high-activity regime with frequent incoming spikes (µ = 18 mV, J = 0.1 mV), to around 8 % slower in the case of low activity regime and infrequent incoming spikes (µ = 10 mV, J = 5 mV).These are the extremes shown in Figure 9.In most other sets of network parameters the hybrid scheme with lossless method was around 20 %-25 % slower than the standard hybrid scheme with threshold-crossing test (1).
As mentioned in 3.4, subregion S 2 contains all states for which the standard threshold-crossing test misses a spike.The occupation frequencies of this subregion are therefore a direct measure of the number of spike missed, per neuron, by the standard hybrid scheme.They are shown as red stars in Figure 8 for the various sets of network parameters (µ, σ 2 , J).The frequency of missed spikes does not have a simple monotonic dependence on the three parameters, owing to the interaction of several mechanisms, discussed in Section 3.5.2.An increase in synaptic coupling J or input current µ generally leads to more frequently missed spikes because the neuron spikes more often overall.For very high -suprathresholdinput currents, however, the frequency decreases again until no spikes are missed anymore; this change in trend happens because the checkpoints become more frequent.Regimes of low J are diffusion-like processes, where frequent arrival of synaptic events does not lead to missed spikes.Regimes of high J are shot-noise processes, where sudden and infrequent arrival of synaptic events leads to suprathreshold excursions and missed spikes.Separate simulations show that the hybrid scheme based on the lossless method, with either algorithm, reproduce the analytic solution of the neuron model within floating point precision.
For biologically realistic synaptic couplings, J < 1 mV, the standard hybrid scheme is 33 % faster than the scheme with the lossless method, and misses less than 1 spike every 10 6 test calls, per neuron; for very low couplings J < 1 mV this figure even becomes less than 1 spike every 10 8 test calls.For synaptic couplings J > 1 mV the standard hybrid scheme starts to miss more spikes, reaching even 1 missed spike every 500 test calls for subthreshold average input currents; and it is only 8 % faster than the hybrid scheme with the lossless method.From these figures a user can decide to use the hybrid scheme with the standard or the lossless test, depending on the desired balance of accuracy and speed.
(mV) Figure 9. Computational costs of the hybrid scheme with lossless method, Algorithm 1 (red), lossless method, Algorithm 2 (green), and standard threshold-crossing test (1) (blue).(A) µ = 18 mV, J = 0.1 mV describes regimes where the lossless method has the highest increase in computational cost, around 33 %.These are regimes of high activity and frequently incoming spikes.(B) µ = 10 mV, J = 5 mV describe regimes where the lossless method has the lowest increase in computational cost, around 8 %.These are regimes of low activity and infrequently incoming spikes.The data come from 10 simulations of 2 × 10 6 ms simulation-time each.

SUMMARY AND DISCUSSION
We here present a general method to solve the threshold-crossing detection problem for an integrable, affine or linear neuronal dynamics.The method is based on the geometric idea of propagating the threshold plane backwards in time and to determine whether the swept volume contains the initial state, rather than propagating the initial state forward in time to check whether it crosses the threshold.These two procedures are obviously mathematically equivalent, but they distribute the computational load in different ways.The forward-propagation of the state looks for the value of the crossing time; if no such value exists, it means there is no threshold crossing.The backward-propagation of the threshold first tests whether a crossing time exists at all, without yielding its value; the latter is calculated afterwards.
The different distribution of computational load in the two procedures can be explained geometrically and algebraically.The first procedure geometrically checks for the intersection of a curve (the state trajectory) with a hypersurface (the threshold).Algebraically, this corresponds to finding the roots of a system of equations, often transcendental.The second procedure geometrically checks for the "intersection" of a point (the state) with a hypervolume (the threshold trajectory), i.e. the inclusion of the former in the latter.Algebraically, this corresponds to testing a set of inequalities.The latter procedure is more efficient for numerical computations, because it only relies on inequality tests -in which the presence of transcendental functions is much less costly than in an equation that needs to be solved for a particular variable.The determination of the exact crossing-time, which involves bisection algorithms and is the costlier part, is done only when the existence of this value is certain.No root search is unnecessarily performed.
We have calculated the system of inequalities expressing the threshold-crossing condition, for a generic affine or linear neuronal dynamics in any dimension.The result is the conjunction of inequalities (23).It consists of two affine linear inequalities in the state-space variables, voltage and currents, and a nonlinear one.The numerical implementation of this system of inequalities can be further optimized, on a case-by-case basis.In order to give a concrete implementation example of the generic inequalities (23), to show their geometrical meaning, and to give an example of optimization,in the present work we apply our procedure, step-by-step, to the 2-dimensional case of a leaky integrate-and-fire neuron with exponentially decaying post-synaptic currents (Rotter and Diesmann, 1999).The generic inequalities (23) take in this case the concrete form (44).
The quantitative data in the present work are obtained by integrating these inequalities into a combined event-and-time-driven simulation framework (Morrison et al., 2007) for large-scale spiking neuronal network models as released by Bos et al. (2015).Implementation and comparison to earlier work show that: • the system of inequalities, the non-linear one in particular, can be expressed analytically in terms of the state-space variables even when the original threshold-crossing condition involves a transcendental equation -and would therefore require bisection algorithms.Compare ( 44) with (30); • the computationally expensive non-linear function in the system can be conveniently triangularized, speeding up the algorithm even further by testing a linear inequality first, ruling out the majority of initial states; • the new method reproduces the analytic solution of the neuron model within floating point precision.
It detects all threshold crossings, in particular those that the approximate test (1) of Hanuschkin et al. (2010), misses in some ranges of mean activity, fluctuations, and synaptic-coupling strength (Figure 8); • at the default spike accuracy of 0.1 ms of the reference simulator the new method is 8 %-33 % slower than the fastest available solver with spike loss (Hanuschkin et al., 2010).It is therefore of comparable speed as embedded event driven methods (see Hanuschkin et al. (2010) Fig 5, inset).
In practice the method of Hanuschkin et al. (2010) rarely misses spikes for biologically realistic synaptic amplitudes.At low frequencies of afferent synaptic events, however, such missed threshold-crossings can happen.Our new scheme therefore offers an alternative for users who need guaranteed spike detection and are willing to pay a price in terms of slightly longer computation time.
In state-spaces of higher dimensions it is be more difficult to derive the non-linear inequality of the system (23) in implicit form, but its set of approximating flat surfaces can still be easily calculated.In the worst-case scenario of an inequality not expressible analytically, it is still possible to construct a nested sequence of approximating flat surfaces to be tested hierarchically.Such construction only needs to be done once for any given model and detects spikes with any desired precision.Being linear, such nested inequalities likely are computationally less expensive than a bisection algorithm.
The problem of detecting some sort of threshold crossing in a system of coupled first-order linear differential equations appears in many other applications and phenomena like switching, friction, and saturation (Hiebert and Shampine, 1980).For example, in an air-conditioning unit a thermostat controls the on-off state based on a certain threshold value of the room temperature (Shampine, 1994).The dynamics of this system is similar to that described in Sections 3.1-3.2.Another example is the problem of ejecting a pilot such that collision with the aircraft stabilizer is avoided.
The present work use concepts from differential geometry, in particular extrusions (Bossavit, 2003) and critical points of maps between manifolds, and shows that these concepts have a readily understandable geometrical and visual meaning.The notion of extrusion has recently found applications in numerical and discretization techniques for partial and integral differential equations (Desbrun et al., 2005).The notion of critical points of a manifold mapping is ubiquitous in science: from the caustics of propagating seismic fronts, at which the seismic wave changes its phase (Romanowicz and Dziewonski, 2007, § 1.04), to the singularities between two coordinate charts in general relativity (Misner et al., 2003), which affect the accuracy of global navigation satellite systems (Coll et al., 2012;Sáez and Puchades, 2013).
Indeed, the neuron model analysed in Section 3 exhibits a similarity with the dynamics of a point mass near a black hole.If the simulation timestep h is very large the curved surface separating the states that lead to a spike from those that do not acts like an event horizon in general relativity: a state evolved from the spike region can enter the no-spike region, but once there it cannot escape and will always remain a "no-spike" state.This is only true for the dynamics (6), though, with constant affine term and no resets at threshold.Inputs from other neurons lead to discontinuous changes in the affine term of the dynamics, causing a "transport" of initial states out of the event horizon, from the no-spike to the spike region.Nevertheless, maybe such similarities are more than mere coincidences.For example, the trajectory of the threshold surface of a leaky integrate-and-fire model with α-shaped post-synaptic currents (Bernard et al., 1994) can be implicitly expressed in terms of the Lambert-W function (Corless et al., 1996), as an analysis along the lines of Section 2.2 shows.This function also appears in the implicit expression of point-mass trajectories in (1 + 1)-dimensional general relativity (Mann and Ohta, 1997).It is surely worthwhile to bring the nascent field of neuronal dynamics closer to ideas and techniques from differential geometry and general relativity. θ

Figure 4 .
Figure 4. System of inequalities, eq.(44), determining the no-spike region.The colored areas represent the complementary inequalities of the system (44), so the solution of that system is the white area.The red region delimited by the horizontal line corresponds to the first equation of the system, the blue region delimited by the inclined line to the second, and the yellow region delimited by the curved line to the third.Upper panel: case I e < I θ , all inequalities necessary.Lower panel: case I e > I θ , the third inequality is redundant.
h τs (I θ − I e ), and no spike will occur.

Figure 5 .
Figure5.State-space subregions formed by the intersections of the reduced inequalities (45): V < f h,Ie (I) (straight blue line, partly dashed partly continuous) and V < b h (I) (black curve), and by the auxiliary inequality (47): V < g h,Ie (I) (dot-dashed straight purple line).The spike region is S 1 ∪ S 2 , the no-spike region is NS 1 ∪ NS 2 .The subregion S 2 contains all states that emit spikes undetected by the standard test (1); they are detected by the lossless method.

Figure 6 .
Figure 6.(A) Schematic of the simulation setup used to calculate occupation frequencies and to compare the hybrid scheme with lossless method Algorithm 1, with lossless method 2, and with the standard test.The neuron model (empty red circle), implementing one of the three schemes, receives input from an external current and from one excitatory (E) and one inhibitory (I) Poisson generator.The total input has mean µ and variance σ 2 .(B) Sample of membrane-potential dynamics for µ = 15 mV and σ 2 = 25 mV 2 .
and considering that these areas together form a triangle with vertices (I θ − I e , θ), e h/τs (I θ − I e ), b Ie [e h/τs (I θ − I e )] , (I f , θ), with I f such that f h,Ie (I f ) = θ.(48) This triangle has base |I f − (I θ − I e )| and height |θ − b Ie [e h/τs (I θ − I e )]|.Expressing h and I e in terms of µ and σ 2 using eqs (53), where h is inversely proportional to the input rate r I + r E , we find areas of S 2 and NS 2

Figure 8
Figure8.Occupation frequencies of the four subregions NS 1 (green circles), S 1 (yellow crosses), NS 2 (blue squares), S 2 (red stars) of Figure5, for various sets (µ, σ 2 , J) of input-current mean and variance, and synaptic strength.Each panel shows the frequencies vs current variance for fixed current mean and synaptic strength.The columns have the same J, ranging from 0.1 mV (leftmost) to 5 mV (rightmost).The rows have the same µ, ranging from 10 mV (top) to 22 mV (bottom).The frequencies were measured from N samples, depending on (µ, σ 2 , J).The dotted lines in each plot show the inverse number of samples 1/N for that network regime.The thickness of the segments connecting the data points equals one standard deviation.The shaded regions show where the limiting frequencies (N → ∞) are expected to lie with 87 % probability, using a Johnson-Dirichlet model with parameter k = 0.05 determined by posterior maximization(Johnson, 1932;Zabell, 1982;Good, 1966; Bernardo and Smith, 2000,  § 3.2.5).The frequencies of region S 2 (red stars) are particularly important: they are the frequencies of spike-misses of the standard test (1).