bad_sources = [17, 18, 19] X_filtered = smica.filter( raw._data[picks], bad_sources=bad_sources, method="wiener" ) raw_filtered = raw.copy() raw_filtered._data[picks] = X_filtered raw.filter(1, 70) ica = ICA_mne(n_components=20, method="fastica", random_state=0) ica.fit(raw, picks=picks) sources = ica.get_sources(raw).get_data() ica_mne = transfer_to_ica( raw, picks, freqs, ica.get_sources(raw).get_data(), ica.get_components() ) # ica_mne.plot_extended(sources, sort=False) bads_infomax = [0, 1, 2] X_ifmx = ica_mne.filter( raw._data[picks], bad_sources=bads_infomax, method="pinv" ) raw_ifmx = raw.copy() raw_ifmx._data[picks] = X_ifmx # We identify that clusters 6, 7, 8, 9 correspond to noise max_raw = raw.copy() max_raw = mne.preprocessing.maxwell_filter(max_raw) setups = [] setups.append({"raw": raw, "proj": False, "name": "Unfiltered"})
smica.fit(raw, picks=picks, verbose=100, tol=1e-10, em_it=100000) # Plot powers noise_sources = [6, 8, 9] muscle_source = [7] f, ax = plt.subplots(figsize=(4, 2)) plot_powers(smica.powers, noise_sources, muscle_source, ax, 'smica') plt.show() ica = ICA_mne(n_components=n_components, method='picard', random_state=0) ica.fit(raw, picks=picks) ica_mne = transfer_to_ica(raw, picks, freqs, ica.get_sources(raw).get_data(), ica.mixing_matrix_) noise_sources = [1, 2] muscle_source = [4] f, ax = plt.subplots(figsize=(4, 2)) plot_powers(ica_mne.powers, noise_sources, muscle_source, ax, 'infomax') plt.show() sobi = SOBI_mne(p=2000, n_components=n_components, freqs=freqs, rng=0) sobi.fit(raw, picks=picks, verbose=True, tol=1e-7, max_iter=10000) # Plot the powers noise_sources = [1, 8]