View source: R/outliers_epoch.R
| outliers_epoch | R Documentation |
Function for selecting outlier epochs for one subject and one sensor in chosen time points. Epochs are marked as outliers based on one of the following criteria: interquartile range criterion, percentile approach or Hampel filter method.
outliers_epoch(
data,
amplitude = "signal",
subject = NULL,
sensor = NULL,
time = NULL,
method,
k_iqr = 1.5,
k_mad = 3,
p = 0.975,
print_tab = TRUE
)
data |
A data frame, tibble or a database table with input data, required columns: subject, sensor, time, epoch and the column with EEG amplitude named as in |
amplitude |
A character specifying the name of the column from input data with an EEG amplitude values. Default is |
subject |
An integer or character ID of selected subject. |
sensor |
An integer or character ID of selected sensor. |
time |
A vector with time range for outliers detection. If not defined, the outliers are searched for all time points in the dataset. |
method |
A character denoting the method used for outlier detection. The options are: |
k_iqr |
A positive numeric value denoting the scaling factor used in the IQR criterion. Default value is |
k_mad |
A positive numeric value denoting the scaling factor used in the Hampel filter method. Default value is |
p |
A probability value from |
print_tab |
Logical. Indicates, whether result table should be printed in console. Default is |
The input data frame or database table must contain at least following columns:
subject - a column with subject IDs,
sensor - a column with sensor labels,
time - a column with time point numbers,
signal (or other name specified in amplitude parameter) - a column with measured EEG signal values.
The outlier detection method is chosen through method argument. The possibilities are
iqr: The interquartile range criterion, values outside the interval [lower quartile - k_iqr * IQR, upper quartile + k_iqr * IQR] are considered as outliers. IQR denotes interquartile range and k_iqr the scaling factor.
percentile: The percentile method, values outside the interval defined by the chosen percentiles are considered as outliers. Note: chosing small pleads to marking too many (or all) values.
hampel: The Hampel filter method, values outside the interval [median - k_mad * MAD, median + k_mad * MAD] are considered as outliers. MAD denotes median absolute deviation and k_mad the scaling factor.
Each of the above methods operates independently per time point, not globally across time.
A list with following components:
epoch_table |
A data frame with epoch ID and the number of time points in which the epoch was evaluated as outlier. (Only epochs with occurrence of outliers in at least one time point are included.) |
outliers_data |
A data frame with subset of data corresponding to the outliers found. (The full record for each flagged point from |
With the setting print_tab = TRUE, the epoch_table is also printed to the console.
# Outlier epoch detection for subject 2, electrode E45 for the whole time range with IQR method
outliers_epoch(epochdata, amplitude = "signal", subject = 2, sensor = "E45", method = "iqr")
# From the result table we see that epochs 14 and 15 were marked as outliers in 50 cases out of 50
# Outlier epoch detection for subject 2, electrode E45 for the whole time range
# using percentile method with 1 and 99 percentiles
outliers_epoch(epochdata, amplitude = "signal", subject = 2, sensor = "E45",
method = "percentile", p = 0.99)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.