<jupyter_start><jupyter_text>Read the epoches<jupyter_code>Tmin = 0
Tmax = 3.51
trial_len = 2
save_path = data_path + '/analysis/python/data/'+s+'-coh-epo-'+str(Tmin)+'-'+str(Tmax)+'-trialLen-'+str(trial_len)+'.fif'
EE = mne.read_epochs(save_path)

epochs = EE.copy()

epochs.drop_channels(extra_channels)
# for ferrara brainamp acticap
montage = mne.channels.read_montage('easycap-M1')
ch_names = montage.ch_names
remove_ch = ["Fpz", "Iz","F9", "F10", "P9", "P10", "O9", "O10", "AFz","FT9","FT10","TP9","TP10","PO9","PO10"]
a = np.nonzero(np.in1d(ch_names, remove_ch))[0]
ch_names = np.delete(ch_names,a)
montage = mne.channels.read_montage('easycap-M1',ch_names)
epochs.set_montage(montage)    
epochs.filter(4., 7., n_jobs=2, fir_design='firwin')
a = epochs.average().plot_joint()
epochs.crop(0.5,epochs.tmax)
# 1Hz high pass is often helpful for fitting ICA
epochs.filter(1., 40., n_jobs=2, fir_design='firwin')
n_components = 25  # if float, select n_components by explained variance of PCA
method = 'fastica'  # for comparison with EEGLAB try "extended-infomax" here
# we will also set state of the random number generator - ICA is a
# non-deterministic algorithm, but we want to have the same decomposition
# and the same order of components each time this tutorial is run
random_state = 23
ica = ICA(n_components=n_components, method=method, random_state=random_state)
a=ica.fit(epochs)
a=ica.plot_components()  # can you spot some potential bad guys?
# plot with bads
#epochs.filter(1., 40., n_jobs=2, fir_design='firwin')
#a= epochs.average().plot_joint()
ecg_inds, scores = ica.find_bads_ecg(epochs, method='ctps')

eog_inds =[3]
a=ica.plot_properties(epochs, picks=eog_inds,psd_args={'fmax': 35.})
a=ica.plot_sources(epochs)
icas = [mne.preprocessing.read_ica(fname) for fname in ica_fnames]
reference_ica = ica
reference_ica.plot_components()

icas = [reference_ica] + icas_from_other_data
template = (0, eog_inds[0])
fig_template, fig_detected = corrmap(icas, template=template, label="blinks",show=True, threshold=.8, ch_type='eeg')
eog_component = reference_ica.get_components()[:, eog_inds[0]]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15046728971962617, 'fraction_numerical': 0.024299065420560748, 'mean_word_length': 6.701438848920863, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '147452', 'license': 'Apache-2.0', 'n_tokens_mistral': 873, 'n_tokens_neox': 845, 'n_words': 175, 'path': 'preporcess_targetEpoches_beforeCoherence.ipynb', 'repo_name': 'sankar-mukherjee/entrainment_python', 'size': '2140'}