eFEL (Electrophys Feature Extract Library)

raw JSON →
5.7.23 verified Sat May 09 auth: no python

eFEL is a Python library for extracting electrophysiological features from recorded or simulated voltage traces, used widely in neuroscience. Current version: 5.7.23. Release cadence: frequent patches, minor releases every few months.

pip install efel
error KeyError: 'T'
cause Trace dictionary missing required key 'T' or value is not a numpy array with length matching 'V'.
fix
Ensure trace dict has all required keys: 'T', 'V', 'stim_start', 'stim_end' with numpy array values of consistent size.
error ValueError: voltage and time arrays must have the same length
cause Mismatched lengths of 'T' and 'V' arrays in the trace dictionary.
fix
Check that T and V arrays have the same length. For example: assert len(trace['T']) == len(trace['V']).
error ModuleNotFoundError: No module named 'efel'
cause eFEL not installed or installed in a different environment.
fix
Run 'pip install efel' in the correct Python environment. Ensure Python >=3.10.
error AttributeError: module 'efel' has no attribute 'getFeatureValues'
cause Importing the module but using an incorrect attribute name (e.g., typo) or using an old version.
fix
Verify import: 'import efel'. Use 'efel.getFeatureValues' (case-sensitive) and upgrade to latest: 'pip install --upgrade efel'.
breaking eFEL v5.0+ requires Python >=3.10. v4.x used Python 3.6+. Upgrade your Python environment.
fix Use Python 3.10 or higher.
breaking The function 'getFeatureValues' returns a list of dicts, not a single dict. Access results via index, e.g., results[0]['Spikecount'].
fix Always index the list: results = efel.getFeatureValues(traces, features); print(results[0]['feature_name']).
gotcha Trace dictionaries must contain keys 'T', 'V', 'stim_start', 'stim_end' as numpy arrays. Using lists or missing keys will cause silent errors or KeyError.
fix Ensure trace dict values are numpy arrays: trace = {'T': np.array(time), 'V': np.array(voltage), 'stim_start': np.array([100.0]), 'stim_end': np.array([900.0])}.
deprecated The older API using efel.api is deprecated. Use the top-level module functions directly.
fix Replace 'from efel.api import ...' with 'import efel' and call efel.getFeatureValues(), efel.setThreshold(), etc.

Basic usage: create a trace dict with T, V, stim_start, stim_end, then call getFeatureValues.

import efel
import numpy as np

# Generate a simple synthetic action potential trace
time = np.arange(0, 10, 0.1)  # 10 seconds, step 0.1 ms
voltage = np.zeros(len(time))
voltage[50:60] = 20  # simple spike

trace = {'T': time, 'V': voltage, 'stim_start': [100.0], 'stim_end': [900.0]}

# Set threshold
import efel
efel.setThreshold(-10)

# Calculate features
features = efel.getFeatureValues([trace], ['Spikecount', 'AP_amplitude'])
print(features[0]['Spikecount'])
print(features[0]['AP_amplitude'])