def test_ICA(epochs): """ Test ICA fit, ICA choice comp and ICA apply """ ep = [epochs.epo1, epochs.epo2] icas = prep.ICA_fit(ep, n_components=15, method='fastica', random_state=97) # check that the number of componenents is similar between the two subjects for i in range(0, len(icas) - 1): mne.preprocessing.ICA.get_components( icas[i]).shape == mne.preprocessing.ICA.get_components( icas[i + 1]).shape
def test_ICA(epochs): """ Test ICA fit, ICA choice comp and ICA apply """ ep = [epochs.epo1, epochs.epo2] icas = prep.ICA_fit(ep, n_components=15, method='infomax', fit_params=dict(extended=True), random_state=97) # check that the number of componenents is similar between the two participants for i in range(0, len(icas) - 1): mne.preprocessing.ICA.get_components( icas[i]).shape == mne.preprocessing.ICA.get_components( icas[i + 1]).shape
# dedicate to hyperscanning, we need to equalize # the number of epochs between our two participants mne.epochs.equalize_epoch_counts([epo1, epo2]) # Preprocessing epochs # Warning: here we directly load epochs data, # for raw data we highly recommend to perform high-pass filtering # with prep.filt function before converting raw to epochs # Computing global AutoReject and Independant Components Analysis # for each participant icas = prep.ICA_fit( [epo1, epo2], n_components=15, method="infomax", fit_params=dict(extended=True), random_state=42, ) # Selecting relevant Independant Components for artefact rejection # on one participant, that will be transpose to the other participant # and fitting the ICA cleaned_epochs_ICA = prep.ICA_choice_comp(icas, [epo1, epo2]) plt.close("all") # Applying local AutoReject for each participant # rejecting bad epochs, rejecting or interpolating partially bad channels # removing the same bad channels and epochs across participants # plotting signal before and after (verbose=True) cleaned_epochs_AR, dic_AR = prep.AR_local(cleaned_epochs_ICA,