Abstract
We have developed an open-source software for neuroscientists to analyze electrophysiological recordings. Named SimplyFire, the software gives the users the flexibility to analyze a variety of recordings using an interactive graphical user interface or as an importable Python package. The software features a simple plugin structure that allows users to create and deploy various electrophysiology analysis tools. SimplyFire is pre-packaged with tools commonly used in electrophysiology, such as noise filtering, trace averaging, miniature analysis, and trace exporting. We discuss in detail the algorithm behind the different features of the analysis tool. We verify the accuracy of the algorithm by testing the software using computer-generated traces with known true values of the events. SimplyFire will be distributed under the GPLv3.0 license. The open nature of this software will allow interested investigators to modify and expand the software for additional capabilities as needed. We believe this software will not only compete with commercially available software packages but will also present a powerful tool to meet the current and unmet needs of electrophysiologists.
Significance Statement
Accurate and efficient analysis of synaptic events is a challenge and requirement for many electrophysiologists. Several proprietary programs have been developed commercially over the years that offer options for analyzing synaptic events, but the algorithms behind such programs are often hidden, and they rarely offer any flexibility for the generation of user-based modules aimed at specific requirements of individual users. Our newly generated software, SimplyFire, meets this unmet need by offering a powerful and efficient algorithm for analyzing synaptic events in Python, while allowing flexibility to adapt to specific users’ needs. Importantly, SimplyFire is freely available to the community and can evolve and be expanded by users.
Introduction
Detection and analysis of synaptic events, such as evoked and spontaneous/miniature excitatory postsynaptic currents (EPSCs and mEPSCs) or inhibitory postsynaptic currents [induced pluripotent stem cells (iPSCs) and mIPSCs], are essential for understanding changes in synaptic plasticity and circuit function. In particular, because of their small size, fast kinetics, and stochastic nature, mEPSCs and mIPSCs require specialized computational methods for fast and efficient analysis. Several proprietary programs have been developed commercially over the years to measure these synaptic events, but the algorithms behind such programs are often hidden, and they rarely offer any flexibility for the generation of user-based modules aimed at the specific requirements of individual users. Recently, efforts have been made to develop free, open-source algorithms for electrophysiology analysis (Siegle et al., 2017; Nasiotis et al., 2019; Kim et al., 2021); however, efficient and user-friendly open-source programs remain sparse. To address this issue, we have developed SimplyFire, an open-source graphical user interface (GUI) package for detecting and analyzing both spontaneous miniature synaptic events as well as evoked synaptic currents and potentials.
We have chosen to develop SimplyFire in Python, a free, open-source programming language. Python is a simple high-level programming language that is popular among biologists, making it more likely that the software can be read and understood in its entirety by many electrophysiologists. Moreover, Python does not require compilation, allowing for fast distribution and development.
SimplyFire is pre-packaged with other post-acquisition tools, such as noise reduction, baseline subtraction, and statistical analyses. SimplyFire can thus be incorporated into the analysis workflow immediately after the acquisition of the electrophysiology data. Additionally, the software is equipped with the capacity to incorporate packages developed by users, providing an opportunity for the software to grow with community input. Here, we describe the architecture of the algorithm underlying SimplyFire. We further assess the performance of SimplyFire to detect synaptic events, using both recorded and simulated data, as compared to a popular commercial software that is no longer supported. Finally, we demonstrate the ability of SimplyFire to single-handedly complete the post-acquisition workflow using recordings of D. melanogaster larval neuromuscular junction (NMJ).
Methods
Artificial data generation
For the data analyzed in Figure 3A–E and the sine wave noise (data not shown), the artificial miniature postsynaptic events were generated according to the equation as follows:
Here,
t is the time in milliseconds from the start of the event, the parameters were chosen such that the time of the local maximum ranged from approximately 2–10 ms, and the time after the maximum for the curve to decay to
The equation of each event was evaluated out to
Sharper events more closely approximating current data (Figs. 3F, 4) were generated by a piecewise function given by the following:
For the sine wave noise, a function
For the data with “hum” (Fig. 5), the random noise was generated according to the same function as above, but a hum of the form
Electrophysiology
Drosophila larval NMJ
We used a standard two-electrode voltage clamp as previously performed (Tsurudome et al., 2010). Briefly, wandering third instar larvae were dissected and rinsed multiple times in a cold calcium-free HL3 solution (Stewart et al., 1994). Synaptic events (mEJC and EJC) were then measured at muscle 6 in segment A3 using an amplifier (AxoClamp 2B; MDS Analytical Technologies) in two-electrode voltage clamp mode for recording miniature or evoked excitatory junctional currents (mEJCs or EJCs) or in current clamp mode to record miniature junctional potentials (mEJPs). For evoked responses, a third suction/stimulating electrode was used to stimulate the appropriate nerve bundle. All recordings were performed at room temperature in HL3 with 0.5 mM external Ca2+, and muscles were held at −80 mV.
Human iPSC-derived human neurons
Miniature excitatory postsynaptic current (mEPSC) recordings were performed on 8.5 weeks old human excitatory glutamatergic neurons that were differentiated from iPSCs using neurogenin 2 (NGN2). Whole-cell voltage clamp was performed in an external bath solution (140 mM NaCl, 5 mM KCl, 2.5 mM CaCl2, 2 mM MgCl2, 10 mM HEPES, 10 mM glucose, pH 7.4) with 0.5 mM tetrodotoxin, and the internal solution used contained 120 mM CsCl2, 5 mM NaCl, 1 mM MgCl2, 10 mM HEPES, 1 mM EGTA, 4 mM Mg-ATP, 0.3 mM Na3GTP, and 10 mM QX-314. The membrane potential was held at −60 mV.
Code accessibility
All source code for SimplyFire is available on GitHub at http://github.com/HaghighiLabBuck/SimplyFire. It is released under the GNU General Public License (GPL) Version 3.
Results
Electrophysiology analysis workflow overview
Various sets of tools are supplied in the base distribution of SimplyFire to fit the needs of electrophysiologists. A user can import a recording encoded in Axon Binary Format (ABF) into SimplyFire for analysis. Filtering, baseline subtraction, and segmentation can be applied as necessary to process the recording before analysis. Individual spontaneous and/or evoked synaptic events (hereafter called “events”) can be detected and analyzed using the “Mini” feature. Alternatively, for experiments designed to have events aligned in time (such as evoked EPSC/IPSC recordings), the traces can be averaged to obtain a representative event trace and further analyzed (Fig. 1A). Then, the results and statistics can be saved as a CSV file for further processing (e.g., synaptic strength quantification and significance testing).
Software architecture
A modular software architecture allows customization and extensibility
The SimplyFire code is broadly organized into four portions (Fig. 1B):
The basic user interface, consisting of a main window containing space for plugin sub-windows, a plotting canvas for voltage or current time traces, an output table for results of analyses, and an action log
A “controller” component that handles Tkinter events triggered by user interaction with the app as a whole
A class called recording that acts as a wrapper around numerical arrays of time and current/voltage values, as well as invoking necessary file parsers for loading and saving of data
A set of plugins for processing tasks
The basic user interface
The GUI (Fig. 1C) is built using the Tkinter Python interface to the widget toolkit Tcl/Tk. The plot display panel wraps an instance of the matplotlib plotting library (Hunter, 2007), with custom widgets and code for navigation (zooming and panning). A toolbar at the top of the window allows load/save operations as well as opening plugin sub-windows. The log window shows a text-based list of recent actions, while the results table is designed for numerical data organized in rows, e.g., a list of detected events and their associated kinetic parameters.
In order to enable the opening of long (1 h or greater of total length among all sweeps) recordings even on computers with limited memory, care was taken to reduce the amount of data held by the plotting window to what is currently displayed within the axis bounds. User navigation triggers fetching of the required subset of current or voltage data from the recording object in concert with the rescaling of the axes themselves, and the X (time) values are generated on the fly by the recording object (see below).
The controller component
This component consists of an interface and an interpreter. The interface mediates communication between the recording object and the trace, handles file and channel selection, and implements a stack of function calls to enable undo functionality, to which plugins can push functions of their own. The interpreter handles keyboard and mouse inputs that manipulate the plot.
The recording class
This class uses the pyabf (Harden, 2022) Python parser for ABF files for reading and writing multi-trace recordings and also allows input and output of single data channels as CSV files. The current/voltage values are stored in NumPy (Harris et al., 2020) arrays within this class, while the time values are generated on demand when data within a given time interval is requested. Other components, particularly the plugins, can access the data for processing by querying member functions to extract a specific subset of channels and/or sweeps and a relevant interval of time.
The plugin module
This consists of the plugins themselves, as well as a framework of support components within the base software. All analyses are performed by individual plugins, which are loaded by a plugin manager component. A custom-made plugin can be added to the software by creating a meta-file and a Python code within the plugin module. Each plugin can have its own GUI component to request user input in the Plugin Window, listen to user interaction with the electrophysiology trace plot and data table via the interpreter, modify the trace plot to display additional curves or markers on top of the data traces, or add numerical entries to a plugin table by passing a pandas DataFrame (McKinney, 2010). There are several additional Python classes provided for plugins to use, such as forms and popup windows.
Plugins
SimplyFire includes many plugins, primarily focused on data filtering, event detection, and trace averaging, as well as for the selection of traces, navigation through the duration of a recording, and changing the stylistic attributes of the trace display.
The “Process” plugin allows several common preprocessing actions for recordings, in particular baseline subtraction, trace averaging, and filtering. The boxcar and Bessel filters are the two filtering algorithms included at this time and are based on the NumPy convolution and SciPy (Virtanen et al., 2020) signal processing functions, respectively. The trace averaging, which is intended primarily for analysis of evoked postsynaptic events, makes no attempt to align the traces in time, so it is only useful when they are pre-aligned.
The “Evoked” plugin provides basic processing operations that are useful for quantifying evoked postsynaptic events. These are calculating the minimum and maximum data point in each trace/sweep, and reporting the mean and standard deviation of these minimum and maximum values in the results table.
The “Mini” plugin is the most complex component of SimplyFire, and its algorithm is described in detail in the following section. This algorithm is used for the detection of events by filtering according to criteria, including amplitude and rise/decay times. While intended for analysis of miniature excitatory postsynaptic/junctional potentials (mEPSPs/mEJPs) or currents (mEPSCs/mEJPs), it can be in principle used for detection of any event that involves a transient de- or hyperpolarization, whenever the time of the event is unknown and noise robustness is necessary.
Algorithm for analysis of miniature events
The Mini Detection package in SimplyFire is used to analyze spontaneous miniature synaptic events. This plugin is used to automatically detect miniature postsynaptic events and accepts a variety of parameters from the user. The user can choose to perform two types of analyses: automated and manual. In automated analysis, the plugin scans a user-defined time window and annotates all minis found according to the parameters (Fig. 2A). The search radius per iteration is determined by the auto_diameter parameter (“Search window in ms (Auto)” within the GUI), and the algorithm shifts the window by half the diameter every iteration. In the manual mode, the plugin searches for a single mini centered around a location where the user clicks on the electrophysiology trace. The search window in the manual mode is defined by the percentage of the visible time axis, which is used to calculate the search_radius.
The algorithm begins by detecting the global extrema (maxima for events that lie above the baseline or minima for events that lie below) of the trace within the search window. Once a global extremum is found, the algorithm scans backward in time from this data point to locate the onset. The backward scan involves comparing each point in the trace with a moving average of a specified number of preceding data points (Fig. 2B). The first visited (i.e., latest in time) point that is on the opposite side of the average from the peak (i.e., below the average for events above the baseline, or vice versa) is selected as the time point immediately preceding the event, and hence the subsequent data point is the first assigned as belonging to the event.
There is a user-controlled option to use the average of a window located a fixed distance to the left of the candidate peak as the baseline instead of the moving average. This is intended to be used when the baseline immediately preceding the onset of a mini is corrupted by high noise or some other source of error. It is important to average over enough preceding data points so that local drift in the baseline or jaggedness in the rising phase of an event due to noise is not mislabeled as the time of onset.
This algorithm is loosely based on Brakel's algorithm (Brakel, 2014), with the key difference that the latter calculates an average preceding every point in the data, whereas ours only calculates one series of moving averages in the vicinity of the global maximum or minimum of each search window. This reduces the computation time considerably given the long baseline segments that must be averaged to compensate for the level of noise in our data. In addition, rather than using the standard deviation of the baseline as the cutoff to determine the transition between baseline and event, we use the simple crossing point of the smoothed and actual data. Hence, Brakel's method is best suited for detecting short sequences of outliers within data of otherwise relatively low variability, whereas ours is more efficient for detecting features defined by prolonged deviations from a varying baseline.
To determine the decay properties of the mini, the algorithm uses the data points forward from the peak. The forward curve fitting is performed using the Levenberg–Marquardt gradient descent algorithm as implemented in the curve_fit function of SciPy. Currently, a single exponential is the only curve that can be fit, as this makes defining a single decay constant (τ) for the mini meaningful and is also the most common choice of function used to model the shape of synaptic events (Kandel et al., 2000). However, for users with programming skills, other functional forms can be added by modifying the plugin code to define additional curves and passing them to the curve fitting function instead. There is also an option to define tau in a curve shape–agnostic manner as the time interval from the peak to the earliest point at which the amplitude has decayed to 1/e times the amplitude of the peak—this is equivalent to the result of the curve fitting for data that follow a true single exponential decay.
When designing the algorithm for this plugin, care was taken to ensure proper handling of both single events and “compound” events, the latter being defined as events whose distance along the time axis is too short to separate the decay of one event from the rise of another event. There is a trade-off involved here, as the second (or third and subsequent) event in a compound series is often not preceded by a segment of nearly constant (i.e., “flat”) signal that can be used to define a baseline, requiring the detection of the event onset to be based essentially on local properties of the trace immediately preceding the event. Conversely, it is important that whenever possible, the fit of an event is minimally biased by noise immediately preceding the onset. The determination of whether a pair of events constitutes a “compound” event is done by a user-provided value that defines the minimum required separation between two peaks to use single event analysis.
When this compound event detection is enabled, and when two peaks are detected that are closer in time than the specified threshold, the following algorithm is used (Fig. 2C). The software determines if there exists a data point between the peaks that is closer to the baseline than a user-selected percentage of the earlier peak's amplitude, which we term the “valley percentage.” If such a point is found, the later peak is considered a separate event, the point of minimum amplitude is marked as the start of the later mini, and the fitted decay curve (see above) for the earlier mini is used to subtract that mini from the region of overlap to provide a more accurate baseline (and hence amplitude) for the later mini.
There are a variety of filtering criteria that can be applied to reject unwanted events. Both minimum and maximum values for the amplitude can be specified, as for the rise time, half-width, and decay time constant. As soon as one of these conditions is found to be violated, the mini is rejected and the software proceeds to the next peak.
As various parameters can alter whether a set of data points is considered noise or a proper event, we have provided an additional feature called the parameter guide (Fig. 1C, right). This feature provides a popup window that shows the peak location, amplitude, rise time, and fitted decay curve superimposed on a zoomed-in view of the trace whenever either a manual mini detection is attempted or a pre-detected mini is selected in the results table. The guide can provide insight into why a feature was accepted or rejected as a mini or allow troubleshooting/verification when the value(s) of any detected parameter(s) seems unreasonable to the user.
Validation of the algorithm
To determine the effectiveness of the algorithm packaged within the MiniAnalysis plugin, we generated mock recording data whose miniature event properties are known and compared the true values against the estimates generated by SimplyFire (see Methods). In order to test the resilience of the algorithm to the degree of noise that is inherent to electrophysiological recordings, we added an artificially generated noise term to these idealized data traces.
First, we modeled “noise” using a sine wave, which allowed us to precisely bind the displacement of the key features of each mini on both the x (time) and y (potential/current) axes. We found that using this noise the algorithm detected the correct time-axis position of the minis, and the estimated amplitudes matched the true values with high accuracy (r2 = 1.0 and 0.999, respectively). The estimated values for 10–90 rise time and the decay time constant (τ) also had a high correlation with the true values (r2 = 0.987 and 0.992, respectively).
To further approximate realistic recordings, we next used a random noise term that was correlated over consecutive data points, to most closely model the type of noise that is present in typical electrophysiology recordings (see Methods). The positions of the peaks in the time axis were detected accurately by SimplyFire. The amplitude estimates performed slightly worse but still very acceptably. The 10–90 rise time and the decay time constant estimates suffered slightly from the introduction of random noise, but the linear correlation between the true values and the estimates was maintained (Fig. 3A–E).
The mock events used in these last two data sets had the form of a product of a rising and a decaying exponential, giving the curve a rounded shape near the point of maximum amplitude, similar to membrane potential data in real recordings. We also tested sharper events consisting of a linear rise followed by a single exponential decay (Fig. 3F), which more closely approximates current traces in voltage clamp experiments. On this type of data, SimplyFire was better able to recover the 10–90 rise time of events (r2 = 0.992), but surprisingly was no better able to measure the decay constants (r2 = 0.981), despite them having a true single exponential form.
During electrophysiological recordings, alternating current sources in the vicinity of the recording equipment can introduce a 50–60 Hz “hum” to recorded data. Therefore, as a final and strict test of our software's event detection ability, we generated a mock recording in which a 0.2 nA, 50 Hz sine wave plus 0.1 nA correlated random noise were added to events with amplitudes in the range 0.5–2.5 nA, with decay constants in the range 5–25 ms (for comparison, the period of a 50 Hz sine wave is 20 ms). Despite the fact that the half-width of the events was of the same order of magnitude as the sinusoidal fluctuations, and the smallest event amplitudes were comparable to the maximum peak-to-peak range of the noise (0.6 nA), true events were still detected, while the amplitude peaks of the hum that did not coincide with events were ignored (Fig. 4A,B). In a recording containing 142 true events, SimplyFire detected all but one of them, while the commonly used software MiniAnalysis (Synaptosoft; see now defunct website: https://web.archive.org/web/20210614022620/http://synaptosoft.com) missed seven events. Furthermore, amplitudes were reported with comparable accuracy to MiniAnalysis using equivalent parameter values, provided that the parameters were configured to make the distance between the baseline averaging window and the peak approximately equal to the period of the hum (in our case, ∼20 ms).
In testing our software, we also used several recordings containing high-amplitude artifacts, both from larval NMJ and from human iPSC-derived neurons in culture (Fig. 5A,B). When running SimplyFire on these recordings, we were able to configure the software to detect true events throughout while ignoring these artifacts, provided that the maximum amplitude cutoff chosen is between the maximum amplitude of the events and that of the artifacts (in the cases shown, a cutoff of ∼100 pA for mEPSCs in human neurons and ∼10 mV for mEJPs in larval NMJ). In any case, the presence of artifacts does not interfere with the detection of true events, even when, as seen in Figure 5C, events occur within a reasonably flat baseline that is nonetheless displaced considerably by an artifact from that in the remainder of the recording.
In order to compare the performance of SimplyFire with the commonly used MiniAnalysis software, we analyzed a sample of mEJC recording from larval NMJ. We found that the two programs highly agreed on the amplitudes of the detected minis (Fig. 6A,B). Finally, we tested whether the “compound” event detection feature, which is useful for detecting events that begin before the preceding event has decayed to baseline, can be used to analyze high-frequency trains of evoked synaptic potentials at the larval NMJ. As shown in Figure 6C, the individual events in such a series are detected, provided that the search window and the minimum separation between successive events are set short enough. The reader should be aware, however, that the amplitudes reported should be recalculated to present the amplitude from baseline measurements. The event detection follows the assumption, integrated into the Mini plugin, that overlapping events are summed, meaning that the amplitudes of later events are measured from the point to which the previous event had decayed rather than from the original baseline.
Spontaneous and evoked synaptic events are commonly analyzed to investigate mechanisms of synaptic homeostasis and synaptic compensation. At the Drosophila larval NMJ, genetic or pharmacological inhibition of postsynaptic glutamate receptor subunit GluRIIA reduced the average size of miniatures (mEPSCs/mEJCs), which triggers a retrograde enhancement in presynaptic neurotransmitter release also known as presynaptic homeostatic plasticity (PHP; Petersen et al., 1997; Frank et al., 2006; Penney et al., 2012). Figure 6D shows an example of PHP as a result of the postsynaptic expression of expression of GluRIIA[M/R], a dominant negative mutant (DiAntonio et al., 1999). In larvae expressing GluRIIA[M/R], mEPSC amplitudes are reduced while EJCs are maintained via presynaptic compensation. In order to demonstrate that the algorithm in SimplyFire can detect and quantify differences in spontaneous miniature synaptic event amplitudes, we compared the EJC, mEPSC, and quantal content (QC) of larvae expressing GluRIIA[M/R] to those expressing LacZ (control). As previously described, larvae expressing GluRIIA[M/R] showed >45% reduction in average mEJP amplitude and a compensatory increase in QC of >175% compared to control (Fig. 6D). The EPSC was not significantly different between the two genotypes.
Discussion
We have created a freely available, open-source, and extensible software tool for the analysis of miniature postsynaptic events and for some other common tasks in electrophysiology data processing, such as noise filtering and baseline subtraction. It features a simple, intuitive user interface for interactive event detection and allows plugins to be created using the Python programming language to perform other tasks. This allows users of our software to distribute additional tools to the electrophysiology community.
We have verified the accuracy of our software on both synthetic data sets and synaptic recordings from Drosophila and shown it to be comparable to that of existing tools. The only cases where SimplyFire poorly fits data involve noisy events that are difficult for almost any software. In order to assist in dealing with such cases, a large range of detection parameters can be tuned and used to filter candidate events. This should extend the applicability of our software to a variety of systems where typical events differ greatly in amplitude and kinetics.
While other capabilities can be added by extending the software, the current plugins in SimplyFire can perform post-acquisition processing of the recording data, including noise reduction via filtering, baseline subtraction, and trace averaging. By utilizing such capabilities, SimplyFire can be incorporated into the experimental workflow immediately after data acquisition. We also added a plugin to analyze evoked synaptic activity amplitude, which can be performed by calculating the peak amplitude of the averaged trace. Details of each plugin can be found in the software documentation (https://simplyfire.readthedocs.io/).
The software is available as a stand-alone “zipped” executable or as a Python package. For Python users, SimplyFire can be installed using the “pip” package manager, while a “zipped” folder containing a Windows executable and all its dependencies is downloadable from the project's GitHub page (www.github.com/HaghighiLabBuck/simplyfire). The ready-to-run executable is the most accessible for users unfamiliar with the Python package ecosystem, whereas the package is useful for those who want to adapt and customize the software for their particular needs.
Footnotes
The authors report no conflict of interest.
We thank the members of the Haghighi Lab for their support, in particular, Olfat Malak for discussions and Myriam Mujahidine for technical support. We thank the Bloomington Stock Center for fly stocks. We would also like to thank Dr. Tara Tracy for support with human iPSC-derived neurons and useful discussions. J.F. was a recipient of a T32 postdoctoral fellowship. This work was funded by the NIH grant R01NS082793 provided to A.P.H.
↵* M.M. and A.R. contributed equally to this work.
This is an open-access article distributed under the terms of the Creative Commons Attribution 4.0 International license, which permits unrestricted use, distribution and reproduction in any medium provided that the original work is properly attributed.