eeg_ica | R Documentation |
This function returns an extended eeg_lst
, eeg_ica_lst
, with the mixing and unmixing
matrix of every recording. It is possible to visualize the topography
of the components with plot_components()
. In order to extract the amplitude of
the components with respect to time use eeg_ica_show()
, see examples section. To remove the
unwanted components, use eeg_ica_keep()
.
eeg_ica(
.data,
...,
.ignore = .type == "artifact",
.method = fast_ICA,
.config = list()
)
.data |
An eeg_lst object |
... |
Channels to include in ICA transformation. All the channels by default, but eye channels and reference channels should be removed. |
.ignore |
Events that should be ignored in the ICA, set to NULL for not using the events table. |
.method |
Methods from different packages: fast_ICA, a wrapper of fastICA::fastICA, (default), and some more experimental .methods: fast_ICA2 and adapt_fast_ICA adapted from fICA package. It can also accept a custom function, see details. |
.config |
Other parameters passed in a list to the ICA method. See the documentation of the relevant .method. |
It is possible to also use a custom function in the method
argument. The function should return
a list that with A
(mixing matrix), consistent with the formulation X = S %*% A
, where X is matrix
of N_samples by N_channels and/or W
(unmixing matrix), consistent with the formulation X %*% W = S
.
Some packages with other ICA methods or implementations: steadyICA
and ica
.
An eeg_ica_lst object
Other ICA functions:
eeg_ica_cor_tbl()
,
eeg_ica_keep()
,
eeg_ica_show()
,
eeg_ica_summary_tbl()
,
eeg_ica_var_tbl()
,
plot_components()
Other preprocessing functions:
eeg_baseline()
,
eeg_downsample()
,
eeg_ica_keep()
,
eeg_rereference()
,
eeg_segment()
,
filt
# For demonstration only, since ICA won't converge
# Suppressing an important warning:
suppressWarnings(data_faces_10_trials %>%
eeg_ica(-EOGH, -EOGV, -M1, -M2, .method = fast_ICA, .config = list(maxit = 10)))
## The example can only bu run, if python is properly configured (see reticulate package help)
## Here a python ICA function is used:
## Not run:
library(reticulate)
use_condaenv("anaconda3") # use the appropriate environment
sk <- import("sklearn.decomposition")
py_fica <- function(x) {
x <- as.matrix(x)
ica <- sk$FastICA(whiten = TRUE, random_state = 23L)
X <- scale(x, scale = FALSE) %>%
as.matrix(x)
S <- ica$fit_transform(X)
W <- t(ica$components_)
list(W = W)
}
data_ica_py <- eeg_ica(data_faces_10_trials, -EOGH, -EOGV, -M1, -M2, .method = py_fica)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.