Introduction

Invasive electrode recordings are a unique source of in-vitro and in-vivo neurophysiological data at high resolution in both space and time, recorded in relation to complex animal and human behavior. The complexity of this kind of data has increased in recent years, with the advent of increasingly dense multi-channel and multi-site electrode arrays. This evolution provides exciting opportunities to explore the relationship between local events, such as action potentials, and more global dynamics at the systems level, such as fluctuations in oscillatory network activity. At the same time, these multiscale explorations require different analytical methods from those traditionally used in the field.

Challenges in exploring high-dimensional spatio-temporal data sets are not specific to electrophysiology: they occur frequently in neuroimaging data, as scanners produce increasingly large volumes of data, which are often shared across multiple groups or research centres. In response, the brain imaging community has made significant strides in developing shared software platforms to harmonize analytical methods and to facilitate data sharing1,2,3,4,5,6. Indeed, free, open-source software toolkits have been critical for facilitating training and augmenting research productivity. This approach has transferred to the field of scalp electrophysiology7, but as of yet it has not found widespread use in invasive neurophysiology (IN). Software tools do exist for specific segments of the IN data workflow, such as for spike detection and sorting and time-series analysis8,9,10,11,12,13,14,15, but they remain relatively specialized, some with limited support and documentation and most with restricted interoperability with other tools.

While we acknowledge significant efforts in harmonizing data formats for electrophysiology (Refs16,17,18, Neuroshare - http://neuroshare.sourceforge.net/index.shtml), it does seem that this field lags behind others in meeting the demands of recommended practices for data management and transparency19,20. In this regard, well-supported software tools are required to produce analytical workflows that are validated, well documented and reproducible. Important components include data organization, review and quality control, verified implementations of signal extraction and decomposition methods, solutions for advanced visualization registered to anatomy, and sound approaches to machine learning and statistical inference. As in the brain imaging field, such tools would facilitate the reproducibility of published results and the dissemination of methods within and between research groups. They would also save considerable time and resources currently required to re-code published methods. In addition, re-coding presents challenges in code verification relative to a published method, raising possible concerns about the validity of the end results and limiting the long-term value of the effort.

Here we deploy and share open-source software (called Invasive Neurophysiology-Brainstorm, or IN-Brainstorm) that integrates multiple aspects of data analysis for most modalities and signal types for basic electrophysiology: from single cells to distributed channel arrays, from spiking events to local field potentials, from ongoing recordings to event-related responses, and from in vitro preparations to free-behaving models. We also emphasize the importance of an extensive graphical interface for user-friendly access to advanced analytical methods, of flexible scripting features for high-performance computing, and of traceable code execution. The proposed tool is accompanied by extensive online documentation and support from a user community web forum.

This free application builds on the foundations of the Brainstorm platform6, which is well-established (21,000 user accounts), free open-source software for magnetoencephalography (MEG) and electroencephalography (EEG). Brainstorm can integrate multimodal data volumes in addition to scalp electrophysiology e.g., magnetic resonance imaging (MRI), CT-scans and functional near-infrared spectroscopy (fNIRS). It also features advanced source modeling for electrophysiological signals.

The IN-Brainstorm application provides a comprehensive suite that interoperates with other, more specific and constantly evolving IN tools available from the open-source community e.g., for performing spike sorting. The end result is a unique and expansive software toolkit that bridges across recording scales and data modalities, registers invasive neurophysiology with structural anatomy data, and thereby delivers a unifying analytical environment to the neurophysiology research community.

Results

The IN-Brainstorm functionalities described here offer comprehensive solutions for data importation and analysis, including spike-sorting, extraction of local field potentials, and correlations among these measures across multiple channels. Importantly, thanks to an intuitive graphical user interface, no programming skills are required for accessing and using the advanced methods available, including for assembling and sharing advanced data analysis pipelines. A summary of these software features is provided in Table 1, and a schematic of the workflow enabled by the toolbox is shown in Fig. 1.

Table 1 Synopsis of the e-Phys toolbox and the tools that can be used for LFP analysis.
Fig. 1
figure 1

Workflow of the e-Phys toolbox. Users initially import the header to the raw binary signal. Once the data is identified, the users perform the spike-sorting step. The spike-sorting process is divided into two parts: Unsupervised (the algorithm creates neuronal clusters automatically) and Supervised (the user inspects the output of the unsupervised part). At this point of the workflow, the LFP can be extracted. All the spiking events that were previously computed, and the down-sampled LFP signals, are all encapsulated to a single binary file. The original binary file can be stored to an external source and is no-longer needed. Finally, users can now perform preprocessing and analyze their data, utilizing the spike-related functions that have been introduced to Brainstorm by this toolbox.

The bedrock of the present developments is the Brainstorm platform. Brainstorm6 is written in Matlab (Matlab2008a and higher) and Java. It is therefore independent of the operating system (Windows, MacOS and Linux). Community code management is via GitHub. Users without access to a Matlab license can use a fully executable version of the application compiled for the above operating systems. Extensive documentation is freely available online, with specialized tutorials, datasets and videos (https://neuroimage.usc.edu/brainstorm/e-phys/Introduction). A thorough comparison of Brainstorm and other open source toolboxes was published recently21.

In the following sections, we describe a broad spectrum of analysis options for multiscale electrophysiology that are enabled by IN-Brainstorm and illustrate these features with the processing of an example raw data file.

Importing, reviewing and pre-processing raw data

Raw data importation

Data to be analyzed must first be imported into the software. Brainstorm can read raw electrophysiology data from 80 different file formats. We have added new data formats specific to single- and multi-unit electrophysiology, including Plexon (.plx, .pl2), Blackrock (.nsX), Ripple (.nsX), Intan (.rhd, .rhs), Tucker Davis Technologies, and Neurodata Without Borders (.nwb). New formats can be added on demand. Raw data can also be read directly from ASCII and basic binary data formats, with header file parameters easily specified from a GUI.

Data review

Raw files of continuous data from chronic preparations can be voluminous due to hours-long durations, tens of kilo-Hertz sampling rate and simultaneous recording from multi-channel electrode arrays. Hence loading such large raw files at once into computer memory can be impractical. For this reason, we have implemented efficient data review solutions of the raw signals, that load portions of the raw data on the fly depending on the visualization parameters set by the user (e.g., virtual page length, selection of a subset of channels or montages for review, keyboard and mouse shortcuts for navigating and marking events).

Task events (e.g., stimulus types and presentation times, behavioral responses) and ancillary recordings (electrooculograms, electrocardiogram, eye and body movements, video recordings of behaviour, etc.) are readily registered to the electrophysiological data in IN-Brainstorm, for multimodal data review, quality control and event-related processing. We emphasize that when a raw file is reviewed, the physical data is not duplicated as a Brainstorm file. Instead, the header of the original data file is automatically parsed to extract metadata, such as channel parameters, sampling rate, time stamps, event codes, etc.

Figure 2 (left) shows an example of IN-Brainstorm display for data review, including sub-menus for displaying and navigating through files and events. The right panel shows an example of raw data collected with a Plexon MAP system and a 32-channel linear electrode implanted in cortical areas MT and MST of a non-human primate. The animal maintained fixation during the presentation of a motion stimulus comprising of dots that translated in 8 different directions.

Fig. 2
figure 2

Dataset navigation and pre-processing windows. Left: (a) Main Brainstorm window showing the created dataset entry (ytu288c-01) on the data-tree section. (b) Selection of starting time point and duration of signal segment to be loaded for reviewing. (c) Experimental and spiking events are displayed. (d) An event is selected from the “Stim on 0” condition. This selection automatically synchronizes all reviewing windows to the timepoint of the event’s occurrence. Right Top: 1 second segment displaying raw signals from all electrodes. The vertical red line indicates alignment around the selected event (“Stim On 0”). The green dots on the top of the figure represent the spiking events from the first neuron on electrode with label AD01. Right Bottom: A selection of the first 4 electrodes, aligned in time with the top figure.

The red line in the figure shows the time of a “Stim On 0” event, extracted from the data. Spikes detected online (labelled as Spikes Channel) were extracted directly from the raw file contents by IN-Brainstorm, with automatic registration to the data time series.

The bottom right panel of Fig. 2 shows a selection of 4 channels temporally aligned with the top figure. The spikes from a neuron that was isolated on the first electrode are marked with green circles at the top of the full time-series displayed in the top panel. Users can browse the raw traces using point-and-click GUI and a series of keyboard shortcuts. On-the-fly bandpass and notch filtering can be applied to the signals.

Quality control & data pre-processing

Starting from the kind of raw data shown in Fig. 2, users can easily navigate through the recordings and experimental trials and events for quality control. Data segments, channels and entire trials can be marked as “bad” and excluded from further analyses using automatic processes or based on user evaluations.

The IN-Brainstorm pre-processing toolkit features solutions for adjustments of recording baseline, data resampling and frequency filtering (with linear phase filters). Additionally, detection and attenuation of artifacts (e.g., heartbeats, eye and body movements, stimulation and juice artifacts) can be achieved with principal22 or independent component analysis23,24. Finally, combining sensor data with the actual geometry of the recording array(s) enables many 2-D and 3-D visualization possibilities for time-series and realistic topographical plots, as illustrated further below.

Spike detection and spike sorting

Following the importation and preprocessing of data, IN data is often processed to extract spiking events from single or multiple neurons. This entails detecting spike occurrences and classifying these events according to their respective neural sources25. Most data acquisition systems feature online spike detection and sorting. These online events can be imported directly into IN-Brainstorm with the corresponding raw recordings. Yet, usual IN practice is to refine spike classification with a two-step procedure consisting of 1) unsupervised clustering, which automatically assigns each spike to a neural source based on waveform features, then 2) supervised clustering, which requires manual reviewing and editing of the labels from unsupervised clustering and the elimination of spurious spike events.

For IN-Brainstorm, we have enabled the direct interoperability with a selection of existing and openly-available spike-sorting toolkits: Waveclus14, UltraMegaSort20008,10 and Kilosort13. Those packages can be downloaded and installed automatically, in a completely transparent procedure. Sequentially, these tools are called by and interact with IN-Brainstorm without programming interventions from users.

Unsupervised spike sorting

Figure 3 (left) shows IN-Brainstorms’ GUI for unsupervised spike-sorting. Raw files are dragged and dropped into the GUI process box before a spike-sorting tool is selected from the IN-Brainstorm toolkit. Next, spike events are detected on each electrode and classified according to their putative neuronal generators.

Fig. 3
figure 3

Unsupervised spike-sorting. Left: Selection of the embedded spike-sorters for unsupervised spike-sorting within Brainstorm. Right: Example of a dataset spike-sorted with WaveClus. (1) A new entry in the database “WaveClus Spike Sorting” appears and indicates that this dataset has been spike-sorted. (2) New events appear in the Events window, corresponding to the spikes that the spike-sorter clustered.

The unsupervised spike events produced overwrite the online counterparts that were detected during data acquisition. The output of the spike-sorting process (Fig. 3 Box 1) is automatically registered to and accessible from the IN-Brainstorm database and linked to the corresponding raw file. The spike events are labelled in a principled manner (per channel and source cell number – Fig. 3 Box 2).

Supervised spike sorting

As WaveClus and UltraMegaSort2000 have built-in supervised spike sorting graphical user interfaces, we synchronized their GUIs with IN-Brainstorm’s. For Kilosort, we developed specific GUI bridges via Klusters9. The user-selected supervised clustering tool is called from Brainstorm’s main window after an unsupervised spike-sorted file is selected (Fig. 4a). The user then switches to the GUI of the selected supervised spike clustering tool (Fig. 4b–d). Once supervised spike clustering is complete, the spike events are updated accordingly and registered into the software’s file system. Double-clicking on the link to the raw data file lets the user review the updated spike events along with the raw electrophysiological traces as shown in Fig. 2 (Right).

Fig. 4
figure 4

Supervised spike sorting. (a) Main window that the user selects the electrode (or group of electrodes for Klusters) and the spike sorted files automatically update the spike sorter in use. Once the neuronal clusters have been adjusted on the supervised spike-sorter’s window, the user presses the Save and Next button and the next electrode gets selected to continue the supervised spike-sorting. (b–d) Supervised GUI for UltraMegaSort2000, WaveClus and Klusters respectively.

Spike events and categories from other spike-sorting tools can be readily imported as Brainstorm events, following the procedure described in the online documentation (https://neuroimage.usc.edu/brainstorm/e-phys/ConvertToBrainstormEvents).

Extraction of local field potentials

In addition to spiking activity, IN recordings yield local field potentials (LFPs), which provide direct measures of the summed post-synaptic electrical activity in the vicinity of recording electrodes26. These can be useful as a complement to spiking activity or a surrogate for some aspects of neural activity (e.g.27), provided that LFP traces can reliably be filtered and separated from spike waveforms28.

Figure 5a shows the IN-Brainstorm’s GUI for extracting LFP traces from raw recordings. The application features efficient tools to remove spike traces (Zanos et al., 2011), to perform anti-aliasing bandpass filtering and to down-sample the raw data. The de-spiking method proposed by Zanos et al.28 increases the accuracy of subsequent spike-field coherence measures and of spike-triggered average signals.

Fig. 5
figure 5

Converter from raw signals to LFPs. (a) Users can select the filtering limits of their LFP and apply a notch filter if necessary. The converter downsamples the raw signal to 1 KHz. (b) Once the conversion is complete, a single binary file (.bst) that contains all the necessary information (LFPs, experimental and spiking events, electrode positions etc.) is stored on the hard drive, and automatically imported on the data-tree as a new dataset. (c) 1 second segment review of the created LFP signal traces. The spiking events from the first neuron of electrode AD01 are represented by the green dots on the top of the figure, as in Fig. 2.

The resulting LFP traces and experimental events are automatically registered in IN-Brainstorm’s data repository for further review and analysis with a vast library of tools and pipelines − as described below − or for easy exportation to other software or plain files.

LFP extraction produces a new IN-Brainstorm down-sampled time-series binary file (Fig. 5b) with all the corresponding metadata, such as channel description (e.g., electrode labels and locations), and spike and experimental events. This file is easily sharable among researchers since its size is typically ~20–30 times smaller than the original raw file. Figure 5c shows a segment of the LFP file created.

Epoching

Once the relevant neural signals (LFPs and spikes) have been extracted from the raw data, they can be divided according to experimental epochs. Epochs are typically comprised of experimental trials, with the time window selection defined around a stimulation or behavioral event of interest. These can be imported directly into the IN-Brainstorm file system.

To illustrate these functions, we make use of the example visual cortex recording described previously (Fig. 2). The experiment involved presentations of moving stimuli while the animal maintained fixation; we defined the relevant epochs as segments of [−500, 1000] ms around the onset of each visual stimulus (Fig. 6 Left). In total we considered 8 different directions of the visual stimulus moving pattern; each stimulus condition was repeated 4 times (one condition was repeated for 96 trials for usage in the raster plot, and noise correlation functions). Imported trials to the database are shown in (Fig. 6 – Right).

Fig. 6
figure 6

Importing of trials. (Left) Selection of the events of interest and temporal boundaries around them, for importing the LFP segments. (Right) Imported LFP trials for the selected conditions in the Brainstorm database.

The following analysis steps can then be applied on the epoched trials.

Analysis of individual LFP signals

LFP traces can be analyzed using Brainstorm’s extensive library originally developed for EEG and MEG research6. We show in Table 1 a list of the main data processing categories that are available for LFP analysis. There is extensive online documentation, accompanied by data files, that describes in detail the methods and practices of LFP signal analysis (http://neuroimage.usc.edu/brainstorm).

We briefly provide below a few examples of these functions and their implementation in IN-Brainstorm.

Time-frequency decompositions

Having extracted the LFP signal and defined an appropriate analysis epoch, one can compute the LFP power at different frequencies and at different times relative to a stimulus event. Such information is often used to infer stimulus selectivity, anatomical sources of input, and other factors that are not necessarily apparent in spiking activity29,30,31,32,33.

IN-Brainstorm provides functionality for spectral and time-frequency decompositions, which can be derived using power spectrum density estimates, Hilbert or wavelet transforms. An example time-frequency decomposition (wavelet) is shown in Fig. 7a for the example LFP data corresponding to a single stimulus condition and epoch that shows strong alpha and beta responses after stimulation. The wavelet decomposition was z-scored with respect to a pre-stimulus baseline [−500:−100] ms.

Fig. 7
figure 7

Analysis of LFP signals. (a) Wavelet Decomposition ([2–90] Hz) of a single LFP trial from electrode labeled AD15 for moving stimulus condition towards −1/4 pi degrees direction. Users can select the channel they want to be displayed from a drop-down list on the main Brainstorm window. (b) Estimation of NxN coherence for a single trial across all electrodes. The coherence values are color-coded for a specific frequency (on the example 40 Hz frequency is selected). Users can display coherence in the other frequencies by moving a sliding toggle on the main Brainstorm window.

LFP-LFP signal analysis

LFP signals from multichannel recordings can be analyzed to detect occurrences of various forms of signal similarities in the time or frequency domain. These measures are often interpreted as representing functional connectivity between different sites30,33,34,35. IN-Brainstorm provides support for widely-used measures based on amplitude or phase statistics as indicators of possible interregional brain interactions (coherence, phase-locking values, bandlimited amplitude envelope correlations, phase-transfer entropy) and parametric models (estimates of time- or frequency-domain Granger causality). Advanced measures of interdependence between oscillatory components of polyrhythmic brain activity can be derived with phase-amplitude coupling (PAC) estimation tools36,37. An example estimation of coherence among all combinations of electrodes is shown in Fig. 7b for a single stimulus condition and epoch. The bimodal pattern that emerges (high coherence among some channels and low coherence among others) is an indication of the transition of the linear probe across neighboring cortical areas, from MT (electrodes 1:13) to MST (21:32).

Analysis of individual neuron spiking activity

Spikes are registered in IN-Brainstorm as events; the corresponding features are 1) the time of occurrence and 2) a label for distinguishing between neuronal sources. We provide several features for visualization of epoched spiking data.

Raster plot – peristimulus time histograms

Raster plots and peristimulus time histograms (PSTH), are routinely used to visualize the relations between neuronal firing and a stimulus event or a behavioral response.

We provide three methods for visualizing spiking activity with IN-Brainstorm:

The first method (raster plot) shows the spiking data as trial vs. time for each neuron. Similarly, the second method (PSTH) shows the average binned firing rate for each neuron, along its 95% confidence intervals. Raster plots and PSTHs of spiking rates are displayed after interactive selection of the cell to be reviewed. Figure 8a shows the raster plot of the first neuron detected from contact AD01 (top), and its equivalent PSTH with 10-ms binning (bottom). The PSTH of the neuron’s firing rate from 96 trials of a single condition revealed a stimulus-onset-to-maximum-firing latency of about 150 ms.

Fig. 8
figure 8

Spike – spike-LFP functions. (a) (Top) Example raster plot for 96 trials of a single condition for the first neuron picked up on electrode labeled ‘AD01’. A single condition was repeated 96 times instead of 4 for the purpose of this raster plot. (a) (Bottom) PSTH from all trials shows maximum firing ~175 ms after the stimulus onset for this neuron with 95% confidence intervals (green shade around average trace). Firing has been binned into 10 ms segments. The vertical red line indicates interactive temporal alignment between the two plots at the maximum firing rate for the selected neuron, and the purple shade the period of the stimulus presentation. (b) Tuning curves function. (LEFT): Users select the neurons and sequentially the conditions (and their order) that would formulate the x-axis (right side of the conditions selection window) for the tuning curve. Additionally, we included a selection for the time-window where the spikes would be counted. (RIGHT): Tuning curve for an example neuron, selected from the window on the left side of Figure b. The green shade indicates the 95% confidence intervals. The x-axis shows the different experimental conditions at the order selected on the previous window. This neuron expresses selectivity for the condition “Stim On −1/4 pi”. (c) Noise correlation. The function selects all the neurons that elicited spikes within the trials imported and displays a nxn figure where the noise correlation is computed for all combinations of neurons. Specifically for the dataset illustrated, there were 53 unique neurons picked up by the electrodes (according to the spike sorting step). This figure shows the computation of noise-correlation on all trials for the presentation 96 trials of a motion stimulus, and spikes are selected on [0,300] ms around the stimuli presentations. (d) Spike field coherence for an example neuron picked up from the 7th electrode (AD07) for all trials of the motion stimulus condition “Stim On 0”. The spike-field coherence window displays spectral influence of a single neuron to all 32 electrodes. Frequency is shown up to 50 Hz. Time selection around each spike was [−150, 150] ms. (e) Spike triggered average of a neuron picked up on electrode labeled AD01 with 95% confidence intervals for each electrode’s average trace (gray shade). A graph of the linear probe with the relative electrode locations is displayed on the left of the figure. The time selection around the spikes was set to [−150, 150] ms for all trials of all experimental conditions. All traces have been aligned to the same time-selection (0 ms – time occurrence of the spikes of AD01).

The third method is embedded within the topographical plots section as shown below.

Tuning curves

Tuning curves capture the relationship between an experimental variable (e.g., the orientation of a visual stimulus) and a scalar measure of neural activity (e.g., a single neuron’s trial-averaged firing rate).

Tuning curves are readily produced from continuous data files that contain the event markers of interest to the study. Tuning curves are displayed with IN-Brainstorm after manual assignment of the order of the experimental conditions (x-axis), the selection of the neurons to be displayed, and the selection of the time window of interest for reporting spiking activity. A separate tuning curve figure is produced for each neuron selected.

We selected the events and individual neurons previously identified from spike sorting via IN-Brainstorm’s GUI. Figure 8b shows the tuning curves of one example neuron (labeled as “Spikes Channel AD07 |1|”) for the 8 different conditions (Stim On −3/4 pi, Stim On −2/4 pi etc.) of the motion stimuli, and its 95% confidence intervals. The tuning curve shows the preference of this neuron for stimuli moving in the right direction (Stim On -1/4 pi condition).

Topographical plots

When multichannel recording devices are used, neurophysiology data can be shown as topographically registered to structural anatomy. IN-Brainstorm can show neuronal firing at the 3-D locations of the recording probes/arrays. To illustrate this feature, we used a separate dataset that was collected from two 96-channel Utah arrays and one 32-linear probe38. A structural T1-weighted MRI volume was acquired preoperatively. The head and brain surface envelopes were segmented with Freesurfer39 and directly imported in IN-Brainstorm. The electrode contact locations were co-registered to the 3-D anatomical volume by specifying the distance of the electrodes along the probe and locating the tip of the probe and the entry point through the skull, using Brainstorm’s MRI volume viewer.

Neuronal firing was binned in 10-ms segments and displayed on the animal’s anatomy as shown in Fig. 9a (a single bin is displayed in the figure). This figure shows IN-Brainstorm’s ability to overlay the segmented cortical surface, MRI orthogonal slices, the implanted devices with actual geometry, and color-coded displays of raw or processed electrophysiology data (here instantaneous firing rates). Figure 9b shows a zoomed-in version of Fig. 9a over the Utah array implanted in the prefrontal cortex.

Fig. 9
figure 9

Topographical visualizations. (a) Visualization of the implanted electrodes on the anatomical MRI of the non-human primate. The MR slices are superimposed on the figure. (b) Zoomed in version of an implanted Utah array on the cortical surface, with the spiking activity color-coded on the array’s topography for a single time-bin of a PSTH computation.

Spike-spike analysis: noise correlations

While tuning curves capture neuronal sensitivity to stimulus properties, the fidelity of a population code is thought to be limited by noise that is common across neurons40; for example, neurons would be noise correlated if for each stimulus their activities are correlated41. Such noise correlations are typically quantified as the Pearson correlation coefficient between the firing rates of two neurons across trials. Such correlations strongly influence the accuracy of population coding42,43,44,45,46.

Noise correlation statistics are displayed with IN-Brainstorm from the correlation of the spike trains that each neuron elicited within a given epoch, for all neuronal combinations. The end result is a nxn matrix (with n the number of unique neurons that produced spikes during the selected trials) that shows noise correlation estimates between the selected neurons.

Figure 8c shows the noise correlation profile across the 32-channel array of the example dataset, for 53 unique neurons that elicited spikes across all trials at the 8 conditions of presentation of the moving stimulus in the original data set from Fig. 2. Spikes included in the correlation computations were selected in the [0,300]-ms time range of each trial.

The computed noise correlation showed 2 pairs of neurons with abnormally high noise correlation (above 0.8). After further inspection, it was revealed that this was due to the fact that the spike-sorter that was used was not taking into account the relative position of the electrodes, and the same neurons were picked up from neighbouring channels:

Neurons: AD01 |1| - AD02|2| and AD08 |1| - AD09 |1| were the same neuron.

Spike-LFP analysis

Spikes are local events, reflecting outputs from individual neurons. LFPs in contrast can capture activity over regions, including subthreshold post-synaptic activity, and therefore reflect the state of a broader network47. There is considerable interest in relating the two types of signals for estimating the dependence of spiking activity on the broader context in which the neuron is embedded.

Spike-field coherence

Spike-field coherence (SFC) estimates the consistency between the time occurrence of spike trains and the phase of co-localized LFP cycles as a function of frequency48. SFC can also be used to evaluate synchronized activity between distant brain regions, as a marker of neuronal communication34,49,50,51,52. IN-Brainstorm features the spike-field coherence estimator proposed by Fries53. The user can derive SFC estimates for each GUI-selected neuron, for all electrodes and frequencies of interest.

Figure 8d shows SFC up to 50 Hz between a single neuron detected at channel AD07 of the example data set and the LFP traces at all the 32 channels of the probe. The time window selected around the spiking events was [−150, 150] ms. The horizontal white line indicates the electrode where the neuron was detected.

Spike-triggered average of the LFP

Spike-triggered averaging (STA) of the LFP reveals how neuronal spiking is related to the dynamics of proximal or distant LFPs54,55,56. STA proceeds with trial averaging of LFP traces time-locked to a designated neuron’s spike events, followed by normalization with the total spike count.

Analogous to spike-field coherence, STA is computed over a user-selected time window around each spiking event. STA scores are per neuron, showcasing the average LFP amplitude around the occurrence of the spikes of each neuron. STA can be visualized on topological 2-D representations of the recording array, to reveal time-locked associations between neuronal spiking activity and local or remote LFP recordings.

Figure 8e shows the STA time-locked to the firing of the first neuron detected by electrode AD01 across trials and conditions. The topographical 2-D plot is produced with IN-Brainstorm using multidimensional scaling of the actual 3-D location and geometry of the implanted probe. The LFP epoch around spike event was [−150,150] ms.

Statistical inference and machine learning

Once measures have been extracted from spiking or LFP data, tools to conduct inferential statistical analysis in the multiple dimensions of electrophysiological data (space, time, frequency, connectivity) are available from Brainstorm’s library.

Parametric (one- and two-sample tests) and nonparametric permutation tests, descriptive and distribution statistics from histograms (Q-Q plot and Shapiro-Wilk test for data normality) are available. Here too, the software architecture emphasises interoperability with other toolkits, for expanded resources. For instance, multidimensional and nonparametric cluster statistics can be run on LFP and time-frequency data, from Brainstorm, via calls to FieldTrip12.

In addition, statistical learning tools for decoding and multivariate pattern analysis (MVPA) are also available (see e.g. Cichy et al.57). The Brainstorm library also includes support vector machine (SVM) and linear discriminant analysis (LDA) classification of LFP time series based on experimental events and conditions.

Additional features

Processing power

Hardware acceleration in the processing of long recordings is enabled by Matlab’s standard parallel computing (e.g., multi-core) features, which are controlled directly from Brainstorm’s GUI. Flexible management of memory resources is also accessible to users, with the specification of the amount of RAM allocated to data manipulations while executing the LFP extraction process. Moreover, GPU acceleration computations are enabled through Kilosort for the spike-sorting step.

Data management

Generally speaking, formal data management plans are seldom adopted by electrophysiology labs. Instead, the handling of data is typically project-based, with trainees managing their individual data collection and analyses until publication. When they move on to another project or to the next step of their career, they frequently leave data, analysis pipelines and results behind, with minimal documented organization for sustainability and knowledge transfer. This limits the long-term value of data and negatively impacts the reproducibility and verification of research results58. Brainstorm has tools to improve and facilitate data management: data is hierarchically organized by Studies, followed by Subjects/Samples and (experimental) Conditions, which point to data elements such as links to raw data files, single-trial epochs, sample statistics, and other derivatives: power spectra, wavelet decompositions, measures of cross-frequency coupling and inter-regional connectivity, etc. As with all features in the application, user interactions with Brainstorm’s data organization are facilitated both by the application’s GUI and direct access via scriptable functions using Matlab code.

Another important aspect of Brainstorm is its capacity for importing entire data repositories at once, with associated metadata, when those datasets are organized according to the emergent Brain Imaging Data Structure (BIDS). Originally driven by the neuroimaging community, BIDS is a grassroots effort to harmonize data organization and documentation59. BIDS has recently been extended to MEG electrophysiology60 and is presently integrating EEG61, and invasive neurophysiology62.

Batch processing

The software has a specific GUI for assembling data processing pipelines in an intuitive manner, choosing elementary processes from the (IN-)Brainstorm library and assembling them together into a logical progression along the workflow. These pipelines enable the reproduction of any data workflow with a click of a button. They can also be shared in Matlab format with collaborators or the entire user community. The Matlab code for pipelines can also be generated automatically by Brainstorm e.g., for execution in headless (no GUI) mode on high-performance computing servers and cloud resources.

Discussion

We provide a free, extensive open-source software application for invasive electrophysiology. IN-Brainstorm is built on the foundations of Brainstorm, which was originally designed for human multimodal electrophysiology and imaging. IN-Brainstorm supports multiple data formats of raw signals from a variety of acquisition systems. The recorded traces and their LFP versions can be reviewed, quality-controlled and processed within a unique analytical environment, with easy GUI interactions, rich visualization, intuitive pipeline editing for scripting and sharing. We have built bridges for IN-Brainstorm to interoperate seamlessly with established, free spike-sorting tools.

A specific emphasis was put on providing versatile solutions for multidimensional data visualization, including 2-D and 3-D topographical plots registered to structural anatomy from co-registered MRI data. Source modeling of array data is also available using boundary element modeling of head and brain tissues63,64 and a variety of source modeling techniques available in Brainstorm65. Videos synchronised to electrophysiological traces can also be imported and visualized simultaneously in synchrony, for marking behavioral events.

The software is supported by an expansive online documentation (with tutorial data) and online user forum. The active Brainstorm user community contributes to an efficient peer-reviewing/debugging process, and daily updates deliver bug fixes and software improvements that are readily available to the users.

With IN-Brainstorm, electrophysiologists are provided a free, integrated software environment that promotes and facilitates harmonized principles of data management, methods, documentation, code verification and reproducibility of data analyses. Such practical and user-friendly tools also accelerate the education of electrophysiologist trainees and promotes the adoption and expansion of data harmonization efforts, such as BIDS and Neurodata Without Borders.

Every instance of data processing is logged, with the filenames of the data used and time stamps of execution. These simple, yet powerful features document the provenance of data derivatives and analysis results. Custom IN analysis pipelines assembled for elementary processing blocks of the software’s library can be shared with collaborators, publishers and the scientific community. Pipelines are constructed via the GUI and saved as Matlab files. The open-source code of IN-Brainstorm is thoroughly documented, verifiable and can benefit from contributions from any user via GitHub. Sharing is further encouraged and facilitated by Brainstorm’s data organization in Studies, which can be zipped for archiving, exportation (e.g., as a BIDS repository) or importation into the Brainstorm environment of a collaborator. Batch processing of multiple data volumes is automated, thanks to the systematic organization of Brainstorm’s file system and can be executed on high-performance computing servers without requiring GUI interactions.

For all these reasons, we believe that IN-Brainstorm responds to an unmet need of the electrophysiology community. By providing a unique environment with a common set of analytical tools, the application also provides a unique bridge between recording scales, data types and researchers, and additionally, between the methods used in human, animal and slice preparations. It also represents a scalable framework to developments and integration of existing or future tools and data formats for the entire field of electrophysiology.

Methods

Electrophysiological recordings acquired from non-human primates that participated in previous studies38,44,66,67,68 were used for showcasing this toolbox.