Electrical extracellular recordings, i.e., recordings of the electrical potentials in the extracellular medium between cells, have been a main work-horse in electrophysiology for almost a century. The high-frequency part of the signal (≳500 Hz), i.e., the multi-unit activity (MUA), contains information about the firing of action potentials in surrounding neurons, while the low-frequency part, the local field potential (LFP), contains information about how these neurons integrate synaptic inputs. As the recorded extracellular signals arise from multiple neural processes, their interpretation is typically ambiguous and difficult. Fortunately, a precise biophysical modeling scheme linking activity at the cellular level and the recorded signal has been established: the extracellular potential can be calculated as a weighted sum of all transmembrane currents in all cells located in the vicinity of the electrode. This computational scheme can considerably aid the modeling and analysis of MUA and LFP signals. Here, we describe LFPy, an open source Python package for numerical simulations of extracellular potentials. LFPy consists of a set of easy-to-use classes for defining cells, synapses and recording electrodes as Python objects, implementing this biophysical modeling scheme. It runs on top of the widely used NEURON simulation environment, which allows for flexible usage of both new and existing cell models. Further, calculation of extracellular potentials using the line-source-method is efficiently implemented. We describe the theoretical framework underlying the extracellular potential calculations and illustrate by examples how LFPy can be used both for simulating LFPs, i.e., synaptic contributions from single cells as well a populations of cells, and MUAs, i.e., extracellular signatures of action potentials.
Keywords: Python; biophysics; compartmental modeling; detailed morphology; extracellular potential; forward modeling; local field potential; spike waveform.