| Title: | Electrodermal Activity Analysis for PhysioExperiment Objects |
|---|---|
| Description: | Provides electrodermal activity (EDA / skin conductance) analysis functions for PhysioExperiment objects. Includes preprocessing (filtering, downsampling), artifact detection and correction, tonic/phasic decomposition (highpass, median, CDA, cvxEDA), SCR peak detection, feature extraction, data transformations, signal quality assessment, visualization, and event-related SCR analysis. |
| Authors: | Yusuke Matsui |
| Maintainer: | Yusuke Matsui <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-06-15 03:36:06 UTC |
| Source: | https://github.com/x-biosignal/PhysioEDA |
Identifies artifacts in electrodermal activity (EDA) signals using one or more detection methods (threshold, gradient, flatline) and optionally corrects them via interpolation or NA replacement.
edaArtifact( x, methods = c("threshold", "gradient", "flatline"), threshold_range = c(0.001, 60), gradient_max = NULL, flatline_sec = 5, correct = "interpolate", assay_name = NULL, output_assay = "cleaned" )edaArtifact( x, methods = c("threshold", "gradient", "flatline"), threshold_range = c(0.001, 60), gradient_max = NULL, flatline_sec = 5, correct = "interpolate", assay_name = NULL, output_assay = "cleaned" )
x |
A PhysioExperiment object containing EDA data. |
methods |
Character vector of detection methods to apply. Any
combination of |
threshold_range |
Numeric vector of length 2 giving the acceptable
range of EDA values in microsiemens (default: |
gradient_max |
Maximum allowable absolute gradient in microsiemens
per sample. If NULL (default), computed as |
flatline_sec |
Minimum duration in seconds of a constant-value segment to be flagged as a flatline artifact (default: 5). |
correct |
Correction strategy: |
assay_name |
Name of the input assay. If NULL, uses
|
output_assay |
Name for the corrected output assay (default:
|
A modified PhysioExperiment with artifact
information stored in metadata(x)$eda_artifacts, a list containing:
Logical matrix (time x channels) where TRUE indicates
an artifact sample.
A data.frame with columns channel,
method, n_artifacts, and pct giving artifact
counts per channel per detection method.
If correct != "none", the corrected signal is stored in the
output_assay.
Kleckner, I.R., et al. (2018). "Simple, transparent, and flexible automated quality assessment procedures for ambulatory electrodermal activity data." IEEE Transactions on Biomedical Engineering, 65(7), 1460-1467. doi:10.1109/TBME.2017.2758643
Boucsein, W. (2012). Electrodermal Activity. 2nd ed. Springer. doi:10.1007/978-1-4614-1126-0
edaQuality for signal quality assessment,
edaFilter for frequency-domain filtering,
edaDecompose for tonic/phasic decomposition
Separates an electrodermal activity (EDA) signal into its slow-varying tonic component (skin conductance level, SCL) and fast-varying phasic component (skin conductance responses, SCR).
edaDecompose( x, method = c("highpass", "median", "cda", "cvxeda"), cutoff = 0.05, window_sec = 4, tau1 = 0.75, tau2 = 2, alpha = 0.01, gamma = 0.1, assay_name = NULL, output_tonic = "tonic", output_phasic = "phasic" )edaDecompose( x, method = c("highpass", "median", "cda", "cvxeda"), cutoff = 0.05, window_sec = 4, tau1 = 0.75, tau2 = 2, alpha = 0.01, gamma = 0.1, assay_name = NULL, output_tonic = "tonic", output_phasic = "phasic" )
x |
A PhysioExperiment object containing EDA data. |
method |
Decomposition method: |
cutoff |
Cutoff frequency in Hz for the highpass method (default: 0.05). |
window_sec |
Window length in seconds for the median method (default: 4). |
tau1 |
SCR rise time constant in seconds for CDA/cvxEDA (default: 0.75). |
tau2 |
SCR decay time constant in seconds for CDA/cvxEDA (default: 2.0). |
alpha |
L1 sparsity penalty for cvxEDA (default: 0.01). Ignored by other methods. |
gamma |
Smoothness weight for cvxEDA tonic component (default: 0.1). Ignored by other methods. |
assay_name |
Name of the input assay. If NULL, uses
|
output_tonic |
Name for the tonic output assay (default: "tonic"). |
output_phasic |
Name for the phasic output assay (default: "phasic"). |
Four methods are available:
FFT-based highpass/lowpass separation at a cutoff frequency.
Sliding median filter for tonic extraction.
Continuous Decomposition Analysis (Benedek & Kaernbach, 2010). Deconvolution with a Bateman impulse response, Gaussian smoothing, and non-negativity constraint on the driver signal.
Convex optimization-based decomposition (Greco et al., 2016). Iterative ADMM approach with Wiener deconvolution and L1 sparsity on the driver signal.
A modified PhysioExperiment with new assays:
The slow-varying skin conductance level (SCL) component.
The fast-varying skin conductance response (SCR) component.
(CDA and cvxEDA only) The sudomotor nerve activity driver signal.
Decomposition parameters are stored in metadata(x)$eda_decompose.
Benedek, M., & Kaernbach, C. (2010). "A continuous measure of phasic electrodermal activity." Journal of Neuroscience Methods, 190(1), 80-91. doi:10.1016/j.jneumeth.2010.04.028
Greco, A., et al. (2016). "cvxEDA: A convex optimization approach to electrodermal activity processing." IEEE Transactions on Biomedical Engineering, 63(4), 797-804. doi:10.1109/TBME.2015.2474131
edaPeaks for SCR peak detection on the phasic signal,
edaFeatures for feature extraction,
plotDecompose for visualizing decomposition results
Reduces the sampling rate of an EDA signal by first applying an anti-aliasing lowpass filter at half the target sampling rate, then decimating the signal.
edaDownsample(x, target_sr, assay_name = NULL)edaDownsample(x, target_sr, assay_name = NULL)
x |
A PhysioExperiment object containing EDA data. |
target_sr |
Target sampling rate in Hz. Must be lower than the current sampling rate. |
assay_name |
Name of the input assay. If NULL, uses
|
A new PhysioExperiment with the downsampled
signal in the "raw" assay and the sampling rate set to the actual
achieved rate. Events are preserved. Downsampling parameters are stored in
metadata(x)$eda_downsample (a list with original_sr,
target_sr, factor, original_n_time, and
new_n_time).
Boucsein, W. (2012). Electrodermal Activity. 2nd ed. Springer. doi:10.1007/978-1-4614-1126-0
edaFilter for frequency-domain filtering,
edaArtifact for artifact detection and correction
Performs event-related skin conductance response (ER-SCR) analysis by extracting SCR features time-locked to experimental events. For each event, the function searches for an SCR onset within a specified window and, if found, computes amplitude, latency, rise time, and 50 percent recovery time.
edaErscr( x, event_type = NULL, onset_window = c(1, 4), peak_window = c(0.5, 5), amplitude_min = 0.01, assay_name = NULL )edaErscr( x, event_type = NULL, onset_window = c(1, 4), peak_window = c(0.5, 5), amplitude_min = 0.01, assay_name = NULL )
x |
A PhysioExperiment object containing EDA data and events. |
event_type |
Character string specifying the event type to analyze. If NULL (default), all events are used. |
onset_window |
Numeric vector of length 2 giving the valid SCR onset latency window in seconds relative to event onset (default: c(1, 4)). |
peak_window |
Numeric vector of length 2 giving the minimum and maximum time from SCR onset to peak in seconds (default: c(0.5, 5)). |
amplitude_min |
Minimum SCR amplitude in microsiemens to be considered a valid response (default: 0.01). |
assay_name |
Name of the assay to use. If NULL, uses "phasic" if available, otherwise the default assay. |
A data.frame with one row per event per channel containing columns:
Integer index of the event.
Numeric onset time of the event in seconds.
Character name of the channel.
Logical indicating whether a valid SCR was detected.
Numeric SCR amplitude (peak minus onset), or NA.
Numeric latency from event to SCR onset in seconds, or NA.
Numeric time from SCR onset to peak in seconds, or NA.
Numeric time for 50 percent recovery from peak, or NA.
Bach, D.R., et al. (2010). "Modelling event-related skin conductance responses." International Journal of Psychophysiology, 75(3), 349-356. doi:10.1016/j.ijpsycho.2010.01.005
edaPeaks for general SCR peak detection,
edaDecompose for tonic/phasic decomposition (run first),
edaFeatures for summary feature extraction,
plotPeaks for visualizing SCR peaks
Computes summary features from electrodermal activity data, including
skin conductance response (SCR) statistics and skin conductance level
(SCL) measures. Requires tonic/phasic decomposition to have been
performed (via edaDecompose).
edaFeatures(x, peaks = NULL, window = NULL, assay_name = NULL)edaFeatures(x, peaks = NULL, window = NULL, assay_name = NULL)
x |
A PhysioExperiment object containing EDA data. |
peaks |
Optional pre-computed peaks data.frame from
|
window |
Optional numeric vector of length 2 giving the time window
in seconds as |
assay_name |
Name of the input assay for peak detection. If NULL,
uses |
A data.frame with one row per channel and the following
columns:
Character channel label.
Integer number of detected SCR peaks.
Numeric SCR count per minute.
Numeric mean SCR peak amplitude in microsiemens (0 if no peaks detected).
Numeric mean tonic skin conductance level.
Numeric standard deviation of the tonic signal.
Numeric area under the phasic curve (positive values
only, in uS*s), or NA if no phasic assay exists.
Numeric non-specific SCR frequency (per minute).
Boucsein, W. (2012). Electrodermal Activity. 2nd ed. Springer. doi:10.1007/978-1-4614-1126-0
Benedek, M., & Kaernbach, C. (2010). "A continuous measure of phasic electrodermal activity." Journal of Neuroscience Methods, 190(1), 80-91. doi:10.1016/j.jneumeth.2010.04.028
edaDecompose for tonic/phasic decomposition (run first),
edaPeaks for SCR peak detection,
edaErscr for event-related SCR analysis
Applies a frequency-domain (FFT-based) filter to an EDA signal. Supports lowpass, highpass, and bandpass filter types using a smooth quadratic transition in the frequency domain.
edaFilter( x, type = c("lowpass", "highpass", "bandpass"), cutoff, order = 2, assay_name = NULL, output_assay = "filtered" )edaFilter( x, type = c("lowpass", "highpass", "bandpass"), cutoff, order = 2, assay_name = NULL, output_assay = "filtered" )
x |
A PhysioExperiment object containing EDA data. |
type |
Filter type: |
cutoff |
Cutoff frequency in Hz. A single numeric value for lowpass or
highpass, or a numeric vector of length 2 ( |
order |
Filter steepness parameter controlling the smoothness of the frequency transition (default: 2). Higher values produce sharper rolloff. |
assay_name |
Name of the input assay. If NULL, uses
|
output_assay |
Name for the output assay (default: "filtered"). |
A modified PhysioExperiment with filtered
data stored in the output_assay and filter parameters recorded in
metadata(x)$eda_filter (a list with type, cutoff,
order, assay_name, and output_assay).
Boucsein, W. (2012). Electrodermal Activity. 2nd ed. Springer. doi:10.1007/978-1-4614-1126-0
edaDownsample for decimation with anti-aliasing,
edaArtifact for artifact detection and correction,
edaDecompose for tonic/phasic decomposition
edaPeaks( x, method = c("gradient", "threshold"), amplitude_min = 0.01, rise_time_min = 0.1, rise_time_max = 5, assay_name = NULL )edaPeaks( x, method = c("gradient", "threshold"), amplitude_min = 0.01, rise_time_min = 0.1, rise_time_max = 5, assay_name = NULL )
x |
A PhysioExperiment object containing EDA data. |
method |
Detection method: |
amplitude_min |
Minimum SCR amplitude in microsiemens (default: 0.01). |
rise_time_min |
Minimum rise time in seconds (default: 0.1). |
rise_time_max |
Maximum rise time in seconds (default: 5.0). |
assay_name |
Name of the input assay. If NULL, uses |
A data.frame with one row per detected SCR and the following
columns:
Character channel label.
Integer sample index of SCR onset.
Numeric onset time in seconds.
Integer sample index of SCR peak.
Numeric peak time in seconds.
Numeric SCR amplitude in microsiemens (peak minus onset).
Numeric rise time from onset to peak in seconds.
Numeric 50\
Returns an empty data.frame with the same columns if no peaks are
found.
Identifies SCR peaks in an EDA signal using either a gradient-based zero-crossing method or an amplitude threshold method. Returns onset, peak, amplitude, rise time, and recovery time for each detected SCR.
Bach, D.R., et al. (2010). "Modelling event-related skin conductance responses." International Journal of Psychophysiology, 75(3), 349-356. doi:10.1016/j.ijpsycho.2010.01.005
Benedek, M., & Kaernbach, C. (2010). "A continuous measure of phasic electrodermal activity." Journal of Neuroscience Methods, 190(1), 80-91. doi:10.1016/j.jneumeth.2010.04.028
edaDecompose for tonic/phasic decomposition (run first),
edaFeatures for summary feature extraction,
plotPeaks for peak visualization,
edaErscr for event-related SCR analysis
Computes per-channel signal quality metrics for electrodermal activity data, including basic statistics, flatline detection, artifact estimation, and an overall quality score.
edaQuality(x, assay_name = NULL)edaQuality(x, assay_name = NULL)
x |
A PhysioExperiment object containing EDA data. |
assay_name |
Name of the input assay. If NULL, uses
|
A data.frame with one row per channel and the following columns:
Channel label
Mean skin conductance
Standard deviation of skin conductance
Minimum skin conductance
Maximum skin conductance
Percentage of samples <= 0
Percentage of signal in flatline segments (runs of consecutive near-zero differences longer than 1 second)
Percentage of gradient-based artifact samples
Estimated signal-to-noise ratio in dB (capped at 60)
Overall quality score from 0 to 100
"good" (>= 70), "acceptable" (>= 40), or "poor"
Kleckner, I.R., et al. (2018). "Simple, transparent, and flexible automated quality assessment procedures for ambulatory electrodermal activity data." IEEE Transactions on Biomedical Engineering, 65(7), 1460-1467. doi:10.1109/TBME.2017.2758643
edaArtifact for artifact detection and correction,
edaFilter for frequency-domain filtering,
edaDecompose for tonic/phasic decomposition
Generates synthetic electrodermal activity (EDA) signals with known tonic (SCL) and phasic (SCR) components for testing and demonstration. SCRs are modeled as biexponential impulse responses (Bateman function).
edaSimulate( n_time = 6000, n_channels = 1, sr = 10, scr_count = 5, scl_level = 5, scr_amplitude = 0.5, noise_sd = 0.01, seed = NULL )edaSimulate( n_time = 6000, n_channels = 1, sr = 10, scr_count = 5, scl_level = 5, scr_amplitude = 0.5, noise_sd = 0.01, seed = NULL )
n_time |
Number of time points (default: 6000). |
n_channels |
Number of EDA channels (default: 1). |
sr |
Sampling rate in Hz (default: 10). |
scr_count |
Number of SCRs to embed (default: 5). |
scl_level |
Baseline skin conductance level in microsiemens (default: 5.0). |
scr_amplitude |
Mean SCR amplitude in microsiemens (default: 0.5). |
noise_sd |
Standard deviation of Gaussian noise (default: 0.01). |
seed |
Random seed for reproducibility (default: NULL). |
A PhysioExperiment object with a single
"raw" assay containing the simulated EDA signal (time x channels
matrix). Channel metadata has type = "EDA" and unit = "uS".
The sampling rate is set to sr.
Boucsein, W. (2012). Electrodermal Activity. 2nd ed. Springer. doi:10.1007/978-1-4614-1126-0
Benedek, M., & Kaernbach, C. (2010). "A continuous measure of phasic electrodermal activity." Journal of Neuroscience Methods, 190(1), 80-91. doi:10.1016/j.jneumeth.2010.04.028
edaDecompose for tonic/phasic decomposition,
edaPeaks for SCR detection,
edaFilter for signal filtering
Applies a mathematical transformation to EDA signal data. Common
transformations include log and square root (to reduce skewness of SCR
amplitudes), z-score standardization, and range normalization. Transformation
parameters are stored in metadata so that edaUntransform can
reverse the operation.
edaTransform( x, method = c("log", "sqrt", "zscore", "range"), assay_name = NULL, output_assay = NULL )edaTransform( x, method = c("log", "sqrt", "zscore", "range"), assay_name = NULL, output_assay = NULL )
x |
A PhysioExperiment object containing EDA data. |
method |
Transformation method: |
assay_name |
Name of the input assay. If NULL, uses
|
output_assay |
Name for the output assay. If NULL, defaults to
|
A modified PhysioExperiment with the transformed assay added and
transformation parameters stored in metadata(x)$eda_transform.
Boucsein, W. (2012). Electrodermal Activity. 2nd ed. Springer. doi:10.1007/978-1-4614-1126-0
edaUntransform for reversing the transformation,
edaFeatures for feature extraction,
edaDecompose for tonic/phasic decomposition
Reverses a transformation previously applied by edaTransform,
using parameters stored in metadata(x)$eda_transform.
edaUntransform(x, assay_name = NULL, output_assay = NULL)edaUntransform(x, assay_name = NULL, output_assay = NULL)
x |
A PhysioExperiment object that has been transformed via
|
assay_name |
Name of the transformed assay to reverse. If NULL, uses the output_assay recorded in the transform metadata. |
output_assay |
Name for the untransformed output assay. If NULL,
defaults to |
A modified PhysioExperiment with the untransformed assay added.
Boucsein, W. (2012). Electrodermal Activity. 2nd ed. Springer. doi:10.1007/978-1-4614-1126-0
edaTransform for applying the initial transformation,
edaDecompose for tonic/phasic decomposition
Generates a synthetic electrodermal activity (EDA) PhysioExperiment object with known tonic (SCL) and phasic (SCR) components. Useful for testing, demonstrations, and vignettes.
make_eda(n_time = 6000, n_channels = 1, sr = 10)make_eda(n_time = 6000, n_channels = 1, sr = 10)
n_time |
Number of time points (default: 6000). |
n_channels |
Number of EDA channels (default: 1). |
sr |
Sampling rate in Hz (default: 10). |
A PhysioExperiment object with a single
"raw" assay containing simulated EDA data. Channel metadata has
type = "EDA" and unit = "uS".
Boucsein, W. (2012). Electrodermal Activity. 2nd ed. Springer. doi:10.1007/978-1-4614-1126-0
make_eda_with_scr for EDA with stimulus events,
edaSimulate for the underlying simulation function,
edaDecompose for tonic/phasic decomposition
x <- make_eda() xx <- make_eda() x
Generates a synthetic electrodermal activity (EDA) PhysioExperiment object
with known SCR events time-locked to stimulus markers. The object includes
regularly spaced stimulus events stored via
PhysioEvents, making it suitable for testing
event-related SCR analysis workflows.
make_eda_with_scr( n_time = 6000, n_channels = 1, sr = 10, n_events = 4, event_interval = 10 )make_eda_with_scr( n_time = 6000, n_channels = 1, sr = 10, n_events = 4, event_interval = 10 )
n_time |
Number of time points (default: 6000). |
n_channels |
Number of EDA channels (default: 1). |
sr |
Sampling rate in Hz (default: 10). |
n_events |
Number of stimulus events to embed (default: 4). |
event_interval |
Interval between events in seconds (default: 10). Note: events are spaced evenly within the usable signal duration rather than at exact fixed intervals. |
A PhysioExperiment object with a single
"raw" assay containing simulated EDA data and stimulus events
accessible via getEvents. Each event has
type = "stimulus" and duration = 0.5 seconds.
Bach, D.R., et al. (2010). "Modelling event-related skin conductance responses." International Journal of Psychophysiology, 75(3), 349-356. doi:10.1016/j.ijpsycho.2010.01.005
make_eda for basic EDA without events,
edaErscr for event-related SCR analysis,
edaSimulate for the underlying simulation function
x <- make_eda_with_scr() xx <- make_eda_with_scr() x
Displays the tonic/phasic decomposition of an EDA signal in a multi-panel
layout. Requires that edaDecompose() has been run first so that
"tonic" and "phasic" assays exist.
plotDecompose( x, channel = 1, time_range = NULL, main = "EDA Decomposition", ... )plotDecompose( x, channel = 1, time_range = NULL, main = "EDA Decomposition", ... )
x |
A PhysioExperiment object with tonic and phasic assays. |
channel |
Integer or character specifying which channel to plot (default: 1). |
time_range |
Numeric vector of length 2 giving start and end times in seconds. If NULL, the full signal is plotted. |
main |
Character string for the overall plot title (default: "EDA Decomposition"). |
... |
Additional arguments passed to |
Invisible NULL. Called for its side effect of producing a plot.
Boucsein, W. (2012). Electrodermal Activity. 2nd ed. Springer. doi:10.1007/978-1-4614-1126-0
plotEda for basic EDA time series plotting,
edaDecompose for performing the decomposition,
plotPeaks for SCR peak visualization
Plots electrodermal activity signals as time series using base R graphics. Multiple channels are displayed in stacked panels. Optionally overlays vertical event markers.
plotEda( x, channels = NULL, time_range = NULL, assay_name = NULL, show_events = TRUE, main = "EDA Signal", col = NULL, ... )plotEda( x, channels = NULL, time_range = NULL, assay_name = NULL, show_events = TRUE, main = "EDA Signal", col = NULL, ... )
x |
A PhysioExperiment object containing EDA data. |
channels |
Integer or character vector specifying which channels to plot. If NULL (default), all channels are plotted. |
time_range |
Numeric vector of length 2 giving start and end times
in seconds for zooming (e.g., |
assay_name |
Name of the assay to plot. If NULL, uses
|
show_events |
Logical; if TRUE (default) and events exist, draws vertical dashed lines at event onsets. |
main |
Character string for the plot title (default: "EDA Signal"). |
col |
Vector of colors for the channels. If NULL, uses default palette. |
... |
Additional arguments passed to |
Invisible NULL. Called for its side effect of producing a plot.
Boucsein, W. (2012). Electrodermal Activity. 2nd ed. Springer. doi:10.1007/978-1-4614-1126-0
plotDecompose for decomposition visualization,
plotPeaks for SCR peak visualization,
edaDecompose for tonic/phasic decomposition
Plots an EDA signal with detected SCR peaks, onsets, and amplitude lines
annotated. If no peaks data.frame is supplied, peaks are computed
automatically via edaPeaks.
plotPeaks( x, peaks = NULL, channel = 1, time_range = NULL, assay_name = NULL, main = "SCR Peaks", ... )plotPeaks( x, peaks = NULL, channel = 1, time_range = NULL, assay_name = NULL, main = "SCR Peaks", ... )
x |
A PhysioExperiment object containing EDA data. |
peaks |
A data.frame as returned by |
channel |
Integer or character specifying which channel to plot (default: 1). |
time_range |
Numeric vector of length 2 giving start and end times in seconds. If NULL, the full signal is plotted. |
assay_name |
Name of the assay to plot. If NULL, uses "phasic" if
available, otherwise |
main |
Character string for the plot title (default: "SCR Peaks"). |
... |
Additional arguments passed to |
Invisible NULL. Called for its side effect of producing a plot.
Boucsein, W. (2012). Electrodermal Activity. 2nd ed. Springer. doi:10.1007/978-1-4614-1126-0
plotEda for basic EDA time series plotting,
plotDecompose for decomposition visualization,
edaPeaks for SCR peak detection