scientific-skills/neurokit2/references/eda.md
Electrodermal Activity (EDA), also known as Galvanic Skin Response (GSR) or Skin Conductance (SC), measures the electrical conductance of the skin, reflecting sympathetic nervous system arousal and sweat gland activity. EDA is widely used in psychophysiology, affective computing, and lie detection.
Automated processing of raw EDA signals returning tonic/phasic decomposition and SCR features.
signals, info = nk.eda_process(eda_signal, sampling_rate=100, method='neurokit')
Pipeline steps:
Returns:
signals: DataFrame with:
EDA_Clean: Filtered signalEDA_Tonic: Slow-varying baselineEDA_Phasic: Fast-varying responsesSCR_Onsets, SCR_Peaks, SCR_Height: Response markersSCR_Amplitude, SCR_RiseTime, SCR_RecoveryTime: Response featuresinfo: Dictionary with processing parametersMethods:
'neurokit': cvxEDA decomposition + neurokit peak detection'biosppy': Median smoothing + biosppy approachRemove noise through low-pass filtering.
cleaned_eda = nk.eda_clean(eda_signal, sampling_rate=100, method='neurokit')
Methods:
'neurokit': Low-pass Butterworth filter (3 Hz cutoff)'biosppy': Low-pass Butterworth filter (5 Hz cutoff)Automatic skipping:
Rationale:
Decompose EDA into tonic (slow baseline) and phasic (rapid responses) components.
tonic, phasic = nk.eda_phasic(eda_cleaned, sampling_rate=100, method='cvxeda')
Methods:
1. cvxEDA (default, recommended):
tonic, phasic = nk.eda_phasic(eda_cleaned, sampling_rate=100, method='cvxeda')
2. Median smoothing:
tonic, phasic = nk.eda_phasic(eda_cleaned, sampling_rate=100, method='smoothmedian')
3. High-pass filtering (Biopac's Acqknowledge):
tonic, phasic = nk.eda_phasic(eda_cleaned, sampling_rate=100, method='highpass')
4. SparsEDA:
tonic, phasic = nk.eda_phasic(eda_cleaned, sampling_rate=100, method='sparseda')
Returns:
tonic: Slow-varying skin conductance level (SCL)phasic: Fast skin conductance responses (SCRs)Physiological interpretation:
Detect Skin Conductance Responses (SCRs) in phasic component.
peaks, info = nk.eda_peaks(eda_phasic, sampling_rate=100, method='neurokit',
amplitude_min=0.1)
Methods:
'neurokit': Optimized for reliability, configurable thresholds'gamboa2008': Gamboa's algorithm'kim2004': Kim's approach'vanhalem2020': Van Halem's method'nabian2018': Nabian's algorithmKey parameters:
amplitude_min: Minimum SCR amplitude (default: 0.1 µS)
rise_time_max: Maximum rise time (default: 2 seconds)rise_time_min: Minimum rise time (default: 0.01 seconds)Returns:
SCR_Onsets: Indices where SCR beginsSCR_Peaks: Indices of peak amplitudeSCR_Height: Peak height above baselineSCR_Amplitude: Onset-to-peak amplitudeSCR_RiseTime: Onset-to-peak durationSCR_RecoveryTime: Peak-to-recovery duration (50% decay)SCR timing conventions:
Correct detected SCR peaks (currently placeholder for EDA).
corrected_peaks = nk.eda_fixpeaks(peaks)
Note: Less critical for EDA than cardiac signals due to slower dynamics.
Automatically select appropriate analysis type based on data duration.
analysis = nk.eda_analyze(signals, sampling_rate=100)
Mode selection:
eda_eventrelated()eda_intervalrelated()Returns:
Analyze stimulus-locked EDA epochs for event-related responses.
results = nk.eda_eventrelated(epochs)
Computed metrics (per epoch):
EDA_SCR: Presence of SCR (binary: 0 or 1)SCR_Amplitude: Maximum SCR amplitude during epochSCR_Magnitude: Mean phasic activitySCR_Peak_Amplitude: Onset-to-peak amplitudeSCR_RiseTime: Time to peak from onsetSCR_RecoveryTime: Time to 50% recoverySCR_Latency: Delay from stimulus to SCR onsetEDA_Tonic: Mean tonic level during epochTypical parameters:
Use cases:
Analyze extended EDA recordings for overall arousal and activation patterns.
results = nk.eda_intervalrelated(signals, sampling_rate=100)
Computed metrics:
SCR_Peaks_N: Number of SCRs detectedSCR_Peaks_Amplitude_Mean: Average SCR amplitudeEDA_Tonic_Mean, EDA_Tonic_SD: Tonic level statisticsEDA_Sympathetic: Sympathetic nervous system indexEDA_SympatheticN: Normalized sympathetic indexEDA_Autocorrelation: Temporal structure (lag 4 seconds)EDA_Phasic_*: Mean, SD, min, max of phasic componentRecording duration:
Use cases:
Derive sympathetic nervous system activity from frequency band (0.045-0.25 Hz).
sympathetic = nk.eda_sympathetic(signals, sampling_rate=100, method='posada',
show=False)
Methods:
'posada': Posada-Quintero method (2016)
'ghiasi': Ghiasi method (2018)
Requirements:
Returns:
EDA_Sympathetic: Sympathetic index (absolute)EDA_SympatheticN: Normalized sympathetic index (0-1)Interpretation:
Use cases:
Compute autocorrelation to assess temporal structure of EDA signal.
autocorr = nk.eda_autocor(eda_phasic, sampling_rate=100, lag=4)
Parameters:
lag: Time lag in seconds (default: 4 seconds)Interpretation:
Use case:
Detect abrupt shifts in mean and variance of EDA signal.
changepoints = nk.eda_changepoints(eda_phasic, penalty=10000, show=False)
Method:
Parameters:
penalty: Controls sensitivity (default: 10,000)
Returns:
Use cases:
Create static or interactive visualizations of processed EDA.
nk.eda_plot(signals, info, static=True)
Displays:
Interactive mode (static=False):
Generate synthetic EDA signals with configurable parameters.
synthetic_eda = nk.eda_simulate(duration=10, sampling_rate=100, scr_number=3,
noise=0.01, drift=0.01)
Parameters:
duration: Signal length in secondssampling_rate: Sampling frequency (Hz)scr_number: Number of SCRs to includenoise: Gaussian noise leveldrift: Slow baseline drift magnituderandom_state: Seed for reproducibilityReturns:
Use cases:
Flat signal (no variation):
Excessive noise:
Baseline drift:
eda_phasic() to separate tonic driftNon-responders:
Preprocessing workflow:
# 1. Clean signal
cleaned = nk.eda_clean(eda_raw, sampling_rate=100, method='neurokit')
# 2. Decompose tonic/phasic
tonic, phasic = nk.eda_phasic(cleaned, sampling_rate=100, method='cvxeda')
# 3. Detect SCRs
signals, info = nk.eda_peaks(phasic, sampling_rate=100, amplitude_min=0.05)
# 4. Analyze
analysis = nk.eda_analyze(signals, sampling_rate=100)
Event-related workflow:
# 1. Process signal
signals, info = nk.eda_process(eda_raw, sampling_rate=100)
# 2. Find events
events = nk.events_find(trigger_channel, threshold=0.5)
# 3. Create epochs (-1 to 10 seconds around stimulus)
epochs = nk.epochs_create(signals, events, sampling_rate=100,
epochs_start=-1, epochs_end=10)
# 4. Event-related analysis
results = nk.eda_eventrelated(epochs)
# 5. Statistical analysis
# Compare SCR amplitude across conditions
Emotion and affective science:
Cognitive processes:
Clinical populations:
Applied settings:
Neuroimaging integration:
SCR amplitude:
SCR frequency:
Tonic SCL: