mne.preprocessing.
ICA
(n_components=None, max_pca_components=None, n_pca_components=None, noise_cov=None, random_state=None, method='fastica', fit_params=None, max_iter=200, verbose=None)[source]¶M/EEG signal decomposition using Independent Component Analysis (ICA).
This object can be used to estimate ICA components and then remove some from Raw or Epochs for data exploration or artifact correction.
Caveat! If supplying a noise covariance, keep track of the projections available in the cov or in the raw object. For example, if you are interested in EOG or ECG artifacts, EOG and ECG projections should be temporally removed before fitting ICA, for example:
>> projs, raw.info['projs'] = raw.info['projs'], []
>> ica.fit(raw)
>> raw.info['projs'] = projs
Note
Methods currently implemented are FastICA (default), Infomax, Extended Infomax, and Picard. Infomax can be quite sensitive to differences in floating point arithmetic. Extended Infomax seems to be more stable in this respect enhancing reproducibility and stability of results.
Warning
ICA is sensitive to low-frequency drifts and therefore requires the data to be high-pass filtered prior to fitting. Typically, a cutoff frequency of 1 Hz is recommended.
Parameters: |
|
---|
Notes
Reducing the tolerance speeds up estimation at the cost of consistency of
the obtained results. It is difficult to directly compare tolerance levels
between Infomax and Picard, but for Picard and FastICA a good rule of thumb
is tol_fastica = tol_picard ** 2
.
References
[1] | (1, 2) Hyvärinen, A., 1999. Fast and robust fixed-point algorithms for independent component analysis. IEEE transactions on Neural Networks, 10(3), pp.626-634. |
[2] | (1, 2) Bell, A.J., Sejnowski, T.J., 1995. An information-maximization approach to blind separation and blind deconvolution. Neural computation, 7(6), pp.1129-1159. |
[3] | (1, 2) Lee, T.W., Girolami, M., Sejnowski, T.J., 1999. Independent component analysis using an extended infomax algorithm for mixed subgaussian and supergaussian sources. Neural computation, 11(2), pp.417-441. |
[4] | (1, 2) Ablin, P., Cardoso, J.F., Gramfort, A., 2017. Faster Independent Component Analysis by preconditioning with Hessian approximations. arXiv:1706.08171 |
Attributes: |
|
---|
Methods
__contains__ (ch_type) |
Check channel type membership. |
__hash__ ($self, /) |
Return hash(self). |
apply (inst[, include, exclude, …]) |
Remove selected components from the signal. |
copy () |
Copy the ICA object. |
detect_artifacts (raw[, start_find, …]) |
Run ICA artifacts detection workflow. |
find_bads_ecg (inst[, ch_name, threshold, …]) |
Detect ECG related components using correlation. |
find_bads_eog (inst[, ch_name, threshold, …]) |
Detect EOG related components using correlation. |
fit (inst[, picks, start, stop, decim, …]) |
Run the ICA decomposition on raw data. |
get_components () |
Get ICA topomap for components as numpy arrays. |
get_sources (inst[, add_channels, start, stop]) |
Estimate sources given the unmixing matrix. |
plot_components ([picks, ch_type, res, …]) |
Project unmixing matrix on interpolated sensor topography. |
plot_overlay (inst[, exclude, picks, start, …]) |
Overlay of raw and cleaned signals given the unmixing matrix. |
plot_properties (inst[, picks, axes, dB, …]) |
Display component properties. |
plot_scores (scores[, exclude, labels, …]) |
Plot scores related to detected components. |
plot_sources (inst[, picks, exclude, start, …]) |
Plot estimated latent sources given the unmixing matrix. |
save (fname) |
Store ICA solution into a fiff file. |
score_sources (inst[, target, score_func, …]) |
Assign score to components based on statistic or metric. |
__contains__
(ch_type)[source]¶Check channel type membership.
Parameters: |
|
---|---|
Returns: |
|
Examples
Channel type membership can be tested as:
>>> 'meg' in inst
True
>>> 'seeg' in inst
False
__hash__
($self, /)¶Return hash(self).
apply
(inst, include=None, exclude=None, n_pca_components=None, start=None, stop=None)[source]¶Remove selected components from the signal.
Given the unmixing matrix, transform data, zero out components, and inverse transform the data. This procedure will reconstruct M/EEG signals from which the dynamics described by the excluded components is subtracted. The data is processed in place.
Parameters: |
|
---|---|
Returns: |
|
compensation_grade
¶The current gradient compensation grade.
detect_artifacts
(raw, start_find=None, stop_find=None, ecg_ch=None, ecg_score_func='pearsonr', ecg_criterion=0.1, eog_ch=None, eog_score_func='pearsonr', eog_criterion=0.1, skew_criterion=-1, kurt_criterion=-1, var_criterion=0, add_nodes=None)[source]¶Run ICA artifacts detection workflow.
Note. This is still experimental and will most likely change. Over the next releases. For maximum control use the workflow exposed in the examples.
Hints and caveats: - It is highly recommended to bandpass filter ECG and EOG data and pass them instead of the channel names as ecg_ch and eog_ch arguments. - please check your results. Detection by kurtosis and variance may be powerful but misclassification of brain signals as noise cannot be precluded. - Consider using shorter times for start_find and stop_find than for start and stop. It can save you much time.
Example invocation (taking advantage of the defaults):
ica.detect_artifacts(ecg_channel='MEG 1531', eog_channel='EOG 061')
Parameters: |
|
---|---|
Returns: |
|
find_bads_ecg
(inst, ch_name=None, threshold=None, start=None, stop=None, l_freq=8, h_freq=16, method='ctps', reject_by_annotation=True, verbose=None)[source]¶Detect ECG related components using correlation.
Note
If no ECG channel is available, routine attempts to create an artificial ECG based on cross-channel averaging.
Parameters: |
|
---|---|
Returns: |
|
See also
References
find_bads_eog
(inst, ch_name=None, threshold=3.0, start=None, stop=None, l_freq=1, h_freq=10, reject_by_annotation=True, verbose=None)[source]¶Detect EOG related components using correlation.
Detection is based on Pearson correlation between the filtered data and the filtered EOG channel. Thresholding is based on adaptive z-scoring. The above threshold components will be masked and the z-score will be recomputed until no supra-threshold component remains.
Parameters: |
|
---|---|
Returns: |
|
See also
fit
(inst, picks=None, start=None, stop=None, decim=None, reject=None, flat=None, tstep=2.0, reject_by_annotation=True, verbose=None)[source]¶Run the ICA decomposition on raw data.
Caveat! If supplying a noise covariance keep track of the projections available in the cov, the raw or the epochs object. For example, if you are interested in EOG or ECG artifacts, EOG and ECG projections should be temporally removed before fitting the ICA.
Parameters: |
|
---|---|
Returns: |
|
get_components
()[source]¶Get ICA topomap for components as numpy arrays.
Returns: |
|
---|
get_sources
(inst, add_channels=None, start=None, stop=None)[source]¶Estimate sources given the unmixing matrix.
This method will return the sources in the container format passed. Typical usecases:
Parameters: |
|
---|---|
Returns: |
|
plot_components
(picks=None, ch_type=None, res=64, layout=None, vmin=None, vmax=None, cmap='RdBu_r', sensors=True, colorbar=False, title=None, show=True, outlines='head', contours=6, image_interp='bilinear', head_pos=None, inst=None)[source]¶Project unmixing matrix on interpolated sensor topography.
Parameters: |
|
---|---|
Returns: |
|
Notes
When run in interactive mode, plot_ica_components
allows to reject
components by clicking on their title label. The state of each component
is indicated by its label color (gray: rejected; black: retained). It is
also possible to open component properties by clicking on the component
topomap (this option is only available when the inst
argument is
supplied).
plot_overlay
(inst, exclude=None, picks=None, start=None, stop=None, title=None, show=True)[source]¶Overlay of raw and cleaned signals given the unmixing matrix.
This method helps visualizing signal quality and artifact rejection.
Parameters: |
|
---|---|
Returns: |
|
plot_properties
(inst, picks=None, axes=None, dB=True, plot_std=True, topomap_args=None, image_args=None, psd_args=None, figsize=None, show=True)[source]¶Display component properties.
Properties include the topography, epochs image, ERP/ERF, power spectrum, and epoch variance.
Parameters: |
|
---|---|
Returns: |
|
Notes
New in version 0.13.
plot_scores
(scores, exclude=None, labels=None, axhline=None, title='ICA component scores', figsize=None, show=True)[source]¶Plot scores related to detected components.
Use this function to asses how well your score describes outlier sources and how well you were detecting them.
Parameters: |
|
---|---|
Returns: |
|
plot_sources
(inst, picks=None, exclude=None, start=None, stop=None, title=None, show=True, block=False, show_first_samp=False)[source]¶Plot estimated latent sources given the unmixing matrix.
Typical usecases:
Parameters: |
|
---|---|
Returns: |
|
Notes
For raw and epoch instances, it is possible to select components for
exclusion by clicking on the line. The selected components are added to
ica.exclude
on close.
New in version 0.10.0.
save
(fname)[source]¶Store ICA solution into a fiff file.
Parameters: |
|
---|
score_sources
(inst, target=None, score_func='pearsonr', start=None, stop=None, l_freq=None, h_freq=None, reject_by_annotation=True, verbose=None)[source]¶Assign score to components based on statistic or metric.
Parameters: |
|
---|---|
Returns: |
|