1.IntroductionEpileptiform activity in the brain has traditionally been treated and studied using electrophysiological recording methods, such as scalp electroencephalography (EEG) and local field potential (LFP) recordings. However, these recording modalities lack the spatial resolution and cellular specificity needed to understand how different types of neurons interact at the microcircuit level to produce aberrantly synchronous activity.1 Calcium imaging is a promising technique that can overcome these limitations in the study of seizure dynamics, providing superior spatial and cellular resolution that could lead to improved understanding and therefore more spatiotemporally precise treatment of seizures.2 While a dense body of literature is available describing the characteristics of epileptiform activity in LFP recordings, as well as automated methods to detect these events from electrophysiological data, these are understudied for optical imaging modalities. Intravital calcium imaging data contains largely different sources of noise and signal-to-noise characteristics and thus requires novel solutions for identifying, extracting, and modeling seizure dynamics to make the use of this technique accessible, reproducible and standardized in the field of epilepsy research. While event detection approaches exist for calcium imaging, they have largely been limited to traditional domains of systems neuroscience where repeated trials can be leveraged to minimize the sources of noise. However, calcium imaging in epilepsy models poses a unique challenge for automated event detection in that seizure events are highly irregular in their timing, can express with a wide variety of different waveform patterns, and must be detected on single trials, thus necessitating more novel approaches. In this study, we demonstrate an accurate and computationally efficient signal processing strategy to identify seizure-related events in calcium imaging data—specifically the timing of pre- and inter-ictal spikes, seizure invasion, and propagating waves associated with seizure termination at both the population level and that of individual neurons. We validated this method using two-photon calcium recordings collected from a mouse pentylenetetrazol (PTZ) model of generalized seizures, quantified its performance against manual labels provided by an experienced researcher, and showed that the resulting event times were sufficient to accurately model spatiotemporal dynamics of the seizure associated traveling waves. A MATLAB repository with code for this method and its evaluation was made available online to improve and standardize the study of epilepsy using calcium imaging. 2.Methods2.1.Experiments and Data Collection2.1.1.Cranial window surgeryAll the procedures involving live animals were conducted with approval from and in accordance with Emory University Institutional Animal Care and Use Committee. Stereotactic cranial window surgery and intracortical delivery of adeno-associated virus (AAV) was performed on adult ( days old) VGAT-Cre mice (Slc32a1-IRES-Cre, Jackson Laboratory, Stock No. 028862) backcrossed to C57BL6/N background (). Electrodes for simultaneous EEG recording and headplates to facilitate awake head fixed recording were placed. The procedure was adapted from standard protocols for concentric cranial window implantation.3,4 In brief, mice were secured in a stereotaxic frame and maintained under anesthesia [1.5% isoflurane balanced in oxygen ()]. A 3 mm craniotomy was performed over the primary motor cortex. Stereotactic injections of AAV (500 nL; ) encoding the genetically encoded calcium indicators (GECI) jRGECO1a5 or jYCaMP1s6 were performed through a pulled glass capillary tube (Nanoject 3.0, Drummond) at 300 and deep to the pial surface (0.30 mm anterior and 1.75 mm lateral to Bregma).7,8 AAVs were produced in house following standard procedures.9 A thin polyamide insulated tungsten wire electrode with exposed tip (; P1Technologies) was then placed intracortically at the posteromedial edge of the craniotomy, with ipsilateral reference and contralateral ground stainless steel screw electrodes (E363/96/1.6/SPC, P1Technologies) placed in the skull over the cerebellum in 0.7 mm burr holes. All electrodes were prefabricated with gold pins to facilitate easy preamplifier attachment for recording. A concentric window (inner diameter 3 mm, outer diameter 5 mm; D263 #1 thickness coverglass, Warner Instruments) was then placed plugging the craniotomy. The window and electrodes were affixed to the skull using dental acrylic (C&B Metabond, Parkell) along with a stainless steel headplate (Neurotar). The skin was closed to this headplate using tissue adhesive (Vetbond, 3M). 2.1.2.Intravital awake two-photon calcium imagingResonant scanning (30 Hz, ) two-photon imaging was performed on mice during acute induced seizures beginning one month following surgery to allow for adequate GECI expression. For each imaging session, mice were head-fixed in a carbon fiber airlifted chamber (Mobile HomeCage, Neurotar) and positioned under a long working distance 16x objective (water-immersion, N.A. 0.80, Nikon). EEG electrodes were connected to an alternating current (AC) preamplifier and a data acquisition system (Pinnacle Technologies). Imaging was performed using a two-photon microscope (HyperScope, Scientifica) equipped with a pulsed tunable infrared laser system (InSight X3, Spectra-Physics) and controller software (ScanImage, Vidrio Technologies). GECI fluorescence was excited using a 1030 nm wavelength light and fluorescence emission was separated by a dichroic mirror (565LP, Chroma) with band pass filters (ET525/50m-2p and ET620/60m-2p, Chroma) and collected using GaAsP and multi-alkali red-shifted photomultiplier tubes (PMTs), respectively. All imaging data was collected while EEG was continuously recorded at 2 kHz with a 0.5 to 300 Hz bandpass filter. Image acquisition was triggered by a transistor-transistor logic (TTL) pulse generated in the EEG recording system. Each recording session began following subcutaneous injection of PTZ (40 to ; P6500, Millipore-Sigma; sterile saline diluent) and lasted 20 to 45 min depending on the course of the seizure. Multiple recordings were performed in mice for whom the seizures were not fatal, with sessions separated by at least a week. Data from a representative recording is presented in Fig. 1. A supplementary video of this recording is provided to visualize these events in sequence, beginning during pre-ictal activity and ending after the terminal spreading wave (Fig. S1 in the Supplementary Material, Video 1, MP4, 48.2 MB [URL: https://doi.org/10.1117/1.NPh.11.2.024202.s1]). 2.2.Description of Event Detection AlgorithmThe following section, as outlined in Fig. 2, describes the approach our algorithm uses to determine the population event times and individual cell recruitment to the events, such as preictal spikes and calcium waves during and after a seizure, using two-photon calcium imaging data. 2.2.1.Data pre-processingMotion registration, region of interest (ROI) detection, and calcium transient extraction of soma and surrounding neuropil were performed using the Suite2P software package10 with integrated Cellpose.11 The raw fluorescence traces were background subtracted taking the global minima of the neuropil transients for each recording as a proxy for the background signal. A clean somatic signal was then generated by subtracting 70% of the surrounding neuropil signal from the somatic signal to remove out-of-plane contamination.10 This step also serves to adjust for any photobleaching that occurs in the indicators. While this is not typically a problem for cytosolic indicators, any fluorophore bound or tethered to the membrane can suffer some photobleaching as it remains in the focal plane over long imaging sessions. These traces were then normalized as , using the mean of the first 30 s of recording as baseline fluorescence (). The EEG recordings were bandpass filtered during data acquisition. 2.2.2.Pre-ictal spike recruitment detectionTo identify the times of individual cell recruitment to pre-ictal spikes, global pre-ictal spike times were determined using the averaged calcium trace of each cell’s nearby neuropil signal and the EEG recording. These were then used as “seed times” to guide the identification of individual cell firing times during each mean spike event. We found that preictal spikes were more prominent in both space and time in the neuropil signal, therefore providing better estimation of mean activity than with individual cells’ activity in the soma to guide individual cell event detection. To determine the global pre-ictal spike times, we began by detecting spike wave discharges on an EEG recording and verified their agreement with spike times determined from the large population mean calcium spikes. For the EEG spike detection, we first applied a previously published threshold detection method.12 Afterward, a spectrogram via Welch’s power spectral density was used to compute the ratio of high theta-alpha power (3 to 15 Hz) relative to subsequent adjusted low-gamma (20 to 55 Hz) power (features that were found to reliably predict spikes in this seizure model based on their spectral content), excluding previously found spikes with a ratio feature less than 20 and an inter-spike interval of . EEG spikes were indexed by the peak of the spike on the spike wave discharge, being the most prominent and least variable feature of the spike. To detect calcium spikes, the mean calcium trace was first double-reverse filtered using an adaptive filtering routine (1 Hz, Butterworth lowpass filter, order 3 to 5) that preserves the phase of the signal. All segments of the trace with positive slope were isolated and then a magnitude feature for each segment was computed as the integral of the first derivative of the signal (the “slope-integral” feature) to account for steepness of slope, peak height, and rise-time duration. The periods of the mean calcium trace that corresponded to the top 15% of these events were then thresholded by taking the integral of the periods and comparing it to the integral of a model spike [Gaussian with a peak height of the standard deviation of the trace and a standard deviation () of 0.33 s to give a 1 s width at ] representative of a typical spike weight under normal physiologic conditions. The exact time of each calcium spike was determined by its point of steepest slope.13 These spikes were then cross-referenced with those detected on EEG, so that only a pair of spikes occurring within 0.2 s on each modality was included in the final set of pre-ictal spike times. Then, the time observed on the EEG was used as the recruitment time for each spike. While false positives are typically virtually eliminated after applying the above steps, we sought to further minimize false negatives for spikes of low amplitude but that were nevertheless physiological based on their waveform similarity to the detected spikes. To do this, a spike wave discharge kernel was generated by taking the mean of the EEG for each calcium and EEG concordant pre-ictal spike determined thus far in the set. This kernel was then convolved with the EEG trace, and local maxima of this signal of at least 5 standard deviations greater than baseline and at least 1 s apart were determined. The temporally correspondent spike wave discharges on the EEG trace that were previously missed as pre-ictal spikes were then appended to the set. This step ensures to include isolated spikes that may not be necessarily reflected as large population spikes in calcium (e.g., in the case of a smaller percentage of recruited cells). To next determine the points of individual cell recruitment to pre-ictal spikes, all individual clean somatic traces were low-pass filtered to 1 Hz using the same method as the mean trace. As was done in the mean trace, all regions of each individual trace with positive slope were isolated and then the magnitude of that slope was computed as the integral of the first derivative of the signal (the slope-integral feature). These events were then indexed by the point of steepest slope. The top 20% of these events were taken and the events closest to each of the pre-ictal spike seed times was determined. A cell was considered recruited if this time fell within 1.5 s of the seed time and the peak of the calcium event was greater than above the cell’s mean. 2.2.3.Wavefront recruitment detectionDetection of the seizure wavefront and terminal spreading wave at the population level was performed using the mean neuropil calcium trace, which provided better detection than using the mean somatic calcium trace, likely because the neuropil signal was less variable across cells than the somatic signal. This signal was first low pass filtered to 1 Hz using the same filtering routine as used in the pre-ictal spike detection. The integral of the trace was then computed for all contiguous intervals above a half maximum and the two largest events were determined. The first of these was taken as the seizure event and the second of these was taken as the terminal spreading wave event. These were indexed by the first time point where the trace crossed the half maximum. The wavefront event time was then used as a seed to guide individual cell recruitment detection. As in pre-ictal spike detection, all individual clean somatic traces were low pass filtered to 1 Hz, and all regions with positive slope were segmented, with the magnitude of the slope computed as the integral of the first derivative of the signal (slope-integral feature). These events were then indexed by the point of steepest slope. The slope magnitudes were then weighted by a Gaussian distribution centered at the mean event seed time, to avoid false-positive detection of events more temporally distant from the seed time. To ensure detection of the seizure wavefront and not the sentinel spike often occurring immediately ahead of the wavefront, a narrow Gaussian () was used, while a larger Gaussian () was used for the terminal spreading wave given its much slower propagation. The period with the maximum weighted slope-integral feature was then taken as the individual cell’s recruitment time. A cell was considered recruited if there was at least a 20% increase in average signal for that cell before and after recruitment and the time detected was within 3 s of the seed time for seizure wavefront and within 5 s for the terminal spreading wave. The before and after periods to account for signal change were taken as 10 s for seizures given the occurrence of pre-ictal spikes and to leverage the large and sustained signal change that occurs in the cells during seizure. For the terminal spreading waves the best detection period was a narrower window of 5 s due to the higher signal variability between the seizure and terminal wave. The terminal spreading waves invaded the imaging field of view at different time points between seizures, with some entering during the final phase of ictal activity and others entering after ictal activity had largely died out, contributing to variable calcium levels at the beginning of the events. Note that in some instances (), the seizure was fatal and under these circumstances the recording was truncated shortly after the point of death for event detection purposes. 2.3.Algorithm EvaluationTo evaluate the algorithm’s performance, an expert blind to the automated detection algorithm described above used a MATLAB-based GUI (Fig. S2 in the Supplementary Material) to visually inspect the traces and manually mark the times of pre-ictal spikes, seizure invasion and terminal spreading wave events of activity averaged across the population and of individual neurons [detected events shown in Fig. 3(a) for pre-ictal spikes and Fig. 4(a) for seizure events]. The times for all event types (pre-ictal spikes and ictal and post-ictal waves) were defined as the point of maximum slope. While labeling, the expert was able to view the EEG recording and averaged population as an additional reference to help decide whether candidate events were seizure-related instead of unrelated noisy fluctuations in the signal. We computed accuracy metrics between detected and manual labels by iterating through manually detected events and searching for a matching auto-detected event within 1 s, producing a true positive detection. Any unmatched manual event was designated as a false negative and any unmatched algorithmic event as a false positive. We computed the accuracy and F1 score (geometric mean of precision and recall—i.e., positive predictive value and sensitivity) for each event type where TP is the true positive count, FP is the false positive count, and FN is the false negative count.When interpreting these metrics, it should be noted that the true negative rate is ill-defined due to the sparsity of seizure events; i.e., the algorithm can easily and properly detect that there is no event during most of the duration of the recording, but this result is trivial and properly quantifying it is an ambiguous problem. Therefore, the results should be interpreted in two ways. First, we consider the F1 score to be a better evaluation metric than accuracy because its computation is naturally independent of the true negative rate. Second, 50% accuracy is no longer an appropriate baseline corresponding to random chance-level performance; rather, true random-chance event detection performs much worse than 50%. To provide a statistically accurate performance baseline, we simulated a Poisson process and quantified the resultant F1 score when randomized event times are used for detection. For each recorded seizure, we computed the average frequency of spikes in the pre-ictal period, then used the reciprocal of this value as the average Poisson distribution inter-event time interval to generate randomized event times for the duration of the pre-ictal period. We then computed accuracy and F1 metrics between these randomized event times and manually identified times in the same manner as above. We repeated this simulation 50 times per seizure and report an overall mean F1 score of 0.098. Pre-ictal signal-to-noise ratio (SNR) was calculated for each cell by computing the mean height of all peaks with greater than 1 prominence during the pre-ictal period, then dividing by the variability of baseline activity during this period (quantified by 40th percentile minus 10th percentile of the time series, so that the noise estimate excludes outliers and data values of the peaks themselves). Linear regression was used to demonstrate the relationship between the SNR of the data and performance of our algorithm. 3.ResultsWe performed simultaneous in vivo two-photon calcium imaging and EEG recording in an awake, head-fixed mouse with prior injection of AAV for expression of a GECI in the motor cortex [Fig. 1(a)]. A seizure was elicited by an injection of PTZ (40 to , i.p.), resulting in sporadic pre-ictal spikes for up to 10 min followed by a seizure manifested as a rapid invasion of calcium wave into the field of view. Often times, shortly after the cessation of the seizure, we encountered a much slower propagation of calcium wave [Fig. 1(b)]. We developed an algorithm to automatically detect these different event types (Fig. 2). This algorithm can detect calcium transients even in noisy recordings by utilizing population responses (EEG and population-averaged calcium transients) as seed-times to guide detection of high-slope events in individual cells. 3.1.Pre-Ictal Spike DetectionWe first evaluated our method for detecting pre-ictal spikes by comparing its performance against manual labels, measuring the accuracy and absolute time-difference between algorithmic and manual event detection ( recordings). When applied to the population mean , our method achieved (mean ± standard error of the mean (SEM); ) accuracy and (mean ± SEM; ) F1-score in detecting preictal spikes using the jYCaMP1s indicator [Fig. 3(b)]. Using the jRGECO1a indicator, accuracy was (mean ± SEM; ) and F1 was (mean ± SEM; ). These metrics corresponded to 139 true positives with 15 false positive and 5 false negative detections for jYCaMP1s, and 122 true positives with 11 false positive and 20 false negative detections for jRGECO1a. The average time difference between automatically detected events and manually labeled events [Fig. 3(c)] was (mean ± SEM; ; jYCaMP1s) and (mean ± SEM; ; jRGECO1a), considerably less than the typical pre-ictal spike width and comparable to 3 to 7 imaging frames (frame rate: 30 Hz). In the detection of individual cell events, the algorithm demonstrated an overall median F1-score of 0.755 (jYCaMP1s; 95% confidence interval = [0.321, 0.943]; cells) and 0.553 (jRGECO1a; 95% confidence interval = [0.293, 0.983]; cells) in detecting spike events, with a median time difference of 0.090 (jYCaMP1s; 95% CI = [0.027, 0.142]; ) and 0.105 (jRGECO1a; 95% CI = [0.038, 0.158]; ;). At the single cell level, these metrics corresponded to 796 true positives with 264 false positive and 302 false negative detections for jYCaMP1s, and 386 true positives with 243 false positive and 289 false negative detections for jRGECO1a. Worst-case performance for any individual cell from any seizure (via lower bound of the 95% confidence interval) was consistently greater than the random-chance baseline of 0.098 estimated via a simulated Poisson process. Overall, accuracy was higher with the jYCaMP1s indicator because of its generally higher signal-to-noise characteristics. F1 score for preictal spike detection increased as the cell’s spike SNR improved [Fig. 3(f)]. 3.2.Seizure Invasion and Activity at Termination DetectionWe next quantified and compared the performance of our algorithm in detecting seizure invasion and activity at seizure termination (Fig. 4). For detecting seizure invasion events using the jYCaMP1s indicator, the algorithm achieved a detection accuracy of (mean ± SEM; ) and F1 score of (mean ± SEM; ) in predicting which cells were recruited into the seizure, with a median absolute time difference of 0.165 s (95% CI = [0.058, 0.882]; cells). Use of the jRGECO1a indicator yielded accuracy of (mean ± SEM; ), F1 score of (mean ± SEM; ), and a median time difference of 0.179 s (95% CI = [0.017, 2.808]; cells). These metrics corresponded to 97 true positives with 4 false negative detections for jYCaMP1s and 131 true positives with 16 false negative detections for jRGECO1a. For detecting terminal spreading wave events using the jYCaMP1s indicator, we achieved a detection accuracy of (mean ± SEM; ), and F1 score of (mean ± SEM; ), in predicting which cells were recruited into the seizure, with a median absolute time difference of 0.101 s (95% CI = [0.047, 0.194]; cells). Use of the jRGECO1a indicator yielded accuracy of (mean ± SEM; ), F1 score of (mean ± SEM; ), and a median time difference of 0.253 s (95% CI = [0.031, 4.012]; cells). These metrics corresponded to 82 true positives with 10 false negative detections for jYCaMP1s and 92 true positives with 29 false negative detections for jRGECO1a. As was the case in the pre-ictal detection, the performance of the algorithm was somewhat contingent on the indicator being used, the relative SNR of the indicator, and the dynamics of the cell populations being recorded. Nevertheless, our algorithm achieved detected recruitment times concordant with those of an expert scorer across indicators for both the seizure wavefront and terminal spreading wave. 3.3.Seizure Wavefront ModelingTo illustrate the utility of this detection method, we calculated the rates and directions at which calcium waves propagate during and after a seizure using the position of the cells and the automatically detected recruitment times. We applied a spatial linear regression algorithm, with L1 regularization (originally developed to model interictal events in human intracranial data),14,15 to our detected recruitment times to model propagation of the seizure wavefront throughout the imaged cortex in one example recording. Figure 5(a) shows sequential imaging frames during a seizure invasion event (progressing from bottom-right to top-left; top) and a terminal spreading wave (progressing from left to right; bottom). Recruitment times were automatically determined for each cell and visualized in Fig. 5(b). In combining these techniques, we were able to estimate statistically significant propagation vectors that appear to be consistent with direction and velocity with the sequential frames for each travelling wave (seizure: , , angle = 0 deg; terminal spreading wave: , , ; -values are computed by comparing model residuals to spatially shuffled data sets, as in prior work14). Therefore, our automated detection method was demonstrated to be sufficiently accurate to study the roles of different cell types and individual neurons in seizure activity. 4.DiscussionIn this study, we demonstrated an accurate and computationally efficient signal processing strategy to identify pre-ictal, ictal, and post-ictal events using calcium imaging data. We showed that this method can achieve high accuracy for each of these event types and that the precision of the identified event times is sufficient to map the spatiotemporal progression of various seizure-related traveling waves, including seizure wavefronts and various terminal spreading waves, including purported cortical spreading depolarization. In the study of epileptic microcircuit dynamics, the ability to determine exact recruitment times for individual cells is of great importance, particularly to evaluate the changes in population synchrony and patterns of propagation. This in turn enables the study of questions at the forefront of the field, such as the role of inhibition in either restraining the network (inhibitory restraint) or paradoxically synchronizing it (inhibitory rebound).16,17 Our method has been partially informed by the approaches utilized by several groups. Principally, for defining the time point of recruitment, we use the local timepoint of maximum slope to determine when the cell or population is recruited into epileptiform activity.13,18,19 Other groups have used the time at which the signal exceeds a threshold value such as multiple standard deviations above baseline activity, crossing the half-maximum point of a trace or exceeding a percentage increase from baseline.20–28 One group made this method robust by using a moving window filter to detect high-threshold events, and used the duration where the event was above threshold to differentiate seizures from spike events.29 Still others define pre-ictal and ictal events based solely on the EEG signal and then determine if cells are statistically significantly activated during that event relative to other activity outside the event.30,31 Niemeyer et al. used a clever method for detection of events that parallels our general framework by first finding global seizure events in the calcium data using a threshold detection in the mean trace and then generated a seed from a global signal and anchoring it to a point of recruitment, being the elbow of trace, or rather the maximum second derivative.32 We believe our approach offers several advantages over methods employed by other groups. While another study used lowess smoothing to remove noise before detection,13 our use of a zero-phase low-pass filter removed shot noise equally effectively without distortion of the signal in time and with orders-of-magnitude lower computational demands. Our method also allows for automatic detection of pre-ictal, ictal, and post-ictal events without needing to manually define which periods of the signal were used for which type of analysis. For multiple different event types, we used a slope-integral feature to detect events; we found this feature to be more reliable at isolating events compared to threshold-based or simple slope-based detection, as even after applying the temporal filter, many high-magnitude noise fluctuations still provided false positives. The slope-integral feature solved this problem by leveraging the property that real spikes and wavefront events typically had longer rise times than this type of noise, to enable robust detection. There were several sources of noise in calcium imaging data that guided the design of our approach and introduced challenges for detection. One major limiting factor is the presence of sentinel spikes, a single large amplitude spike that directly precedes the seizure.33 These spikes exhibit large population-wide calcium activity often within a few seconds of ictal invasion and thus can complicate the identification of epileptic wavefront recruitment. Additionally, signal changes associated with seizure activity, such as sudden movements of the animal body at a seizure onset, can lead to lateral shifts, axial drifts, and fluctuating shifts in the baseline signal () that introduce further challenges. While these can be slightly mitigated mechanically with excellent headplate installation and a high rigidity head-fix apparatus, with online z-shift correction or with post hoc motion registration,10 convulsive seizures present a uniquely intense circumstance that can sometimes exceed the corrective capacity of these measures to completely prevent these artifacts from impacting the recording quality. Furthermore, microscope scanning shot noise, particularly from high-frequency resonant scanning, and reduced sampling rates can affect the accuracy of our method. Another limitation is SNR of the recording. Differences in GECI calcium binding affinity and kinetics could contribute to SNR differences. For our selected indicators, both look to have similar half rise times. The half decay time of jYCaMP1s () is about three-fold longer than jRGECO1a (),5,6 which should not affect the current results significantly as our algorithm uses the slope integral feature for onset detection. Similarly, while the binding affinities () are different between jYCaMP1s (70 nM)6 and jRGECO1a (160 nM),34 they are relatively small compared with intracellular calcium concentrations observed during seizures, which can be as high as 700 nM,35 and are therefore unlikely to contribute to SNR differences observed in our recordings. Perhaps the most relevant difference between the GECIs to explain the SNR differences we observed is in their dynamic range: the peak fluorescence change at a saturating level of calcium is higher in jYCAMP1s than in jRGECO1a.5,6,36 Nevertheless our detection method performed well using the indicators of our choice, although we expect an improvement of the accuracy of our approach by utilizing indicators with higher SNR, such as improved versions of GCaMP.36 In fact, F1 score improved as SNR of pre-ictal calcium transients in individual cells increased [Fig. 3(f)]. Another potential influence on the SNR observed in our recordings across indicators could be related to the intrinsic difference in the cell populations targeted with each indicator. As jRGECO1a was selectively expressed in interneurons, which have a higher basal level of firing and resonant frequency37–39 than the pyramidal cells targeted with jYCaMP1s, a lower SNR is expected in the recordings with jRGECO1a. Differences in calcium buffering between cell types may complicate the matter as well. Despite the two indicators being driven by the same promoter, expression levels may be different, which not only impact the baseline level of fluorescence, but also the change, and thus time to saturation, relative to firing.40 It is also important to note that manual labels, which we used as a ground truth for evaluation, are not perfect. In particular, some events, especially in low-SNR cells, can be visibly indistinguishable from noise fluctuations, leading to variability in visual inspection. Discarding low-SNR cells might be necessary to ensure accurate event detection, although this decision requires careful consideration when the aim of the study is to accurately capture population variability—i.e., cell SNR could be related to a physiological variable of interest (e.g., GABAergic subtype) and therefore this consideration could influence results and conclusions. Despite the challenges introduced by these sources of noise, calcium imaging may hold several advantages over EEG in enabling reliable detection of seizure-related events. EEG can often present with variable spike morphology,33 which may require different detection approaches in different models, whereas activation waveforms in calcium data appear to be more consistent and reliably detectable when they are high-SNR. In addition, the higher spatial resolution allowed us to remove sources of noise by averaging activity across the population of cells. However, we envision that EEG will continue to be the gold standard and be primarily used in detecting seizures until a reliable method is established to distinguish seizure-related activity from non-seizure activity through cellular calcium signals. Simultaneous EEG recording also facilitates comparison with prior EEG literature across models. As EEG and calcium signals are each measuring distinct properties of the neural activity with different spatiotemporal resolution, each with their own limitations in the context of epilepsy, we regard them as complementary approaches. Genetically encoded calcium imaging is becoming a more widely used technique to study epileptic networks as it affords great advantage over classically used electrophysiological techniques, principally enabling the recording of hundreds of neurons repeatedly with subtype specificity.1,2 However there remain substantive barriers to the more widespread adoption of these methods including technical expertise and computationally efficient and implementable methods. Currently, it seems nearly every group analyzing this data uses a different approach to quantify these results and few offer a quantitative analysis or validation of the accuracy of their methods. There is a gap in the tools readily available that are optimized for the unique situations presented by the high frequency synchronous firing occurring during seizure events. Here we offer an approach and associated code to aid not only in closing this gap, but in facilitating the standardization of the analysis across the epilepsy field. However, it is important to note that as there is a lack of standardization amongst the experimental paradigms used, including model system, indicators used and imaging parameters; some modifications may be necessary to tailor this approach to each lab’s unique circumstances, as is often the case with pre-clinical EEG/LFP seizure and spike detection. In addition to the study of seizure dynamics, accurate methods to detect and model epileptiform activity in calcium imaging could benefit the long-term development of future epilepsy treatments in translational settings. Despite great advancements for management of epilepsy over the past century, nearly one-third of patients’ seizures are still poorly controlled with medication41,42 and surgical treatment options43–46 are only effective for a subset of these patients. Pre-clinical optical imaging with cellular resolution might be used to evaluate novel brain stimulation targets for epilepsy with the potential for superior cell-specific modulation,47–50 or to provide unbiased evaluation of different stimulation patterns and parameters51,52 for seizure control at scale. Efficient seizure detection methods might also be combined with mean-field imaging to provide feedback for real-time optimization and control paradigms, as brain stimulation for seizure control may benefit by responding to the dynamics of different cell populations in real-time.53–55 In this way, our work may provide a small but important contribution to the development of novel seizure control strategies in animal models, which could inform treatment approaches for patients with medically intractable epilepsy. Code and Data AvailabilityThe code needed to perform this analysis is available in our GitHub repository at https://github.com/Stern-MA/2PCISz_RecDetect and the data used to evaluate this approach will be made available upon request to the authors. AcknowledgmentsThis work was supported by the National Institutes of Health [Grant Nos. F31NS115479 (MAS), R21NS112948 (REG), and S10OD021773 (KB)], and the Mirowski Family Foundation (REG). ReferencesJ. S. Farrell, Q. A. Nguyen and I. Soltesz,
“Resolving the micro-macro disconnect to address core features of seizure networks,”
Neuron, 101
(6), 1016
–1028 https://doi.org/10.1016/j.neuron.2019.01.043 NERNET 0896-6273
(2019).
Google Scholar
L. F. Rossi, D. M. Kullmann and R. C. Wykes,
“The enlightened brain: novel imaging methods focus on epileptic networks at multiple scales,”
Front. Cell. Neurosci., 12 8 https://doi.org/10.3389/fncel.2018.00082
(2018).
Google Scholar
M. A. Stern et al.,
“Applications of bioluminescence-optogenetics in rodent models,”
Methods Mol. Biol., 2525 347
–363 https://doi.org/10.1007/978-1-0716-2473-9_27
(2022).
Google Scholar
G. J. Goldey et al.,
“Removable cranial windows for long-term imaging in awake mice,”
Nat. Protoc., 9
(11), 2515
–2538 https://doi.org/10.1038/nprot.2014.165 1754-2189
(2014).
Google Scholar
H. Dana et al.,
“Sensitive red protein calcium indicators for imaging neural activity,”
eLife, 5 24 https://doi.org/10.7554/eLife.12727
(2016).
Google Scholar
M. A. Mohr et al.,
“jYCaMP: an optimized calcium indicator for two-photon imaging at fiber laser wavelengths,”
Nat. Methods, 17
(7), 694
–697 https://doi.org/10.1038/s41592-020-0835-7 1548-7091
(2020).
Google Scholar
S. Jiang et al.,
“Automated, highly reproducible, wide-field, light-based cortical mapping method using a commercial stereo microscope and its applications,”
Biomed. Opt. Express, 7
(9), 3478
–3490 https://doi.org/10.1364/BOE.7.003478 BOEICL 2156-7085
(2016).
Google Scholar
I. Ferezou et al.,
“Spatiotemporal dynamics of cortical sensorimotor integration in behaving mice,”
Neuron, 56
(5), 907
–923 https://doi.org/10.1016/j.neuron.2007.10.007 NERNET 0896-6273
(2007).
Google Scholar
X. P. Huang et al.,
“Aav2 production with optimized n/p ratio and pei-mediated transfection results in low toxicity and high titer for in vitro and in vivo applications,”
J. Virol. Methods, 193
(2), 270
–277 https://doi.org/10.1016/j.jviromet.2013.06.008 JVMEDH 0166-0934
(2013).
Google Scholar
M. Pachitariu et al.,
“Suite2p: beyond 10,000 neurons with standard two-photon microscopy,”
(2017). Google Scholar
C. Stringer, M. Michaelos and M. Pachitariu,
“Cellpose: a generalist algorithm for cellular segmentation,”
Nat. Methods, 18 100
–106 https://doi.org/10.1038/s41592-020-01018-x
(2021).
Google Scholar
J. D. Rolston et al.,
“Spontaneous and evoked high-frequency oscillations in the tetanus toxin model of epilepsy,”
Epilepsia, 51
(11), 2289
–2296 https://doi.org/10.1111/j.1528-1167.2010.02753.x EPILAK 0013-9580
(2010).
Google Scholar
M. Wenzel et al.,
“Reliable and elastic propagation of cortical seizures in vivo,”
Cell Rep., 19
(13), 2681
–2693 https://doi.org/10.1016/j.celrep.2017.05.090
(2017).
Google Scholar
J. Y. Liou et al.,
“Multivariate regression methods for estimating velocity of ictal discharges from human microelectrode recordings,”
J. Neural Eng., 14
(4), 044001 https://doi.org/10.1088/1741-2552/aa68a6 1741-2560
(2017).
Google Scholar
E. H. Smith et al.,
“Human interictal epileptiform discharges are bidirectional traveling waves echoing ictal discharges,”
eLife, 11 20 https://doi.org/10.7554/eLife.73541
(2022).
Google Scholar
V. Magloire et al.,
“Gabaergic interneurons in seizures: investigating causality with optogenetics,”
Neuroscientist, 25
(4), 344
–358 https://doi.org/10.1177/1073858418805002 NROSFJ 1073-8584
(2019).
Google Scholar
A. J. Trevelyan and C. A. Schevon,
“How inhibition influences seizure propagation,”
Neuropharmacology, 69 45
–54 https://doi.org/10.1016/j.neuropharm.2012.06.015 NEPHBW 0028-3908
(2013).
Google Scholar
M. Wenzel et al.,
“Acute focal seizures start as local synchronizations of neuronal ensembles,”
J. Neurosci., 39
(43), 8562
–8575 https://doi.org/10.1523/JNEUROSCI.3176-18.2019 JNRSDS 0270-6474
(2019).
Google Scholar
A. Somarowthu, K. M. Goff and E. M. Goldberg,
“Two-photon calcium imaging of seizures in awake, head-fixed mice,”
Cell Calcium, 96 102380 https://doi.org/10.1016/j.ceca.2021.102380 CECADV 0143-4160
(2021).
Google Scholar
C. H. Tran et al.,
“Interneuron desynchronization precedes seizures in a mouse model of Dravet syndrome,”
J. Neurosci., 40
(13), 2764
–2775 https://doi.org/10.1523/JNEUROSCI.2370-19.2020 JNRSDS 0270-6474
(2020).
Google Scholar
J. Mattis et al.,
“Corticohippocampal circuit dysfunction in a mouse model of Dravet syndrome,”
eLife, 11 30 https://doi.org/10.7554/eLife.69293
(2022).
Google Scholar
E. Baird-Daniel et al.,
“Glial calcium waves are triggered by seizure activity and not essential for initiating ictal onset or neurovascular coupling,”
Cereb. Cortex, 27
(6), 3318
–3330 https://doi.org/10.1093/cercor/bhx072
(2017).
Google Scholar
S. F. Muldoon et al.,
“Gabaergic inhibition shapes interictal dynamics in awake epileptic mice,”
Brain: J. Neurol., 138 2875
–2890 https://doi.org/10.1093/brain/awv227
(2015).
Google Scholar
S. F. Muldoon, I. Soltesz and R. Cossart,
“Spatially clustered neuronal assemblies comprise the microstructure of synchrony in chronically epileptic networks,”
Proc. Natl. Acad. Sci. U. S. A., 110
(9), 3567
–3572 https://doi.org/10.1073/pnas.1216958110
(2013).
Google Scholar
D. Hadjiabadi et al.,
“Maximally selective single-cell target for circuit control in epilepsy models,”
Neuron, 109
(16), 2556
–2572.e6 https://doi.org/10.1016/j.neuron.2021.06.007 NERNET 0896-6273
(2021).
Google Scholar
L. A. Lau, K. J. Staley and O. P. Lillis,
“In vitro ictogenesis is stochastic at the single neuron level,”
Brain: J. Neurol., 145
(2), 531
–541 https://doi.org/10.1093/brain/awab312
(2022).
Google Scholar
R. Enger et al.,
“Dynamics of ionic shifts in cortical spreading depression,”
Cereb. Cortex, 25
(11), 4469
–4476 https://doi.org/10.1093/cercor/bhv054
(2015).
Google Scholar
C. D. Verdugo et al.,
“Glia-neuron interactions underlie state transitions to generalized seizures,”
Nat Commun, 10 13 https://doi.org/10.1038/s41467-019-11739-z NCAOBW 2041-1723
(2019).
Google Scholar
F. Aeed et al.,
“Layer- and cell-specific recruitment dynamics during epileptic seizures in vivo,”
Ann. Neurol., 87
(1), 97
–115 https://doi.org/10.1002/ana.25628 ANNED3 0364-5134
(2020).
Google Scholar
F. T. Sparks et al.,
“Hippocampal adult-born granule cells drive network activity in a mouse model of chronic temporal lobe epilepsy,”
Nat. Commun., 11
(1), 13 https://doi.org/10.1038/s41467-020-19969-2 NCAOBW 2041-1723
(2020).
Google Scholar
J. Meyer et al.,
“Asynchronous suppression of visual cortex during absence seizures in stargazer mice,”
Nat. Commun., 9 9 https://doi.org/10.1038/s41467-018-04349-8 NCAOBW 2041-1723
(2018).
Google Scholar
J. E. Niemeyer et al.,
“Seizures initiate in zones of relative hyperexcitation in a zebrafish epilepsy model,”
Brain: J. Neurol., 145
(7), 2347
–2360 https://doi.org/10.1093/brain/awac073
(2022).
Google Scholar
M. L. Saggio et al.,
“A taxonomy of seizure dynamotypes,”
eLife, 9 56 https://doi.org/10.7554/eLife.55632
(2020).
Google Scholar
S. Kerruth et al.,
“The kinetic mechanisms of fast-decay red-fluorescent genetically encoded calcium indicators,”
J. Biol. Chem., 294
(11), 3934
–3946 https://doi.org/10.1074/jbc.RA118.004543 JBCHA3 0021-9258
(2019).
Google Scholar
J. V. Raimondo et al.,
“Ion dynamics during seizures,”
Front. Cell. Neurosci., 9 14 https://doi.org/10.3389/fncel.2015.00419
(2015).
Google Scholar
H. Dana et al.,
“High-performance calcium sensors for imaging activity in neuronal populations and microcompartments,”
Nat. Methods, 16
(7), 649
–657 https://doi.org/10.1038/s41592-019-0435-6 1548-7091
(2019).
Google Scholar
L. R. Silva, Y. Amitai and B. W. Connors,
“Intrinsic oscillations of neocortex generated by layer-5 pyramidal neurons,”
Science, 251
(4992), 432
–435 https://doi.org/10.1126/science.1824881 SCIEAS 0036-8075
(1991).
Google Scholar
T. F. Freund and G. Buzsaki,
“Interneurons of the hippocampus,”
Hippocampus, 6
(4), 347
–470 https://doi.org/10.1002/(SICI)1098-1063(1996)6:4<347::AID-HIPO1>3.0.CO;2-I
(1996).
Google Scholar
G. Buzsaki, C. A. Anastassiou and C. Koch,
“The origin of extracellular fields and currents - EEG, ECoG, LFP and spikes,”
Nat. Rev. Neurosci., 13
(6), 407
–420 https://doi.org/10.1038/nrn3241 NRNAAN 1471-003X
(2012).
Google Scholar
F. Ali and A. C. Kwan,
“Interpreting in vivo calcium signals from neuronal cell bodies, axons, and dendrites: a review,”
Neurophotonics, 7
(1), 17 https://doi.org/10.1117/1.NPh.7.1.011402
(2020).
Google Scholar
P. Kwan and M. R. Sperling,
“Refractory seizures: try additional antiepileptic drugs (after two have failed) or go directly to early surgery evaluation?,”
Epilepsia, 50 57
–62 https://doi.org/10.1111/j.1528-1167.2009.02237.x EPILAK 0013-9580
(2009).
Google Scholar
J. M. Rho and H. S. White,
“Brief history of anti-seizure drug development,”
Epilepsia Open, 3
(Suppl 2), 114
–119 https://doi.org/10.1002/epi4.12268
(2018).
Google Scholar
C. B. Josephson et al.,
“Systematic review and meta-analysis of standard vs selective temporal lobe epilepsy surgery,”
Neurology, 80
(18), 1669
–1676 https://doi.org/10.1212/WNL.0b013e3182904f82 NEURAI 0028-3878
(2013).
Google Scholar
R. E. Gross et al.,
“Stereotactic laser amygdalohippocampotomy for mesial temporal lobe epilepsy,”
Ann. Neurol., 83
(3), 575
–587 https://doi.org/10.1002/ana.25180 ANNED3 0364-5134
(2018).
Google Scholar
M. J. Morrell, RNS System in Epilepsy Study Group,
“Responsive cortical stimulation for the treatment of medically intractable partial epilepsy,”
Neurology, 77
(13), 1295
–1304 https://doi.org/10.1212/WNL.0b013e3182302056 NEURAI 0028-3878
(2011).
Google Scholar
V. Salanova et al.,
“Long-term efficacy and safety of thalamic stimulation for drug-resistant partial epilepsy,”
Neurology, 84
(10), 1017
–1025 https://doi.org/10.1212/WNL.0000000000001334 NEURAI 0028-3878
(2015).
Google Scholar
E. R. Cole et al.,
“Evidence supporting deep brain stimulation of the medial septum in the treatment of temporal lobe epilepsy,”
Epilepsia, 63
(9), 2192
–2213 https://doi.org/10.1111/epi.17326 EPILAK 0013-9580
(2022).
Google Scholar
S. Khoshkhoo, D. Vogt and V. S. Sohal,
“Dynamic, cell-type-specific roles for gabaergic interneurons in a mouse model of optogenetically inducible seizures,”
Neuron, 93
(2), 291
–298 https://doi.org/10.1016/j.neuron.2016.11.043 NERNET 0896-6273
(2017).
Google Scholar
R. C. Wykes et al.,
“Optogenetic approaches to treat epilepsy,”
J. Neurosci. Methods, 260 215
–220 https://doi.org/10.1016/j.jneumeth.2015.06.004 JNMEDT 0165-0270
(2016).
Google Scholar
Y. Takeuchi et al.,
“Closed-loop stimulation of the medial septum terminates epileptic seizures,”
Brain: J. Neurol., 144
(3), 885
–908 https://doi.org/10.1093/brain/awaa450
(2021).
Google Scholar
T. A. Spix et al.,
“Population-specific neuromodulation prolongs therapeutic benefits of deep brain stimulation,”
Science, 374
(6564), 201
–206 https://doi.org/10.1126/science.abi7852 SCIEAS 0036-8075
(2021).
Google Scholar
E. R. Cole et al.,
“Irregular optogenetic stimulation waveforms can induce naturalistic patterns of hippocampal spectral activity,”
(2022). Google Scholar
S. E. Park et al.,
“Optimizing neuromodulation based on surrogate neural states for seizure suppression in a rat temporal lobe epilepsy model,”
J. Neural Eng., 17
(4), 046009 https://doi.org/10.1088/1741-2552/ab9909 1741-2560
(2020).
Google Scholar
E. R. Cole et al.,
“Autonomous state inference for data-driven optimization of neural modulation,”
in 10th Int. IEEE-EMBS Conf. Neural Eng. (NER),
950
–953
(2021). https://doi.org/10.1109/ner49283.2021.9441385 Google Scholar
E. Krook-Magnuson et al.,
“On-demand optogenetic control of spontaneous seizures in temporal lobe epilepsy,”
Nat. Commun., 4 1376 https://doi.org/10.1038/ncomms2376 NCAOBW 2041-1723
(2013).
Google Scholar
BiographyMatthew A. Stern is currently an MD/PhD candidate at Emory University completing his neuroscience PhD under the advisory help of Robert Gross. He received his BS degree in biology from Haverford College in 2011. He is interested in the use of functional optical imaging modalities to advance our understanding of the basic mechanisms of neurological disease, in particular epilepsy, and their utility to inform neurosurgical treatments. Eric R. Cole is currently a PhD candidate in the joint biomedical engineering program at Emory University and Georgia Institute of Technology under the advisory help of Robert Gross. He received his BS degree in bioengineering and electrical engineering from Cornell University in 2018. He is interested in developing real-time algorithmic methods for precision brain stimulation. Robert E. Gross is the MBNA/Bowman Endowed Chair in Neurosurgery at Emory University with appointments in Neurology and the Coulter Department of Biomedical Engineering of Emory/Georgia Institute of Technology. He directs the Emory Neuromodulation Technology Innovation Center and the Translational Neuro-engineering Research Lab. He received his ScB degree in neural science from Brown University in 1981 and his MD and PhD degrees in molecular pharmacology from Albert Einstein College of Medicine in 1990 under the advisory assistance of Charles Rubin. Ken Berglund is assistant professor of neurosurgery at Emory University and leads various imaging projects in the Translational Neuro-engineering Research Lab. He completed his BA degree in 1997 and PhD in 2002 both in psychology at the University of Tokyo under the advisory assistance of Masao Tachibana and postdoctoral training at Duke University under the advisory help of George J. Augustine. |
Calcium
Electroencephalography
Two photon imaging
Signal to noise ratio
Wavefronts
Signal detection
Detection and tracking algorithms