| 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 [aut, cre] |
| Maintainer: | Yusuke Matsui <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.4 |
| Built: | 2026-10-03 13:41:53 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 epoch-based wavelet / machine-learning methods) and optionally corrects them via interpolation or NA replacement. An accelerometer channel can additionally gate out high-motion epochs (Taylor et al., 2015).
edaArtifact( x, methods = c("threshold", "gradient", "flatline"), threshold_range = c(0.001, 60), gradient_max = NULL, flatline_sec = 5, epoch_sec = 5, wavelet_k = 5, ml_threshold = 0.5, acc_channel = NULL, acc_threshold = NULL, 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, epoch_sec = 5, wavelet_k = 5, ml_threshold = 0.5, acc_channel = NULL, acc_threshold = NULL, 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). |
epoch_sec |
Epoch length in seconds for the |
wavelet_k |
Robust-outlier multiplier for the |
ml_threshold |
Probability threshold for the |
acc_channel |
Optional channel index or label (or several) identifying
accelerometer channel(s). When supplied, per-epoch motion energy (variance
of the accelerometer magnitude) gates the EDA channels: epochs with energy
above |
acc_threshold |
Motion-energy threshold for accelerometer gating. If
|
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.
(only when "wavelet"/"ml" or accelerometer
gating is used) A data.frame, one row per EDA channel per epoch,
with the epoch bounds and, as applicable, wavelet_flag,
ml_prob, ml_flag, motion_energy, and acc_flag.
If correct != "none", the corrected signal is stored in the
output_assay.
Taylor, S., et al. (2015). "Automatic identification of artifacts in electrodermal activity data." IEEE EMBC, 1934-1937. doi:10.1109/EMBC.2015.7318762
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
x <- edaSimulate(n_time = 600, sr = 10, seed = 1) xa <- edaArtifact(x, methods = c("threshold", "gradient"), correct = "none") S4Vectors::metadata(xa)$eda_artifacts$summaryx <- edaSimulate(n_time = 600, sr = 10, seed = 1) xa <- edaArtifact(x, methods = c("threshold", "gradient"), correct = "none") S4Vectors::metadata(xa)$eda_artifacts$summary
Estimates trial-by-trial latent sudomotor input amplitudes that best explain
the skin-conductance signal, in the spirit of the PsPM dynamic causal model
for SCR (Bach et al., 2010, 2011). Each event contributes a non-negative
latent input whose skin-conductance response is the canonical
scrf kernel; the per-event amplitudes are estimated by
non-negative least squares against a low-frequency cosine drift basis, and
the input timings are optionally refined by a nonlinear local search
(the "dynamic" step).
edaDCM( x, events, channel = 1, assay_name = NULL, tau1 = 0.75, tau2 = 2, drift = 6, refine_latency = TRUE, latency_window = 1.5 )edaDCM( x, events, channel = 1, assay_name = NULL, tau1 = 0.75, tau2 = 2, drift = 6, refine_latency = TRUE, latency_window = 1.5 )
x |
A PhysioExperiment object with EDA data. |
events |
A |
channel |
EDA channel index or label (default: 1). |
assay_name |
Input assay (default: |
tau1, tau2
|
SCR rise/decay time constants in seconds. |
drift |
Number of cosine drift terms (default: 6). |
refine_latency |
Logical; refine each event's onset by a local search to
improve the fit (default: |
latency_window |
Half-width in seconds of the latency search (default: 1.5). |
Unlike edaGLM, which estimates one amplitude per condition,
edaDCM estimates one latent input amplitude per event.
A list of class "eda_dcm" with:
a data.frame with event, onset,
onset_refined, amplitude (per-event latent input), and
condition if present.
fitted signal; residuals; r_squared.
Bach, D.R., Daunizeau, J., Friston, K.J., & Dolan, R.J. (2010). "Dynamic causal modelling of anticipatory skin conductance responses." Biological Psychology, 85(1), 163-170. doi:10.1016/j.biopsycho.2010.06.007
edaGLM for the condition-level GLM,
scrf for the response kernel.
ev <- data.frame(onset = c(10, 30, 50, 70)) pe <- edaSimulate(n_time = 1000, sr = 10, scr_count = 4, seed = 1) fit <- edaDCM(pe, ev, refine_latency = FALSE) fit$estimatesev <- data.frame(onset = c(10, 30, 50, 70)) pe <- edaSimulate(n_time = 1000, sr = 10, scr_count = 4, seed = 1) fit <- edaDCM(pe, ev, refine_latency = FALSE) fit$estimates
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", "dda", "cvxeda", "cvxeda_fast"), cutoff = 0.05, window_sec = 4, tau1 = 0.75, tau2 = 2, alpha = 0.01, gamma = 0.1, delta_knot = 10, qp_sr = 4, optimize_tau = FALSE, assay_name = NULL, output_tonic = "tonic", output_phasic = "phasic" )edaDecompose( x, method = c("highpass", "median", "cda", "dda", "cvxeda", "cvxeda_fast"), cutoff = 0.05, window_sec = 4, tau1 = 0.75, tau2 = 2, alpha = 0.01, gamma = 0.1, delta_knot = 10, qp_sr = 4, optimize_tau = FALSE, 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. |
delta_knot |
Tonic spline knot spacing in seconds for the |
qp_sr |
Target rate (Hz) at which the |
optimize_tau |
Logical; for |
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"). |
Six 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 a
non-negativity constraint on the driver signal; optional tau2
optimisation.
Discrete Decomposition Analysis (Benedek & Kaernbach, 2010): the continuous CDA driver is reduced to a sparse impulse train (one impulse per significant SCR) and reconvolved.
Convex optimization decomposition (Greco et al., 2016), solved as a quadratic program: a cubic-knot spline tonic basis and a sparse, non-negative sudomotor driver through a biexponential system, with L1 sparsity on the driver and L2 smoothness on the tonic. Requires the quadprog solver; degrades gracefully to the Wiener approximation if it is unavailable.
Fast Wiener/ADMM approximation of cvxEDA (no solver dependency); the original iterative approximation.
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 variants only) The sudomotor nerve activity driver signal.
Decomposition parameters are stored in metadata(x)$eda_decompose;
for method = "cvxeda" this also records the per-channel solver
engine ("qp" or "wiener_fallback") and final QP objective.
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
x <- edaSimulate(n_time = 600, sr = 10, seed = 1) xd <- edaDecompose(x, method = "highpass") SummarizedExperiment::assayNames(xd) # cvxEDA solves a quadratic program via the quadprog Suggests dependency xc <- edaDecompose(x, method = "cvxeda")x <- edaSimulate(n_time = 600, sr = 10, seed = 1) xd <- edaDecompose(x, method = "highpass") SummarizedExperiment::assayNames(xd) # cvxEDA solves a quadratic program via the quadprog Suggests dependency xc <- edaDecompose(x, method = "cvxeda")
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
x <- edaSimulate(n_time = 600, sr = 10, seed = 1) xd <- edaDownsample(x, target_sr = 5) samplingRate(xd)x <- edaSimulate(n_time = 600, sr = 10, seed = 1) xd <- edaDownsample(x, target_sr = 5) samplingRate(xd)
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
x <- make_eda_with_scr(n_time = 1200, sr = 10, n_events = 4) x <- edaDecompose(x) edaErscr(x)x <- make_eda_with_scr(n_time = 1200, sr = 10, n_events = 4) x <- edaDecompose(x) edaErscr(x)
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, ns_scr_amplitude_min = 0.05 )edaFeatures( x, peaks = NULL, window = NULL, assay_name = NULL, ns_scr_amplitude_min = 0.05 )
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 |
ns_scr_amplitude_min |
Minimum SCR amplitude (in uS) to count a peak as a non-specific SCR (default 0.05, the standard threshold). |
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.
Integer count of non-specific SCRs (amplitude >=
ns_scr_amplitude_min).
Numeric non-specific SCR frequency (per minute):
ns_scr_count / duration_min.
Integer number of significant SCRs in the CDA/DDA driver,
or NA if no driver assay exists.
Numeric sum of the CDA/DDA driver SCR amplitudes (uS),
or NA.
Numeric integrated SCR: time-integral of the phasic
driver (uS*s), or NA.
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
x <- edaSimulate(n_time = 600, sr = 10, seed = 1) x <- edaDecompose(x) edaFeatures(x)x <- edaSimulate(n_time = 600, sr = 10, seed = 1) x <- edaDecompose(x) edaFeatures(x)
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
x <- edaSimulate(n_time = 600, sr = 10, seed = 1) xf <- edaFilter(x, type = "lowpass", cutoff = 1) SummarizedExperiment::assayNames(xf)x <- edaSimulate(n_time = 600, sr = 10, seed = 1) xf <- edaFilter(x, type = "lowpass", cutoff = 1) SummarizedExperiment::assayNames(xf)
Fits a general linear model of the skin-conductance signal against
event-related regressors, each a stick function at the event onsets convolved
with the canonical skin-conductance response function (scrf;
Bach & Friston, 2013). Events are grouped into conditions; each condition
yields an amplitude estimate (beta) with a standard error and t statistic.
A low-frequency cosine drift basis absorbs the tonic level. Optionally, a
temporal-derivative basis is added per condition to accommodate response
latency differences.
edaGLM( x, events, conditions = NULL, channel = 1, assay_name = NULL, tau1 = 0.75, tau2 = 2, basis = c("canonical", "derivative"), drift = 6 )edaGLM( x, events, conditions = NULL, channel = 1, assay_name = NULL, tau1 = 0.75, tau2 = 2, basis = c("canonical", "derivative"), drift = 6 )
x |
A PhysioExperiment object with EDA data. |
events |
A |
conditions |
Optional character vector selecting/ordering the conditions
(default: the unique conditions in |
channel |
EDA channel index or label to model (default: 1). |
assay_name |
Input assay (default: |
tau1, tau2
|
SCR rise/decay time constants in seconds. |
basis |
|
drift |
Number of cosine drift terms (default: 6). |
A list of class "eda_glm" with:
a data.frame with condition,
beta, se, t, p (canonical amplitude per
condition; NA for a condition dropped due to collinearity).
(basis = "derivative") the derivative-regressor betas.
fitted signal; residuals; sigma; df;
r_squared; rank; n_regressors; collinear.
Bach, D.R., & Friston, K.J. (2013). "Model-based analysis of skin conductance responses." Psychophysiology, 50(1), 15-22. doi:10.1111/j.1469-8986.2012.01483.x
edaDCM for trial-wise latent input estimation,
scrf for the response kernel.
ev <- data.frame(onset = c(10, 30, 50, 70), condition = c("A", "A", "B", "B")) pe <- edaSimulate(n_time = 1000, sr = 10, scr_count = 4, seed = 1) fit <- edaGLM(pe, ev) fit$coefficientsev <- data.frame(onset = c(10, 30, 50, 70), condition = c("A", "A", "B", "B")) pe <- edaSimulate(n_time = 1000, sr = 10, scr_count = 4, seed = 1) fit <- edaGLM(pe, ev) fit$coefficients
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.
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% recovery time in seconds, or NA.
Returns an empty data.frame with the same columns if no peaks are
found.
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
x <- edaSimulate(n_time = 600, sr = 10, seed = 1) x <- edaDecompose(x) head(edaPeaks(x))x <- edaSimulate(n_time = 600, sr = 10, seed = 1) x <- edaDecompose(x) head(edaPeaks(x))
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
x <- edaSimulate(n_time = 600, sr = 10, seed = 1) edaQuality(x)x <- edaSimulate(n_time = 600, sr = 10, seed = 1) edaQuality(x)
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. The ground-truth components used to
build the signal are stored in metadata(x)$eda_truth as a list with:
time x channels matrix of the true tonic (SCL) component.
time x channels matrix of the true phasic (SCR) component.
a data.frame of the true SCR onsets with columns
channel, sample, time_sec, and amplitude.
This lets edaSimulate() serve as a ground-truth oracle for testing
decomposition (e.g. edaDecompose with method="cvxeda").
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
x <- edaSimulate(n_time = 600, sr = 10, seed = 1) x str(S4Vectors::metadata(x)$eda_truth, max.level = 1)x <- edaSimulate(n_time = 600, sr = 10, seed = 1) x str(S4Vectors::metadata(x)$eda_truth, max.level = 1)
Extracts the sympathetic skin response evoked by each stimulus from a skin conductance recording: the response onset latency, the baseline-to-peak amplitude, the waveform morphology (monophasic / biphasic) and a present/absent classification. A per-channel summary reports the response rate, mean latency and amplitude, an amplitude-habituation slope across the repeated stimuli, and the clinical absent-SSR flag.
edaSSR( x, stimulus_events, assay_name = NULL, response_window = c(0.5, 8), baseline_sec = 2, amplitude_min = 0.05, recovery_frac = 0.1, onset_frac = 0.05, morphology_frac = 0.3, events_unit = c("auto", "index", "seconds") )edaSSR( x, stimulus_events, assay_name = NULL, response_window = c(0.5, 8), baseline_sec = 2, amplitude_min = 0.05, recovery_frac = 0.1, onset_frac = 0.05, morphology_frac = 0.3, events_unit = c("auto", "index", "seconds") )
x |
A PhysioExperiment object with a skin conductance assay. |
stimulus_events |
Stimulus times, as sample indices or times in seconds
(see |
assay_name |
Input assay (default: |
response_window |
Numeric |
baseline_sec |
Length in seconds of the pre-stimulus window used to estimate and remove the tonic trend (default 2). |
amplitude_min |
Minimum detrended peak amplitude (uS) for a response to count as present (default 0.05). |
recovery_frac |
Fraction of the peak amplitude the trace must fall back after the peak for the response to be accepted as phasic (rather than a monotone drift; default 0.1). |
onset_frac |
Fraction of the SSR amplitude above baseline at which the response onset (and hence latency) is marked (default 0.05). |
morphology_frac |
Fraction of the SSR amplitude an opposite-going deflection must reach for the response to be classed biphasic (default 0.3). |
events_unit |
Unit of |
The tonic trend estimated from the pre-stimulus baseline is subtracted from
each response window, so slow skin-conductance drift is neither counted as a
response nor mistaken for a biphasic deflection. In the detrended window the
phasic peak is located; a response is accepted only if it exceeds
amplitude_min and recovers (rises then falls), and the latency is measured
from the stimulus to the onset of that phasic deflection (Vetrugno et al.
2003).
An eda_ssr object with responses (one row per stimulus per
channel: channel, stimulus, stim_time, present, latency,
amplitude, peak_time, morphology) and summary (one row per channel:
channel, n_stimuli, n_present, response_rate, mean_latency,
mean_amplitude, habituation_slope, ssr_absent).
Vetrugno, R. et al. (2003). Sympathetic skin response: basic mechanisms and clinical applications. Clin Auton Res 13(4):256-270.
# 3 stimuli at 10, 40 and 70 s, each followed by an SCR pe <- edaSimulate(n_time = 900, sr = 10, scr_count = 0, seed = 1) sig <- as.numeric(SummarizedExperiment::assay(pe)) sr <- 10 for (st in c(10, 40, 70)) { t <- (seq_along(sig) - 1) / sr - st sig <- sig + 0.5 * ifelse(t > 0, (exp(-t / 3) - exp(-t / 0.75)), 0) } SummarizedExperiment::assay(pe) <- matrix(sig, ncol = 1) res <- edaSSR(pe, stimulus_events = c(10, 40, 70), events_unit = "seconds") res$summary# 3 stimuli at 10, 40 and 70 s, each followed by an SCR pe <- edaSimulate(n_time = 900, sr = 10, scr_count = 0, seed = 1) sig <- as.numeric(SummarizedExperiment::assay(pe)) sr <- 10 for (st in c(10, 40, 70)) { t <- (seq_along(sig) - 1) / sr - st sig <- sig + 0.5 * ifelse(t > 0, (exp(-t / 3) - exp(-t / 0.75)), 0) } SummarizedExperiment::assay(pe) <- matrix(sig, ncol = 1) res <- edaSSR(pe, stimulus_events = c(10, 40, 70), events_unit = "seconds") res$summary
Spectral power of the electrodermal signal in the sympathetic band (0.045-0.25 Hz by default), following Posada-Quintero et al. (2016). The signal is optionally downsampled, its Welch power spectral density is estimated, and the band power is reported both in absolute units and normalised by the total spectral power.
edaSympatheticIndex( x, band = c(0.045, 0.25), assay_name = NULL, resample_hz = 2, seg_sec = NULL )edaSympatheticIndex( x, band = c(0.045, 0.25), assay_name = NULL, resample_hz = 2, seg_sec = NULL )
x |
A PhysioExperiment object with an electrodermal assay. |
band |
Numeric |
assay_name |
Input assay (default: |
resample_hz |
Rate (Hz) the signal is downsampled to before spectral
estimation (default 2; |
seg_sec |
Welch segment length in seconds ( |
A data frame with one row per channel: channel, edasymp
(absolute band power), edasymp_norm (band power / total power, in
[0, 1], or NA for a constant / zero-power channel), total_power, and
the band_low/band_high used.
Posada-Quintero, H.F. et al. (2016). Power spectral density analysis of electrodermal activity for sympathetic function assessment. Ann Biomed Eng 44(10):3124-3135.
pe <- edaSimulate(n_time = 1200, sr = 4, scr_count = 6, seed = 1) edaSympatheticIndex(pe)pe <- edaSimulate(n_time = 1200, sr = 4, scr_count = 6, seed = 1) edaSympatheticIndex(pe)
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
x <- edaSimulate(n_time = 600, sr = 10, seed = 1) xt <- edaTransform(x, method = "log") SummarizedExperiment::assayNames(xt)x <- edaSimulate(n_time = 600, sr = 10, seed = 1) xt <- edaTransform(x, method = "log") SummarizedExperiment::assayNames(xt)
A time-resolved sympathetic-tone index built by complex demodulation of the dominant components of the electrodermal signal in the sympathetic band (Posada-Quintero et al. 2016). The two strongest spectral components in the band are demodulated to their instantaneous amplitudes, combined, and normalised to a reproducible trajectory that rises when sympathetic oscillations appear.
edaTVSymp( x, band = c(0.08, 0.24), assay_name = NULL, resample_hz = 2, n_components = 2, lp_hz = NULL )edaTVSymp( x, band = c(0.08, 0.24), assay_name = NULL, resample_hz = 2, n_components = 2, lp_hz = NULL )
x |
A PhysioExperiment object with an electrodermal assay. |
band |
Numeric |
assay_name |
Input assay (default: |
resample_hz |
Rate (Hz) the signal is downsampled to (default 2; |
n_components |
Number of dominant band components to demodulate (default 2). |
lp_hz |
Low-pass cutoff (Hz) of the demodulation envelope (default 0.5 of the band width). |
A data frame with one row per time sample per channel: channel,
time_sec, tvsymp (combined instantaneous amplitude) and tvsymp_norm
(unit-variance normalised). The dominant component frequencies are attached
as the "components" attribute.
Posada-Quintero, H.F. et al. (2016). Time-varying analysis of electrodermal activity during exercise. PLoS ONE 11(8):e0161553.
pe <- edaSimulate(n_time = 1200, sr = 4, scr_count = 6, seed = 1) tv <- edaTVSymp(pe) head(tv)pe <- edaSimulate(n_time = 1200, sr = 4, scr_count = 6, seed = 1) tv <- edaTVSymp(pe) head(tv)
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
x <- edaSimulate(n_time = 600, sr = 10, seed = 1) xt <- edaTransform(x, method = "log") xu <- edaUntransform(xt) SummarizedExperiment::assayNames(xu)x <- edaSimulate(n_time = 600, sr = 10, seed = 1) xt <- edaTransform(x, method = "log") xu <- edaUntransform(xt) SummarizedExperiment::assayNames(xu)
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
x <- edaSimulate(n_time = 600, sr = 10, seed = 1) x <- edaDecompose(x) plotDecompose(x)x <- edaSimulate(n_time = 600, sr = 10, seed = 1) x <- edaDecompose(x) plotDecompose(x)
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
x <- edaSimulate(n_time = 600, sr = 10, seed = 1) plotEda(x)x <- edaSimulate(n_time = 600, sr = 10, seed = 1) plotEda(x)
Computes and plots the grand-average phasic skin-conductance waveform
time-locked to stimulus events, separately per event type (condition), with a
confidence-interval band. Each event's epoch over window is baseline
corrected against the pre-event baseline interval, epochs are averaged
within a condition, and the band is the standard error of the mean scaled to
ci_level (Boucsein 2012; Bach event-related SCR averaging). The epoching
reuses the event onsets from getEvents() on the same sample grid as
edaErscr().
plotErscrGrandAverage( x, event_types = NULL, window = c(-1, 6), baseline = c(-1, 0), channel = 1, assay_name = NULL, ci = c("sem", "none"), ci_level = 0.95, colors = NULL, plot = TRUE, ... )plotErscrGrandAverage( x, event_types = NULL, window = c(-1, 6), baseline = c(-1, 0), channel = 1, assay_name = NULL, ci = c("sem", "none"), ci_level = 0.95, colors = NULL, plot = TRUE, ... )
x |
A PhysioExperiment object with a skin conductance assay and events. |
event_types |
Character vector of event types to average and overlay;
|
window |
Numeric |
baseline |
Numeric |
channel |
Channel index to average (default 1). |
assay_name |
Input assay (default: |
ci |
Confidence band: |
ci_level |
Confidence level for the SEM band (default 0.95). |
colors |
Optional per-condition colours (recycled). |
plot |
Draw the plot (default |
... |
Additional arguments passed to |
Invisibly, an erscr_grand_average object with grand_average (a
tidy data frame of type, time, mean, sd, sem, ci_lower,
ci_upper, n_trials), the per-condition baseline-corrected epochs
matrices, and the time axis.
Boucsein, W. (2012). Electrodermal Activity. 2nd ed. Springer.
x <- make_eda_with_scr() ga <- plotErscrGrandAverage(x, plot = FALSE) head(ga$grand_average)x <- make_eda_with_scr() ga <- plotErscrGrandAverage(x, plot = FALSE) head(ga$grand_average)
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
x <- edaSimulate(n_time = 600, sr = 10, seed = 1) x <- edaDecompose(x) plotPeaks(x)x <- edaSimulate(n_time = 600, sr = 10, seed = 1) x <- edaDecompose(x) plotPeaks(x)
First-class canonical skin-conductance response kernel used throughout
PhysioEDA as the single source of the SCR shape (simulation,
CDA / cvxEDA deconvolution, and GLM designs). The response is the
biexponential (Bateman) function
h(t) = exp(-t / tau2) - exp(-t / tau1) for t >= 0 (0 otherwise),
optionally augmented with a Gaussian bump for the PsPM-style canonical form
(Bach et al., 2010). Both the kernel and its first/second time-derivatives are
available (the derivatives drive GLM temporal/dispersion regressors).
scrf( t, tau1 = 0.75, tau2 = 2, form = c("bateman", "pspm_canonical"), normalize = c("peak", "area", "none"), deriv = 0, bump_amp = 0.3, bump_center = NULL, bump_sd = 0.7 )scrf( t, tau1 = 0.75, tau2 = 2, form = c("bateman", "pspm_canonical"), normalize = c("peak", "area", "none"), deriv = 0, bump_amp = 0.3, bump_center = NULL, bump_sd = 0.7 )
t |
Numeric vector of times in seconds. Values |
tau1 |
SCR rise time constant in seconds (default: 0.75). |
tau2 |
SCR decay time constant in seconds (default: 2.0). Must differ
from |
form |
Kernel family: |
normalize |
Normalisation of the kernel: |
deriv |
Derivative order to return: 0 (kernel), 1, or 2. |
bump_amp |
Gaussian bump amplitude, relative to the raw Bateman peak,
for |
bump_center |
Gaussian bump centre in seconds (default: the analytic Bateman peak time). |
bump_sd |
Gaussian bump standard deviation in seconds (default: 0.7). |
A numeric vector the same length as t: the requested derivative
of the (optionally normalised) response kernel.
Bach, D.R., Flandin, G., Friston, K.J., & Dolan, R.J. (2010). "Modelling event-related skin conductance responses." International Journal of Psychophysiology, 75(3), 349-356. doi:10.1016/j.ijpsycho.2010.01.005
scrfPeak for the analytic Bateman maximum,
edaSimulate and edaDecompose which consume it.
t <- seq(0, 15, by = 0.1) k <- scrf(t) # unit-peak Bateman kernel dk <- scrf(t, deriv = 1) # its temporal derivative ck <- scrf(t, form = "pspm_canonical")t <- seq(0, 15, by = 0.1) k <- scrf(t) # unit-peak Bateman kernel dk <- scrf(t, deriv = 1) # its temporal derivative ck <- scrf(t, form = "pspm_canonical")
Returns the closed-form time and amplitude of the maximum of the raw
biexponential (Bateman) response used by scrf.
scrfPeak(tau1 = 0.75, tau2 = 2)scrfPeak(tau1 = 0.75, tau2 = 2)
tau1 |
SCR rise time constant in seconds (default: 0.75). |
tau2 |
SCR decay time constant in seconds (default: 2.0). |
A list with time (seconds) and amplitude (the raw
Bateman value at the peak).
scrfPeak()scrfPeak()