Dynamic imaging of intracellular calcium is commonly used to record changes in excitability in central and peripheral neurons. We describe a novel analytical methodology that objectively discriminates calcium transients from low signal-to-noise recordings from multiple sites and quantifies the degree of temporal synchrony between events. These new methods can be applied not only to calcium imaging but also to many other physiological recordings where discrimination and temporal correlation of biological signals from multiple sites is required.
Keywords: calcium transient, peripheral axons, spike detection, temporal correlation
Abstract
Calcium imaging is commonly used to record dynamic changes in excitability from axons or cell bodies in the nervous system of vertebrates. These recordings often reveal discrete calcium transients that have variable amplitudes, durations, and rates of rise and decay, all of which can arise from an unstable or “noisy” baseline. This often leads to considerable ambiguity about how to discriminate and quantify calcium transients. We describe an analytical methodology that objectively identifies multiple calcium transients from multiple recording sites and quantifies the degree of temporal synchrony between each event. The methodology consists of multiple steps. The first step involves baselining, to either preserve the underlying shape of calcium transients or remove unwanted frequency components and transform the peaks of calcium transients into more easily detectable patterns. The second step is the application of at least one of two different spike detection algorithms, one based on a gradient estimate and the other on template matching. The third step is the quantification of synchrony between pairs of recordings using at least one of two time lag correlation measures. The fourth step is the identification of statistically significant coincident firing patterns. This allows discrimination of neuronal firing patterns between different sites that appear to occur simultaneously and that statistically could not be attributed to chance. The analytical methods we have demonstrated can be applied not only to calcium imaging but also to many other physiological recordings, where discrimination and temporal correlation of biological signals from multiple sites is required, particularly when arising from unstable baselines, with variable signal-to-noise ratios.
NEW & NOTEWORTHY Dynamic imaging of intracellular calcium is commonly used to record changes in excitability in central and peripheral neurons. We describe a novel analytical methodology that objectively discriminates calcium transients from low signal-to-noise recordings from multiple sites and quantifies the degree of temporal synchrony between events. These new methods can be applied not only to calcium imaging but also to many other physiological recordings where discrimination and temporal correlation of biological signals from multiple sites is required.
calcium imaging of nerve dendrites, axons, or cell bodies is a common method to quantify excitation dynamics in the central and peripheral nervous systems. Calcium fluxes within cells manifest as changes in fluorescence when fluorescent calcium indicators are used. These changes in fluorescence observed during calcium imaging are called calcium transients. Calcium transients within nerve cells due to action potentials are graded and subject to greater variability than membrane potential changes associated with action potentials. This has limited their use for investigation of activity within complex neural circuits. A major problem facing investigators is how to reliably identify calcium transient peaks in recordings that have low signal-to-noise ratios. A significant advantage of calcium imaging over other neurophysiological recording techniques is that multiple neurons can readily be recorded simultaneously. However, this gives rise to a second major problem, which is how to determine the degree of temporal correlation of calcium transients in axons or nerve cell bodies from multiple sites.
When signals are discrete and easy to detect, such as large calcium peaks or action potentials, then analytical approaches that use spike timings or time series are appropriate to analyze the temporal correlation of multiple signals. Perhaps the most common of such approaches is the cross-correlogram, which essentially histograms the differences in spike timings. Much work has been done to estimate the statistical distribution of the cross-correlogram under different conditions. For example, if the spike trains are assumed to be independent homogenous Poisson processes, then the cross-correlogram is asymptotically normal (Windhorst and Johansson 1999). Other approaches use resampling and/or spike shuffling schemes (Schwindel et al. 2014), where such a technique is applied to a scenario with low firing rates and a long collection time. Despite the extensive work done to estimate the distribution of the cross-correlogram, there exist scenarios where such approximations are inappropriate. An example of such a case would be when the errors in the spike timings are large, which could be due to low signal-to-noise ratios or ambiguous spike shapes. Another case is when the recordings consist of a small number of spikes. One preparation where these conditions commonly occur is that of the enteric nervous system, where neural circuits involved in controlling many intestinal functions can be studied. Intact preparations of the intestine with its functioning enteric neural circuits have been used extensively to study neural control of intestinal functions, either by recording electrophysiologically from single enteric neurons or by recording mechanical or electrical activity of the muscle layers. Whereas calcium imaging is ideal for simultaneous recordings from multiple neurons and nerve fibers in complex neural systems, there are no ready-to-use and reliable methods to analyze such signals recorded at multiple sites.
Recently, we recorded discrete calcium transients along multiple varicosities along single spinal afferent axons in isolated whole mouse colon (Travis and Spencer 2013). In these preparations maintained under circumferential stretch, multiple single varicosities discharged in what appeared to be a simultaneous fashion at multiple varicosities along a single axon (Travis and Spencer 2013). Although it may appear from a lay perspective that many of the varicosities discharge simultaneously, a number of analytical concerns can arise with calcium imaging of this nature. For example, the baseline of calcium fluorescence recordings are often unstable, with some degree of background noise. Also, continuous illumination of tissues generates a constant decay in baseline fluorescence as the duration of continuous illumination increases. Additionally, discrete calcium transients can be of different waveforms at different regions of interest, even within the same axon or cell body. They can often have indistinct peaks, with different rates of rise and decay, different durations, and different signal-to-noise ratios. This can make unambiguous identification of calcium transients due to action potentials problematic.
In this study we present two methods to identify unambiguous peaks of calcium transients and two ways to investigate the degrees of temporal synchrony, based on timings of the identified peaks. We also have developed a method to estimate degrees of synchronization when spike timings are ambiguous or spike occurrences are infrequent. The methods described were developed on recordings of calcium transients obtained in experiments using open, flat preparations of mouse colon with intact nerve terminals. The methods can be potentially applied to data obtained from other biological systems, where peak detection and timing correlations between peaks are sought.
MATERIALS AND METHODS
Protocol for Calcium Imaging in Nerve Axons in the Colon
Mice (30–90 days old) of either sex were euthanized humanely by inhalation of anesthetic (1 ml/l isoflurane) followed by cervical dislocation, in accordance with the use and treatment of animals as approved by the Animal Welfare Committee at Flinders University of South Australia. The entire colon was removed from the pelvic cavity and placed in oxygenated Krebs solution. A midline incision was made along the mesenteric border and the longitudinal muscle dissected away from half of the myenteric plexus by sharp dissection, ensuring no damage to the enteric nervous system. The entire preparation was pinned circular muscle down in a Sylgard-lined petri dish containing oxygenated Krebs-Ringer buffer (KRB; see composition below) at room temperature.
The preparation was incubated with fluo 4-AM (Molecular Probes, Eugene, OR) for 20 min at room temperature, during constant bubbling with oxygenated Krebs solution. After the loading procedure, the preparation was perfused with warmed Krebs solution at 36°C, to allow for de-esterification. Nifedipine (1 μM) was present in all experiments to paralyze smooth muscle action potentials and facilitate imaging from nerve endings. The imaging setup consisted of a Nikon Eclipse 50i upright microscope fitted with epi-fluorescence FITC filter cubes with excitation and emission wavelengths of 492 and 520 nm, respectively. Fluo 4-AM has a peak excitation at 485 nm and peak emission at 525 nm. The relative changes in fluorescence were recorded in enteric nerve axons as a consequence of continuous fluorescent illumination of the colon using an FITC wavelength of light. For all imaging experiments on nerve endings, water-immersion (×10, 0.3 W; ×20, 0.5 W; and ×40 Fluor, 0.8 W) lenses were used, where the working distance of each lens varied from 3.5 to 2.0 mm, respectively. An electron-multiplying charge-coupled device (EMCCD) camera (Delta Evolve; Roper Scientific, Tucson, AZ) was used to record dynamic changes in fluorescence activity in the varicosities and fine nerve axons in myenteric ganglia. Data were acquired at 70 Hz. All imaging data were acquired using Imaging Workbench (version 6.0; INDEC BioSystems, Santa Clara, CA).
Background to Methods
A number of methods have been developed to describe temporal correlation of biological signals (see e.g., Brown et al. 2004). Perhaps the most commonly cited approach using spike timing is the cross-correlogram (see Windhorst and Johansson 1999). The cross-correlogram essentially represents the lags between spike timings as histograms: if two spike trains are synchronized, then the maximum of the cross-correlogram will occur at time lag zero. A similar spike-time lag histogram method is the joint peristimulus time histogram (see Gerstein and Perkel 1969). One advantage of the cross-correlogram and the joint peristimulus time histogram is that their statistical properties are well understood under certain regularity conditions.
A range of approaches exist that do not use spike timings. A number of techniques use some measure of the relationship between two time series at different time lags. The simplest technique is the standard cross-correlation function, which for two sets of time series, {yi(k1)}i=1R and {yi(k2)}i=1R are estimated using the following equation:
If the two recordings are synchronized, then we expect a large peak near p = 0. The cross-correlation is a measure of linear relationship. There also exist a number of nonlinear measures of relationship that can be found in the neuroscience literature. We implemented the nonlinear cross-correlation found in Pereda et al. (2005) and three different estimates of mutual information (empirical histogram, kernel density estimation, and Hermite polynomial expansion). However, for our data, none of these other approaches gave consistent results, whereas the standard cross-correlation function proved to be very reliable.
Many methods like the ones described above take two time series and compute a single measure. Moreover, they do not focus on individual spike firing patterns. An approach that considers more than two time series and considers coincident firing patterns is unitary event (UE) analysis. The version as described in Grün and Rotter (2010) estimates the probability that a particular subset of neurons fire coincidently at least N times over a particular interval, under the assumption that the neurons fire independently and the firing for each neuron is a homogeneous Poisson process. If a subset of neurons have fired coincidently at least N times and the estimated probability of this is less than some user-defined level α, then the firings are deemed statistically significant; that is, they could not have fired coincidently by chance.
Our Method for Analysis
The methods described in this article were implemented in MATLAB R2012b by the first author (J. Sorensen). In the Supplemental Data, we have included a .zip file that can be downloaded. (Supplemental Data for this article is available online at the Journal of Neurophysiology website.) The file includes MATLAB code that implements the techniques described in this article. Also included in the .zip files are four sets of data that the code can be run on.
To quantitatively analyze the calcium transients, it is necessary first to identify discrete calcium transient peaks. This then allows us to investigate degrees of temporal synchrony within the calcium transient discharges that occur in either single or multiple nerve axons and cell bodies.
The methods used to achieve this consisted of the following:
-
1)Baselining: Two techniques were used to stabilize the baseline, the first being a median filter and the second a finite impulse response (FIR) bandpass filter. Both have different advantages and disadvantages:
-
a)Median filter: The median filter removes the baseline without distorting spike shapes. Also, for the data considered with no activity, we found that the median-filtered data were uncorrelated, that is, the median filter did not induce correlation. As will be shown, this observation was crucial for the derivation of a thresholding method. However, the median filter does not remove higher frequency noise components.
-
b)FIR bandpass filter: The FIR bandpass filter removes unwanted frequencies, that is, frequencies at which synchrony does not occur. Also, it often transforms the calcium transient peaks into more easily detectable patterns. However, picking the correct frequency bounds requires care.
-
a)
-
2)Spike detection: Two spike detection schemes were used, the first being an estimate of gradient and the second template matching, or more specifically:
-
a)Gradient: The gradient measure is identification of spikes whose difference between peak and trough is larger than that of spikes due to background noise.
-
b)Template matching: Template matching is the correlation of a small set of templates against FIR bandpass filtered data, where templates have been chosen to represent the shape of spikes after FIR bandpass filtering.For both baselining and spike methods, thresholding is required. We describe two methods. The first thresholding method is used for both the gradient measure and the template matching method. The second thresholding method is used only for the gradient measure. This second thresholding method is based on the statistical distribution of the gradient measure under the assumption that the noise present in baselined data is an independent and identically distributed (IID) Gaussian process. Although this assumption may seem unrealistic, we found that it holds for the median-filtered data where no activity is present.
-
a)
-
3)
Pairwise measures of synchrony: Two pairwise measures of synchrony were used, the first being the cross-correlogram function and the second the cross-correlation function. Both attempt to measure the relationship between two recordings at different time lags. For both measures, we are interested in whether the measure is maximized at a time lag of zero and whether the measure is statistically significant at time lag zero. We do not expect either of the measures to be maximized exactly at a time lag of zero. However, we do expect the time lag to be significantly less than the average time between peaks: if the time lag at which the measures are maximized is significantly less than the average time between peaks, then it is reasonable to conclude that the recordings are temporally synchronized.
Our preferred measure is the cross-correlogram, for two reasons. The first reason is the incorporation of noise not removed by filtering into the cross-correlation calculation. This is not an issue for the cross-correlogram: the cross-correlogram is calculated using spike trains, which apart from false detections do not contain noise. The second reason is differing spike shapes: two recordings may have calcium transient peaks at identical locations, but the shape of peaks between the two recordings may differ, which will reduce the value of the cross-correlation. However, there are times when the cross-correlogram is inappropriate. The two measures work as follows:-
a)Cross-correlograms: The cross-correlogram essentially represents the spike timing differences between two recordings as a histogram. If two recordings contain a large number of coincident peaks, the cross-correlogram should have a peak close to zero.
-
b)Cross-correlation: The cross-correlation essentially calculates the correlation between two time series at different time lags. This measure does not use spike timings and hence is useful when the cross-correlogram cannot be used because of ambiguous spike waveforms. Moreover, when there exist a small number of spikes, the confidence bounds for the cross-correlation function are more likely to be accurate than those for the cross-correlogram, because they are based on more data points. However, the cross-correlation function is degraded by poor signal-to-noise ratio. Also, as will be illustrated later, the cross-correlation function cannot be applied directly to raw data; it must be applied to either median-filtered data or FIR bandpass-filtered data.
-
a)
-
4)
UE analysis: UE analysis is a method used to estimate the probability that a particular coincident firing pattern can occur at least N times. If this probability is below a specified level α, the pattern is considered statistically significant; otherwise it is considered statistically insignificant.
Baselining Technique
Two baselining techniques were used, the first being a median filter and the second an FIR bandpass filter. A median filter runs a window over a time series and subtracts the median for each window instance. An FIR bandpass filter also runs a window over a time series, but instead takes a weighted sum that removes frequency components that fall outside a user-defined frequency range (see Fig. 1). To describe mathematically how these filters are implemented, let {xi(k)}i=1R denote R raw data points for a recording, where the recording index superscript (k) will be omitted for brevity in all sections that can be applied independently to each recording. The median filter acts on the raw data as follows:
Fig. 1.
A shows an example of 6 simultaneous raw recordings where the spike timings are widely spaced. B and C show the same recordings baselined with the median filter and FIR bandpass filter, respectively. D shows an example of 4 simultaneous raw recordings where the spike timings are relatively close in time. E and F show the same recordings baselined with the median filter and FIR bandpass filter, respectively.
where median{xl}l=i−Li+L is simply the median of the 2L + 1 data points contained within the brackets. The FIR acts on the raw recording according to the following equation:
where M is the length of the filter and {fj}j=0M−1 are the filter coefficients. In our analysis, the filter coefficients were generated by the MATLAB function fir2 using a Blackman window.
Both filters have advantages and disadvantages. The median filter baselines the data without distorting the underlying shape of the calcium transient peaks or smearing closely spaced peaks, whereas a FIR bandpass filter removes unwanted higher frequency noise components at the expense of distorting the underlying shape of peaks of calcium transients. This can be seen in Fig. 2, where A shows three simultaneous raw recordings, B shows the result of a median filter, and C–F show the results of four different FIR bandpass filters, where the lower and upper bounds of the filters are given by the numbers contained within square brackets. The median filter has not distorted the underlying shape of the peaks of calcium transients, whereas the FIR bandpass filter has removed higher order frequency components and distorted the calcium transient peaks so that they resemble an elongated “S.” The level of distortion depends on the upper bound of the filter: the lower the upper bound, the higher the degree of distortion.
Fig. 2.
A shows 3 simultaneous raw recordings. B shows the data baselined with a median filter. C–F show 4 examples of the FIR bandpass filter where the upper frequency bound of the filter is decreased from C to F. The numbers in square brackets give the lower and upper bounds (in Hz) of the filter, respectively. The point of B is to show the shape of the original peaks and the noise level present. C–F show the effect of reducing the upper bound of the filter; that is, the noise is reduced as the upper frequency bound is reduced while at the same time, the shape of the spikes are increasingly distorted.
Bandpass filtering has some advantages. As mentioned, it removes higher frequency noise components while transforming the calcium transient peaks into something that resemble an elongated S. This elongated S is often easier to detect than the corresponding peaks in the raw data. Another advantage of the filter is that it produces cross-correlations that decay quickly away from a time lag of zero. To illustrate, consider Fig. 3, where A2–C2 show the cross-correlation applied to three pairs of raw recordings, A3–C3 show the cross-correlation applied to the same pairs of data with a median filter applied, and A4–C4 show the cross-correlation applied to the same pairs with a bandpass filter applied. In all three cases, the cross-correlation decays most quickly for the bandpass filtered data.
Fig. 3.
Three examples of the filter bank approach are shown in A1, B1, and C1, respectively. Each row in these plots shows the cross-correlation applied to data that have been filtered with a narrowband filter of width 0.5 Hz, where the center frequency of the filter is indicated on the Y-axis. A2, B2, and C2 show the cross-correlation applied to the corresponding raw recordings used to generate plots A1, B1, and C1, respectively. Similarly, A3, B3, and C3 show the cross-correlation applied to the median-filtered data, and A4, B4, and C4 show the cross-correlation applied to FIR bandpass filtered data, where the bounds of filters are given in square brackets. A1, B1, and C1 show that between 0 and 2 Hz approximately, the cross-correlation function decays slowly away from a time lag of 0, whereas between 2 and 5 Hz approximately, the cross-correlation function decays quickly. Moreover, in these cases the cross-correlation is small after 5 Hz.
Guidelines for Deciding Window Width
The choice of window width for the median filter is important. If the window is too short, the calcium transient peaks will be removed, whereas if the window is too long, the slow-moving trend will not be removed. Experimentally, we found that a window width two to four times longer than the maximum duration (once returned to baseline) of a discrete calcium transient worked well.
The choice of window width for the FIR bandpass filter is not as critical as that for the median filter. We do need the filter length to be of a minimum size to excise the frequencies not included in the bounds. However, increasing the length of the filter beyond this point will only improve the performance of the filter. A general rule for the minimum length is as follows. The coefficients for an FIR filter are symmetric and decay away from the center: we choose the length of the filter so that the coefficients have decayed close to zero.
Methods to Determine the Bounds for FIR Bandpass Filter
Two FIR bandpass filters were employed. The bounds of the first filter were chosen to produce data that can be used for template matching, that is, so that the slow decay of calcium transient peaks is removed, with a resultant waveform resembling something that looks like an elongated S. This was done simply by visual inspection of the filtered data. The second filter was used to produce data for cross-correlation. A more nuanced approach was taken to determine the bounds of this filter. We were interested in the frequencies at which synchrony occurs for pairs of recordings that are clearly visually synchronous, that is, for pairs of recordings where the majority of calcium transient peaks are time aligned. Moreover, we wanted to know if there exists a continuous band over which the synchrony occurs. To do this, we used a filter bank approach. In explanation, consider Fig. 3, which shows three examples of the filter bank approach in A1–C1. Each row in these plots shows the cross-correlation applied to data which have been filtered with a narrowband filter of width 0.5 Hz, where the center frequency of the filter is indicated on the Y-axis label. In each case, we can see that between 0 and 2 Hz approximately, the cross-correlation function decays slowly away from a time lag of zero, whereas between 2 and 5 Hz approximately, the cross-correlation function decays quickly. Moreover, in these cases, the cross-correlation is small after 5 Hz. The slow decay of the cross-correlation between 0 and 2 Hz dominates the cross-correlation of the corresponding raw recordings, shown in Fig. 3, A2–C2; in each of these plots, the cross-correlation function decays slowly. The removal of the lower frequency components results in a cross-correlation function that decays quickly, as shown in Fig. 3, A4–C4. The upper bound of the filter was also chosen to exclude the frequencies at which the cross-correlation is small. Note also that the median filter in these cases also results in a faster decaying cross-correlation, as shown in Fig. 3, A3–C3. To summarize, the filter bank approach consists of the following two parts:
-
1)
Apply a set of overlapping narrowband filters, which in our example were of width 0.5 Hz and stepped in intervals of 0.05 Hz.
-
2)
For each narrowband filter, calculate the cross-correlation between the two filtered recordings. Investigate if the cross-correlation function is maximized at a time lag of zero (or near to) and look at the rate of decay.
Calcium Transient Peak (Spike) Detection
A wide range of approaches have been used to detect action potentials in neurons (see e.g., Kaiser 1960). However, there is no consensus on which approach is best. We employed two common approaches: gradient/slope (see Brown et al. 2004) and template matching. We developed a new gradient/slope-based spike measure for which we derived the statistical distribution under certain regularity conditions. The template matching approach used standard k-means clustering: we implemented a number of heuristic measures to determine the number of templates required. In the current study, we applied the gradient technique to both the median-filtered data and FIR passband-filtered data, whereas the template matching technique was applied only to the FIR passband-filtered data. The template matching technique was not applied to median-filtered data because calcium transient waveforms resulting from this filter decayed too slowly in general.
The two spike detection methods have different strengths. For the gradient method, two main advantages are as follows. First, it is relatively agnostic regarding the shape of the peaks of calcium transients. Second, it is usually more successful than a template-based approach for the resolution of two closely located peaks of calcium transients, where the second peak is masked to a certain extent by the slow decay of the first peak. For the template matching method, two main advantages are as follows. First, it is more robust with regard to noise because it is essentially a weighted sum. Second, the templates used by a template matching algorithm also can be used to cluster different calcium transient peaks.
An associated problem with any technique is threshold determination. In illustration, consider Fig. 4, where A shows four simultaneous raw recordings and where C and E show the median-filtered and FIR bandpass-filtered data, respectively. The results of the gradient method applied to the median-filtered and FIR bandpass-filtered data are shown in Fig. 4, B and D, respectively. Figure 4F shows the correlation of a single template (per recording) against the FIR bandpass-filtered data. We can see in Fig. 4, B, D, and F, that the peaks of corresponding calcium transients have been transformed into spikes/peaks. To determine which “peaks” correspond to a calcium transient peak, some sort of thresholding is required. Again, a range of techniques ranging from fully manual to fully automatic exist in neuroscience, many of which are heuristic. In this article we describe the two thresholding techniques that we used, both of which are based on a median estimate of the background noise variance. Before describing these thresholding techniques, we describe in detail the gradient and template matching techniques used.
Fig. 4.
A shows 4 simultaneous raw recordings. C and E show the median filter and FIR passband filter applied to these raw recordings, respectively. B and D show the gradient method applied to the median-filtered data and FIR passband filtered-data, respectively. F shows the correlation of the FIR bandpass-filtered data with a single template (per recording). The horizontal blue lines in B, D, and F show the thresholds from the first thresholding method; the horizontal red lines in B and D show the thresholds from the second thresholding method.
Gradient Method
For both baselining methods, the peaks for the calcium transients are accompanied by an abrupt shift in level, with a corresponding high gradient value. This can be seen in Fig. 4, C and E. For both baselining techniques, the distance in time between the minimum and maximum values of a calcium transient peak event is not constant, but it is generally bounded by some small range, Dmin, · · ·, Dmax. This led us to use the following gradient measure:
where {yi}i=1R is either median-filtered or FIR bandpass-filtered data. Figure 4, B and D, show the gradient method applied to the median-filtered and FIR bandpass filtered-data, respectively. For both baselining techniques, the calcium transient peak is transformed into something that resembles a spike that can be detected using a thresholding scheme. As will be described later, we used two thresholding schemes. Of particular note, the second thresholding scheme uses an approximation of the statistical distribution of zi when no activity is present. We did not expect to be able to derive or approximate this distribution because the set of differences {yi − yi−D}D=DminDmax are correlated due to the common term yi, and we did not expect to know the distribution of {yi}i=1R. However, when we applied the median filter to a set of six independent sets of recordings with no distinct calcium transients present, we obtained time series whose autocorrelation function had few statistically significant values at any lag other than zero. An example can be seen in Fig. 5, C, E, and G, each of which displays the autocorrelation function of median-filtered data of inactive recordings. The horizontal blue lines in each plot show the 99% confidence bounds; we can see very few values falling outside these bounds. Moreover, the time series appeared to be Gaussian. This can be seen in Fig. 5, D, F, and H, which show the QQ-norm plots of the data used to generate the autocorrelation functions in B, D, and F. Under the assumption that yi are IID Gaussian, the cumulative density function of zi is given by
Fig. 5.
A shows 3 simultaneous raw recordings. B shows the median filter applied to these raw recordings. C, E, and G show the autocorrelation functions of the median-filtered data. D, F, and H show the QQ plots for the median-filtered data. If the data are Gaussian, the blue dots will lie on the black line. Apart from the tails of the distribution, the blue dots lie on the black line. This indicates that the median-filtered data are Gaussian, or close to it.
where σ2 is the variance of {yi}i=1R and N = Dmax − Dmin+1 + 1. In our cases, the value of N is at most 3 or 4, and hence the integral is trivial to calculate because it is the convolution of two functions; it just requires an estimate of σ2. In practice, to avoid numerical errors, we set σ = 1 and scale the threshold accordingly. The derivation of this expression is given in Distribution of data from the gradient method. A robust method for estimating σ2 is given later. We finish this discussion by mentioning that we did not use the results of Gupta et al. (1985) for the maximum of equally correlated Gaussian random variables that have been studentized. We could not use their result because we do not use, or cannot use, the estimate of standard deviation that they used to studentize the maximum of equally correlated Gaussian random variables. As will be explained later, because of the presence of spikes, an approach using the median of {|yi|}i=1R is used to estimate σ2.
We finish this discussion of the gradient method by describing a method that can be used to reduce the noise in the gradient method when it has been applied to noisy median-filtered data. Just as we have used bandpass FIR filtering to also remove higher order frequency components present in raw recordings, low-pass FIR filters can be used to remove higher order frequency noise components present in data produced by the gradient method when it has been applied to noisy median-filtered data. This method produces data very similar to those produced by the Gradient method when it has been applied to FIR bandpass-filtered data.
Distribution of data from gradient method.
We derive the distribution of the gradient method when the underlying noise process is IID Gaussian with mean zero and variance σ2. To do this, let X1, · · ·, XN, X be IDD Gaussian random variables with mean zero and variance σ2. Define Zn to be
and Z to be
We will derive an expression for
where fZ(z) and FZ(z) are the probability density function (pdf) and cumulative density function (cdf) of Z, respectively. Note that
Using the independence of X1, · · ·, XN, X, the following decomposition can be done:
where fZ1|Z2 · · · ZN,X,X1(z1|z2, · · ·, zN, x, x1) is the conditional pdf of Z1 given Z2 · · · ZN,X,X1and δ(·) is the delta function. Using the same process another N − 1 times, we get
This can be calculated numerically using the convolution of the two functions exp (−x2/2σ2) and
Template Matching
Template matching is commonly used for spike detection. This approach searches for patterns in a recording that are similar to a template, where the template is representative of the event of interest. Many techniques use more than one template because the events of interest may not be described accurately by one template. Some template matching techniques use predefined templates, whereas others find templates in some sort of unsupervised fashion from the data (see e.g., Salganicoff et al. 1998). In the case of multiple templates, the templates used or formed also can be used to cluster/associate events. A good comparison study of such techniques among others can be found in Lewicki (1988).
We found in many recordings that the spikes in the FIR bandpass-filtered data were similar in shape, where the main difference in shape was due to the distance in time between the trough and peak and the difference in amplitude between the trough and peak. Also, the farther the distance from the trough and peak, the greater the variation in the spike shape. In illustration, see Fig. 6, which contains example waveforms from four recordings. The first three plots in each row of Fig. 6 contain the waveforms for the three largest peaks detected for the recording. The last plot in each row contains the template formed from these waveforms with the use of a singular value decomposition (SVD). In the first two rows, the waveforms appear to be similar. However, in the third and fourth rows, the waveforms diverge farther from the trough and peak. Moreover, the trough and peak positions change relative to one another. In the fourth row, the variation is probably due to noisy data.
Fig. 6.
The first three plots in each row show the three waveforms for the three largest peaks of a recording. The fourth plot in each row is the principal component of these three waveforms, which is the template used. The first three plots in each row contain the waveforms for the three largest peaks detected by the gradient method for the recording they belong to. For each recording, these waveforms are placed in a matrix. The SVD is then performed on each of these matrices. The vector corresponding to the largest singular value from the SVD, which is referred to as the principal component, is shown in last plot in each row. This principal component is what is used as the template.
The similarity in shape we see in many cases lends itself to a template matching approach. We describe a template matching method that we found effective for forming templates. We also describe some heuristic approaches we used to estimate the number of templates required. The method forms templates in an unsupervised manner using k-means clustering, where the templates are the resultant cluster centers. The templates formed also can be used to cluster multiple events. We applied the template matching approach to FIR bandpass-filtered data. We did not apply the approach to the median-filtered data because the peaks generally decay slowly in these data.
The template matching approach consisted of the following three steps:
1) Construct templates of what the events of interest look like.
2) Correlate templates against recording.
3) Threshold results of correlations.
These three steps are the steps taken by most template matching techniques. We describe steps 1 and 2 below; the thresholding done in step 3 is described later. As already mentioned, an unsupervised k-means clustering approach was used to construct representative templates, where the cluster center updates were done in either the conventional way (i.e., taking the average of vectors in a cluster region) or by using the SVD. The following describes our implementation of the clustering algorithm in detail for the case of K cluster centers:
-
1)
Initial peak finding: Find candidate transient peak positions using the gradient technique.
-
2)
Pruning peaks: Rank candidate transient peaks in descending order according to their corresponding gradient value. For each of the top P peaks, take a segment of M data points around the peak; let yp be a row vector containing the M data points for the pth peak. The vectors yp can also be normalized at this point so that ||yp|| = 1. This rescales the waveforms so that they have roughly the same amplitude.
-
3)Clustering Part: Perform k-means clustering on {yp}p=1P.
-
a)Initial cluster centers: Uniformly at random choose K cluster centers, without replacement, from {yp}p=1P and denote these {ck(0)}k=1K.
-
b)for j = 0:J (we took J to be 20):
-
i)Clustering: Assign each peak p to the cluster k that minimizes ||yp − ck(j)||. Let k(j) be the set of peaks assigned to cluster k. Let Yk(j) be a matrix whose rows are the vectors yp for all ∈ .
-
ii)Update cluster centers: Update cluster centers in either the conventional way, that is, the new cluster centers ck(j+1) are the average of the row vectors in Yk(j), or by performing the SVD on Yk(j), that is, Yk(j) = Uk(j)Dk(j)Vk(j), and defining the new cluster centers ck(j+1) to be the first column vector of the matrix Vk(j) multiplied by Dk(j)(1,1), where (1,1) indexes the matrix Dk(j).
-
i)
-
a)
The set of templates are then the set of cluster centers after step 3 has finished. The important part to note in the clustering method is the use of the normalization in step 2. We found that this is an effective way to compensate for peaks that have the same shape but different amplitudes. This is not an essential step, because one may wish to cluster on the basis of spike amplitudes.
The natural question to ask is, how do we estimate the number of cluster centers K? As has been widely recognized, there is no definitive way to determine the number of cluster centers, and we also found this to be the case. This is probably due to the similarity of the spike shapes in many cases. We applied a number of heuristic approaches, which we explain below.
We started by using the rule of thumb (see Kodinariya et al.2013), which we in fact used as an upper bound. We then performed k-means clustering for the value K = 1 to , where for each value of K the clustering was performed multiple times. For each value of K, we calculated
This expression gives a measure of fit of the clustering performed. We ran the clustering algorithm a number of times and averaged this measure of fit. The reason for this is that different runs will produce different cluster centers because of the random initialization of cluster centers. An example of this averaging is the bar graph in Fig. 7D. A simple method to determine K from this graph is the scree test (Kodinariya et al. 2013), which is the point of maximum inflection. In this case, the point of maximum inflection is K = 2, and so the number of cluster centers would be 2. Unfortunately, in some cases there is no obvious point of inflection.
Fig. 7.
A shows median-filtered data for visualization purposes. B shows the correlation of the corresponding FIR-filtered data with the template shown in D. Apart from the bar graphs, the plots in C, E and F, H–J, and L–O show the templates found by k-means clustering using 1, 2, 3, and 4 cluster centers, respectively, for a single run. The bar graph in D shows the average of for K = 1, 2, 3, 4 over 50 runs, which has been normalized so that the maximum value is 1. Bar graphs in G, K, and P show the singular values for the matrix containing the waveforms in plots to the left in the corresponding row; the singular values in each case indicate that only one template is required.
We also found it useful to look at the templates generated for different values of K. The plots (not including bar graphs) in the rows of Fig. 7 showing C, E and F, H–J, and L–O show this. If the templates are very similar for a particular value of K, then that value of K is probably too high. This is a subjective measure, but it is a useful check. This also led us to use a principal components-based approach to assess the similarity of the cluster centers. The approach taken was to normalize the cluster centers {ck(J)}k=1K and place these normalized vectors row-wise into a matrix Y ∈ K×M. The SVD is performed on Y, that is, Y = UDVT. Using the square of the singular values of Y, which are the diagonal entries of the diagonal matrix D, determine the number of principal components using one of the two following methods:
1) From Kaiser (1960), the number of principal components is the number of singular values greater than 1.
2) From Cattell (1966), use the scree test: rank the square of the singular values in descending order. Visually determine the elbow point; the number of singular values is the number of singular values preceding the elbow point.
The rationale behind using the singular values is as follows. We do not know the number of templates required, so we overestimate the number we think are required. The k-means clustering algorithm then outputs a number of templates; principal components analysis can be used to estimate the number of principal components required to represent the matrix Y(k) that contains these templates (normalized). This is commonly done by considering the singular values of Y(k). We used either of the following two tests. The first test is that proposed in Kaiser (1960), where the number of principal components is the number of singular values greater than 1. The second test is the scree test proposed in Cattell (1966), where the singular values are ranked in descending order and the number of singular values is the number of singular values preceding the elbow point, which is the point of maximum inflection. Either of these tests can be used to determine the number of principal components of the matrix Y(k), which then can be used as an estimate of the number of cluster centers K.
All of these methods are heuristic in nature and must be viewed with a degree of caution and skepticism. For example, even though the scree test applied to the bar graph in Fig. 7D would suggest that two templates are required, when we consider the plots in Fig. 7, G, K, and P, which contain the (squared) singular values of the matrix containing the templates, we would conclude only one template is required. Moreover, when we correlate using the single template found in Fig. 7C, we obtain distinct peaks (see the plot in Fig. 7B).
We now mention the correlation of templates against recordings. For each template in a set of templates {ck(J)}k=1K, the following correlation is done:
where {yi}i=1R is the FIR bandpass-filtered data the templates were formed from, and ck(J)(m) refers to entry m in ck(J). For each template ck(J), the corresponding correlation {vi,k}i=1R is thresholded and the position of peaks determined.
We finish this section by noting that in many cases only one template was required. In this case, we usually set K = 3. Note that in this case there is no clustering required. Four examples of this can be seen in Fig. 6. The first three plots in each row contain the waveforms for the three largest peaks detected for the recording. The last plot in each row contains the template formed from these waveforms using the SVD.
Choice of Threshold
Both the gradient and template matching algorithm techniques transform the peak of a calcium transient into something that looks like a spike. However, some sort of thresholding is still required to detect the peaks produced. This choice of threshold is a difficult problem in spike detection because the time series generated often cannot be tackled with standard statistical detection methods. Hence the use of even manual thresholds and ad hoc/heuristic techniques can be seen in literature. We propose two thresholding schemes: the first can be applied to peaks generated by both the gradient and template matching algorithms, and the second can only be applied to the peaks generated by the gradient method.
Thresholding Method 1
One common approach to peak finding is to think of the time series resulting from the two methods, for example, {zi}i=1R in the gradient algorithms, as signal plus noise, where the signal is due to spikes. The threshold that follows from this is βσ̂n, where σ̂n2 is an estimate of noise variance σn2 and β is a constant. In the literature it seems that β usually takes values between 3 and 5. Unfortunately, estimating σ̂n2 directly from a time series with spikes is problematic because the spikes will cause bias. A more recent and popular method, used in Quiroga et al. (2004) to estimate σn for the Gaussian noise case, is the following:
where {xi}i=1R denotes the time series with spikes and Gaussian noise. For example, in the gradient algorithm, the time series {xi}i=1R is {zi}i=1R. This is the approach that we took for the first thresholding method. Three examples are given in Fig. 4, B, D, and F, where the horizontal blue lines denote the threshold (the horizontal red lines in B and D are the thresholds from the second thresholding method). In all three examples the value of β is 3. Unfortunately, we have not found a universal value for β that works optimally. Generally, a value of 3 for β will guarantee detection of most peaks, but in the case of noisy data, it may introduce false peak detections.
Thresholding Method 2
As explained earlier, in the case studies of calcium imaging recordings with no distinct transient peaks, the median-filtered data appeared to be IID Gaussian. If we think of the median-filtered data {yi}i=1R as signal plus noise, where the signal is due to spikes and the noise is IID Gaussian (i.e., the noise has the same distribution as when no activity is present), then a natural threshold for the gradient {zi}i=1R is the value of z such that
where σ2 is the variance of {yi}i=1R when no activity is present and α is small, generally <0.01. This is the approach we took for the second thresholding method. This requires an estimate of σ2, which we obtain by again using the method in Quiroga et al. (2004); that is, we need absolute value in the following equation:
Figure 4B gives an example of this thresholding technique applied to gradient data generated from median-filtered data. The horizontal red lines denote the threshold, all of which were generated with a value of 0.01 for α. Unfortunately, as for β used in the first thresholding method, we did not find a value of α that worked optimally in all cases.
The discussion thus far has concentrated on thresholding gradient data generated from median-filtered data. However, we did not restrict the threshold to just this case. In Fig. 4D, an example is given of the thresholding technique applied to gradient data generated from FIR bandpass-filtered data, where again the horizontal red lines denote the threshold, all of which were generated with a value of 0.01 for α. Although FIR bandpass-filtered data are correlated (bandpass filters induce correlation), unlike the median-filtered data that were used to justify this method, the thresholding method still proved effective.
We finish this discussion by noting a limitation of this second thresholding method that is not such a problem for the first thresholding method. Both thresholding methods use an estimate of the variance of some underlying noise process by taking the median of the absolute value of {zi}i=1R and {yi}i=1R, respectively. In both cases, the higher the density of peaks, that is, the smaller the time between peaks, the greater the influence of the peaks on the estimate of the variance. This is a greater problem for the second thresholding method because the peaks in {yi}i=1R, the filtered data, decay more slowly than the peaks of {zi}i=1R, the gradient data.
Synchrony Measures
Two pairwise measures of synchrony were used, the first being the cross-correlogram function, which is calculated on the basis of the timing of discrete spike events, and the second being the cross-correlation function, which is calculated using entire signals. Both attempt to measure the strength of relationship between two recordings at different time lags. For both measures we are interested in whether the measure is maximized at a time lag of zero and whether the measure is statistically significant at time lag zero. Our preferred measure is the cross-correlogram because it only uses spike timings and is not susceptible to any additional background noise (beyond that which may have introduced false-positive spikes). However, for recordings with ambiguous peaks, the cross-correlogram is inappropriate. Moreover, when there exist a small number of spikes, the confidence bounds for the cross-correlogram cannot be used, hence the need for a measure that does not use spike timings. The cross-correlation function filled this need. It does not use spike timings, and its confidence bounds are based on more data points. We did, however, try the nonlinear cross-correlation measure described in Quiroga et al. (2004) and a lag-based estimate of mutual information. However, these two methods when applied to our data gave inconsistent results.
Cross-Correlogram
One of the most commonly cited synchrony measures is the cross-correlogram, which essentially constructs histograms of the following quantity:
where
and
are the spike timing estimates for two recordings (k1) and (k2) with R data points. If two spike trains have a large number of coincident spikes, then the cross-correlogram should have a large value at a time lag close to zero. An example is given in Fig. 8C, which displays two recordings with mostly coincident spikes. Figure 8B displays the resultant cross-correlogram as described in this section. As expected, it is maximized at a time lag close to zero.
Fig. 8.
A and B show the cross-correlation and cross-correlogram of 2 time series, respectively, where the cross-correlation was computed using FIR bandpass-filtered data and the cross-correlogram has been scaled so that the maximum value is 1. The horizontal black lines in A and B are confidence bounds; points outside these lines are statistically significant. C displays the 2 time series baselined by the median filter. The vertical black lines in C denote the position of the peaks detected. In this example, most of the peaks fire coincidently. This is reflected in both the cross-correlation and cross-correlogram functions being maximized at a time lag of 0 and the fast decay from 0.
There are a number of versions of the cross-correlogram. We used the version described in Windhorst and Johansson (1999), which has the following form for two spike trains {ni(0)}i=1N0(R) and {ni(1)}i=1N1(R):
where b is bin width, p is time lag, and
If the two spike trains are independent Poisson processes, then the expected value of q̂10(p) is 0 with the following asymptotic bounds given by
where Zα is given by the inverse cdf of the standard normal distribution for 1 − α. The equation above allows us to determine whether q̂10(0) is statistically significant; that is, if q̂10(0) falls outside the bounds given by the above equation, then q̂10(0) is statistically significant.
Cross-Correlation of Calcium Transients
The second measure of time alignment used was the standard cross-correlation function, as introduced earlier, which was applied to either the median-filtered or FIR bandpass-filtered data. However, we usually applied the cross-correlation function to FIR bandpass-filtered data rather than median-filtered data because the resultant cross-correlation functions generally decayed more quickly for FIR bandpass-filtered data. An example of this can be seen in Fig. 3, A3–C3 and A4–C4, which shows the cross-correlation of median-filtered and FIR bandpass-filtered data, respectively, to three pairs of recordings. The cross-correlation function decays most quickly for the FIR bandpass-filtered data.
As already mentioned, we are interested in whether the measure is maximized at a time lag of zero and whether the measure is statistically significant at time lag zero. To determine if p̂k1,k2 is statistically significant, we used the asymptotic confidence intervals derived in Brillinger (1979) for two stationary time series. An example of the cross-correlation function and these confidence intervals is given in Fig. 8A; the roughly horizontal lines show the confidence interval. Mathematically the confidence intervals are given by
where Tα is given by the inverse cdf of the t distribution (2L degrees of freedom) for 1 − α, and p is the time lag. The numerous terms making up the expression for f33(0, p) and an explanation of L are given below.
Confidence bounds for cross-correlation.
For two data sets {yi(k1)}i=1R and {yi(k2)}i=1R and time lag p, the expression for f33(0, p) in Brillinger (1979) is made up of the following terms:
A discussion is given in Brillinger (1979) regarding the values that L can take. They conclude that, in practice, L can be arbitrarily large. We took L = R/2.
Unitary Event Analysis
Lagged correlation measures only compare pairs of time series. Moreover, they do not focus on individual firing patterns. In illustration of this, consider Fig. 9, which shows a number of recordings (baselined with median filter) where the vertical bars denote the position of detected peaks. We can see a number of coincident patterns. To determine if these coincident patterns cannot occur due to chance, we use unitary event (UE) analysis as described in Grün and Rotter (2010), which starts with the null hypothesis that a set of spike trains are independent homogeneous Poisson processes. Under this null hypothesis, the authors show how to estimate the probability that a particular pattern can occur at least N times over an observed time interval. If a particular pattern occurs N times and the estimate of the probability that this pattern can occur at least N times is less than some predefined α level, then the pattern is deemed statistically significant given the null hypothesis; otherwise, the pattern is deemed statistically insignificant. An example of this method is given in Fig. 9, where the blue vertical lines denote spikes that do not belong to a pattern that is deemed statistically significant, whereas the red vertical lines denote spikes that belong to a pattern that is deemed statistically significant.
Fig. 9.
This plot shows 5 independent calcium imaging recordings that have been baselined with the median filter. The vertical lines denote the position of the peaks that have been detected. The red lines indicate those peaks that belong to a pattern that is considered statistically significant, whereas the blue lines indicate those peaks that do not belong to a pattern that is considered statistically significant.
The estimation that a particular pattern can occur at least N times is done using the following steps:
-
1)For a set of K recordings with R data points each, detect calcium transient peaks and form spike trains {si(k)}i=1R using the following equation:
-
2)Divide each spike train into disjoint bins of size h, resulting in m = R/h bins. Using this partitioning, construct the following spike trains {bj(k)}j=1m using the following formula:
-
3)For each spike train, estimate the probability pk that a spike can occur in a bin of size h using the following equation:
This step uses the assumption that the spike trains {si(k)}i=1R are homogeneous Poisson processes.
4) Estimate the probability of a particular pattern {bj(k)}k=1K at index j using the following equation:
This step uses the assumption that the spike trains {si(k)}i=1R are independent.
5) The probability that a particular pattern {bj(k)}k=1K at index j occurs at least N times is estimated by the following equation:
where P̂k = Prob ({bj(k)}k=1K). This step uses the binomial distribution.
6) If m is large, use the following Poisson approximation to binomial:
where Nk = P̂k·m.
The three steps above to take note of are steps 2, 5, and 6. The binning in step 2 is to allow for imperfect alignment of spikes. Most importantly, in step 5 an estimate of the probability that a particular pattern occurs at least N times is given. If it is lower than a user-defined level α, then the particular pattern is considered statistically significant given the assumptions of the null hypothesis. The Poisson approximation in step 6 is to make the calculation of the probability in step 5 tractable; generally, m will be too large to calculate .
RESULTS
Activation of Calcium Transients from Multiple Regions of Interest in Single Axons
All of the analysis performed in this study was based on dynamic continuous fluorescence illumination of single nerve axons in isolated full-length mouse colonic preparations in vitro (n = 6). First, we recorded a discharge of calcium transients in multiple varicosities along single nerve axons. Next, we arbitrarily identified discrete regions of interest around these varicosities. This enabled us to record and compare the dynamic changes in fluorescence at multiple single varicosities simultaneously. We found that often at single recording sites, the ratio of signal to noise of the calcium transient was small on a decaying baseline (Fig. 1). The first step we employed was to apply a median filter to these raw recordings, as shown in Fig. 1. Figure 1, B and E, show the effect of a median filter applied to the raw calcium recordings in A and D, respectively. The effect of this filter is to remove their baselines while preserving the shape of the calcium transient peaks.
Cross-Correlogram and Cross-Correlation
Figures 8 and 10 show two examples of the cross-correlogram and cross-correlation. The first example, shown in Fig. 8, contains two recordings whose spikes are unambiguous and easy to detect. The second example, shown in Fig. 10, contains two recordings whose spikes are ambiguous and difficult to detect. Both Figs. 8C and 10C show the recordings baselined with the median filter, where the vertical blue lines denote the peaks detected. Figures 8 and 10, A and B, show the cross-correlation and cross-correlograms, respectively, where the blue lines are confidence bounds. The cross-correlation was calculated using bandpass-filtered data.
Fig. 10.
A shows the cross-correlation, as applied to FIR bandpass-filtered data, to the 2 recordings shown in C. For the purpose of visualization, median filtered-data are displayed in C. The spikes detected are denoted by a vertical bars. The spikes are ambiguous and few. Moreover, for the second recording, no spikes have been detected. This means that the cross-correlogram is inappropriate, which is reflected in B, which displays the cross-correlogram in this case. Despite this, the recordings do display some synchrony. This is reflected in the cross-correlation plot that is both maximized and statistically significant at a time lag of 0.
In the first example, most of the detected spikes are coincident, which is reflected in the cross-correlogram, which is maximized at a time lag of zero. The cross-correlation function is also maximized at a time lag of zero. In the second example, the cross-correlogram is of no use because of the ambiguous peaks. However, visually the two time series display synchrony. This is displayed in the cross-correlation plot, which is maximized at a time lag of zero.
Application of Unitary Event Analysis to Calcium Transients in Nerve Axons
In Fig. 9 we give an example of unitary event (UE) analysis applied to five recordings with relatively unambiguous spikes. The vertical lines denote the position of the spikes that have been detected. The red lines indicate those spikes that belong to a pattern that is deemed statistically significant, whereas the blue lines indicate peaks that did not belong to such patterns. We can see spike patterns that include three, four, or five coincident spike firings, where the patterns that include three or four spike firings are actually a subset of the patterns that include five coincident spike firings. This was a common occurrence in our analysis; many smaller patterns are often seen as a subset of a larger spike firing pattern.
DISCUSSION
One of the most problematic scenarios faced with calcium imaging in vertebrate and invertebrate nervous system is how to objectively identify calcium transients from an unstable baseline with low signal-to-noise ratios. Even more problematic is when each calcium transient has slightly different rates of rise, or rates of decay, with inconsistent durations, and particularly when numerous calcium transients can occur on the decay phase of a single calcium peak that does not return rapidly to baseline. Many of the techniques described in this study are specifically designed for calcium imaging data, particularly with discrete calcium transients that have slow and variable rates of decay. Indeed, other techniques have been developed by other investigators with general applicability to peak detection of biological signals, whereas others are fine-tuned for the particular experiment. In the current study, we have used a variety of methods, some of which have general applicability, whereas others are applicable almost exclusively to calcium imaging. Our baselining techniques, correlation methods, and UE analysis are of general applicability, whereas the spike detection techniques are applicable to calcium imaging.
The use of median and FIR filters in neuroscience is common. Moreover, filters tuned for the specific applications have been developed (see e.g., Fontaine et al. 2014). Our major novelty is the combination of an FIR bandpass filter and our gradient measure to detect calcium transient peaks. More specifically, this involves the transformation (using an FIR filter) of slowly decaying calcium transient peaks into elongated S shapes that have a clearly defined trough and peak, which can then be transformed into a spike using our gradient measure. The advantage of our gradient measure is that it allows the distance in time between the trough and maximum of these elongated S shapes to vary over a specified time frame. We have also derived the statistical distribution of our gradient measure under certain regularity conditions: we found that these conditions were met in a number of case studies when the gradient measure was applied to median-filtered data. This distribution can then be used to threshold the time series resulting from our gradient measure.
The standard cross-correlation function has been used extensively in the literature to measure synchrony between two pairs of time series. However, the novelty of our study is the use of a filter bank to investigate the synchrony between two time series at different frequencies (Fig. 3). More specifically, this involves the application of a set of narrowband filters to identify the rate of decay of the cross-correlation function for the time series at different frequencies.
Like the standard cross-correlation function, the cross-correlogram has been used extensively to measure synchrony between two time series, including calcium imaging of neural networks. However, to the best of our knowledge, a significant innovative methodology in this study is the application of UE analysis to detect coincident firings patterns of calcium transients.
Advantages and Disadvantages of Using an FIR Filter
Advantages.
The FIR bandpass filter transforms slowly decaying peaks into waveforms with a much faster rate of decay. The resulting waveform can also be detected using template matching.
Removes higher order frequency noise components.
For cross-correlation analysis, removes frequency components that are not in synchrony.
Disadvantages.
Can smear closely spaced peaks.
Frequency bounds must be carefully chosen. If the lower bound is not high enough, slow-moving trend components will not be removed. If the upper bound is too low, the peaks will become smeared, whereas if the upper bound is too high, higher frequency noise components will not be removed.
Advantages and Disadvantages of Using a Median Filter
Advantages
Successfully baselines the data without distorting the underlying peak shape. This is particularly useful for data visualization.
In the cases we have studied, the median filter data appears to be IID Gaussian when no activity is present. In this case the distribution of the Gradient method can be described and a threshold derived for peak detection.
Disadvantages
Does not remove higher order frequency noise components. However, for a low signal-to-noise scenario, a low-pass filter can be applied to the median-filtered data to remove higher frequency noise components. However, depending on the upper bound of the filter, the spike shapes will still be distorted and correlation will be induced within the time series. The induced correlation will mean that assumptions for the second thresholding method will be violated.
The cross-correlation function for the median-filtered data does not generally decay as fast as that for the FIR bandpass-filtered data. Because we are interested in synchrony, we ideally want the cross-correlation to be maximized at time lag zero and minimized elsewhere. The FIR bandpass-filtered data yield cross-correlations that are most like this, which is seen in their fast decay. In many cases the cross-correlation function for the median-filtered data decays quickly, but rarely as quickly as the cross-correlation for the corresponding FIR-filtered data.
Advantages and Disadvantages of Using the Gradient Method
Advantages.
Only requires that the distance in time between the trough and peak of the waveform in the baselined data be bounded.
Can be used for closely spaced peaks.
Disadvantages.
More sensitive to noise than template matching technique.
Advantages and Disadvantages of Thresholding Method 2
Advantages.
The thresholding method is based on an exact distribution for the data generated by the gradient method under the assumption that the baselined data is IID Gaussian when no activity is present, which we have seen to be case for median-filtered data.
Disadvantages.
For closely spaced peaks, the variance estimate used by the thresholding method is unreliable.
Advantages and Disadvantages of the Template Method
Advantages.
Allows spikes to have different shapes.
Can be used to cluster events according to their waveform shape.
Less sensitive to noise than the gradient method as it is essentially a weighted sum.
Disadvantages.
Can smear closely spaced peaks.
Determination of the number templates is difficult and often subjective.
Advantages and Disadvantages of Cross-Correlogram
Advantages.
Only uses spike timings, so apart from false spike detections, background noise is not taken into account.
Has well understood statistical properties, which can be used to calculate confidence bounds.
Disadvantages.
Can only be used to compare two recordings.
Inappropriate for case studies with a small number of spikes.
Inappropriate for cases with ambiguous spike shapes.
Advantages and Disadvantages of Cross-Correlation
Advantages.
Does not require the use of spike timings.
Useful for case studies with a small number of spikes and ambiguous spike shapes.
Disadvantages.
Can only be used to compare two recordings.
Is adversely effected by low signal to noise.
Advantages and Disadvantages of UE Analysis
Advantages.
Can be used to compare multiple recordings, not just two recordings.
Does not require every recording to be firing synchronously every time because it determines which firing patterns are statistically significant.
Disadvantages.
Inappropriate for case studies with a small number of spikes.
Does not give an overall measure of synchrony; it only detects firing patterns that cannot be attributed to chance.
Conclusion
The methodology presented in this article is demonstrably very effective in the analysis of calcium transients in nerve axons within the intestine. Using our new methods, we will be able to analyze effectively the many complex data being obtained from experiments in which the activity of a large number of enteric neurons and nerve fibers is recorded by calcium imaging. However, our method is not restricted to analysis of data obtained using calcium fluorescence imaging. Our analytical approaches can be applied to any physiological recordings where relatively small signal-to-noise ratios occur, and particularly when they arise from uneven baselines (Fig. 11). This could include ECG signals, extracellular electromyographical signals from gastrointestinal tract, bladder, or ureter, intracellular recordings of excitatory or inhibitory junction potentials from smooth muscle, pacemaker cell signals in the gastrointestinal tract, EEG recordings, or diurnal rhythms in body temperature or energy consumption, among others.
Fig. 11.
The flow diagram shows the consecutive steps taken in our analysis, starting with the raw recordings and finishing with the measures of synchrony, that is, the cross-correlation and cross-correlogram functions and unitary event analysis. The diagram also shows the different paths the investigator may utilize, some of which may be better in some scenarios than others. For example, the investigator may find that in a given scenario, unitary event analysis provides the best analysis tool, and the best spike timing estimates are given by the gradient method applied to median-filtered data, where thresholding method 2 was used.
GRANTS
The experiments carried out in this study were funded by National Health and Medical Research Council of Australia Grants 1067317 and 1067335 (to N. J. Spencer).
DISCLOSURES
No conflicts of interest, financial or otherwise, are declared by the author(s).
AUTHOR CONTRIBUTIONS
J.S. and L.W. conception and design of research; J.S. analyzed data; J.S., L.W., T.H., M.C., and N.J.S. interpreted results of experiments; J.S. prepared figures; J.S., L.W., T.H., M.C., and N.J.S. drafted manuscript; J.S., L.W., T.H., M.C., and N.J.S. edited and revised manuscript; J.S., L.W., T.H., M.C., and N.J.S. approved final version of manuscript.
Supplementary Material
REFERENCES
- Brillinger DR. Confidence intervals for the crosscovariance function. In: Selecta Statistica Canadiana, volume V: Mathematical Statistics, edited by Behara M, Blyth C, Campbell LL, Csörgö M, Dawson DA, Giri N, Joffe A, Stanton RG, and Theodorescu R. Hamilton, Canada: Department of Mathematical Sciences, McMasters University, 1979, p. 1–16. [Google Scholar]
- Brown EN, Kass RE, Mitra PP. Multiple neural spike train data analysis: state-of-the-art and future challenges. Nat Neurosci 7: 456–461, 2004. [DOI] [PubMed] [Google Scholar]
- Cattell RB. The scree test for the number of factors. Multivariate Behav Res 1: 245–276, 1966. [DOI] [PubMed] [Google Scholar]
- Fontaine B, MacLeod KM, Lubejko ST, Steinberg LJ, Köppel C, Pena JL. Emergence of band-pass filtering through adaptive spiking in the owl's cochlear nucleus. J Neurophysiol 112: 430–445, 2014. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Gerstein GL, Perkel DH. Simultaneously recorded trains of action potentials: analysis and functional interpretation. Science 164: 828–830, 1969. [DOI] [PubMed] [Google Scholar]
- Grün S, Rotter S. Analysis of Parallel Spike Trains. New York: Springer, 2010. [Google Scholar]
- Gupta SS, Panchapakesan S, Sohn JK. On the distribution of the studentized maximum of equally correlated normal random variables. Commun Stat Simul Comput 14: 103–135, 1985. [Google Scholar]
- Kaiser HF. The application of electronic computers to factor analysis. Educ Psychol Meas 20: 141–151, 1960. [Google Scholar]
- Kodinariya TM, Makwana PM. Review on determining number of cluster in K-means clustering. Int J Adv Res Comput Sci Management Studies 1: 90–95, 2013. [Google Scholar]
- Lewicki MS. A review of methods for spike sorting: the detection and classification of neural action potentials. Network 9: R53–R78, 1998. [PubMed] [Google Scholar]
- Pereda E, Quiroga RQ, Bhattacharya J. Nonlinear multivariate analysis of neurophysiological signals. Prog Neurobiol 77: 1–37, 2005. [DOI] [PubMed] [Google Scholar]
- Quiroga RQ, Nadasdy Z, Ben-Shaul Y. Unsupervised spike detection and sorting with wavelets and superparamagnetic clustering. Neural Comput 16: 1661–1687, 2004. [DOI] [PubMed] [Google Scholar]
- Salganicoff M, Sarna M, Sax L, Gerstein GL. Unsupervised waveform classification for multineuron recording: a real-time, software-based system. I. Algorithms and implementation. J Neurosci Methods 25: 181–187, 1998. [DOI] [PubMed] [Google Scholar]
- Schwindel CL, Ali K, McNaughton BL, Tatsuno M. Long-term recordings improve the detection of weak excitatory-excitatory connections in rat prefrontal cortex. J Neurosci 34: 5454–5467, 2014. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Travis NJ, Spencer L. Imaging stretch-activated firing of spinal afferent nerve endings in mouse colon. Front Neurosci 7: 179, 2013. [DOI] [PMC free article] [PubMed] [Google Scholar]
- Windhorst U, Johansson H, editors. Modern Techniques in Neuroscience Research. Berlin: Springer, 1999. [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.











