Пример #1
0
                    events,
                    event_id,
                    tmin,
                    tmax,
                    proj=True,
                    picks=picks,
                    baseline=baseline,
                    preload=True,
                    reject=reject)

# fit sources from epochs or from raw (both works for epochs)
ica.decompose_epochs(epochs)

# plot components for one epoch of interest
# A distinct cardiac component should be visible
ica.plot_sources_epochs(epochs, epoch_idx=13, n_components=25)

###############################################################################
# Automatically find the ECG component using correlation with ECG signal

# As we don't have an ECG channel we use one that correlates a lot with heart
# beats: 'MEG 1531'. We can directly pass the name to the find_sources method.
# In our example, the find_sources method returns and array of correlation
# scores for each ICA source.

ecg_scores = ica.find_sources_epochs(epochs,
                                     target='MEG 1531',
                                     score_func='pearsonr')

# get maximum correlation index for ECG
ecg_source_idx = np.abs(ecg_scores).argmax()
Пример #2
0
tmin, tmax, event_id = -0.2, 0.5, 1
# baseline = None
baseline = (None, 0)
reject = None

events = mne.find_events(raw, stim_channel='STI 014')
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=True, picks=picks,
                    baseline=baseline, preload=True, reject=reject)


# fit sources from epochs or from raw (both works for epochs)
ica.decompose_epochs(epochs)

# plot components for one epoch of interest
# A distinct cardiac component should be visible
ica.plot_sources_epochs(epochs, epoch_idx=13, n_components=25)

###############################################################################
# Automatically find the ECG component using correlation with ECG signal

# As we don't have an ECG channel we use one that correlates a lot with heart
# beats: 'MEG 1531'. We can directly pass the name to the find_sources method.
# In our example, the find_sources method returns and array of correlation
# scores for each ICA source.

ecg_scores = ica.find_sources_epochs(epochs, target='MEG 1531',
                                     score_func='pearsonr')

# get maximum correlation index for ECG
ecg_source_idx = np.abs(ecg_scores).argmax()