def main(to_file): layout_fname = "gsn_129.lout" layout_path = "/home/zairex/Code/cibr/materials/" layout = mne.channels.read_layout(layout_fname, layout_path) raw = cli_raws()[0] raw.filter(l_freq=1, h_freq=100) ica = mne.preprocessing.ICA(n_components=0.95, method="fastica") ica.fit(raw) sources = ica.get_sources(raw) # alter amplitudes to get better plot for source in sources._data: for idx, amplitude in enumerate(source): source[idx] = amplitude / 5000.0 ica.plot_components(layout=layout, show=False) sources.plot() indices = raw_input( "Please enter indices (starts from one) of " "ICA components to be zeroed out " "(separated with spaces, empty for none): " ) if indices: indices = map(int, indices.split(" ")) indices = [i - 1 for i in indices] # project out selected ica components ica.apply(raw, exclude=indices) raw.plot() to_be_saved = raw_input("Do you want to save (y, n)? ") if to_be_saved == "y": raw.save(to_file, overwrite=True)
import sys import mne import numpy as np import matplotlib.pyplot as plt import matplotlib.patches as patches from scipy.ndimage.filters import convolve from lib.load import cli_raws from lib.load import get_raw # get data raws = cli_raws() if not raws: raws = [get_raw('KH003', 'eoec'), get_raw('KH003', 'med')] for raw in raws: picks = mne.pick_types(raw.info, eeg=True, meg=True) raw.drop_channels([name for idx, name in enumerate(raw.info['ch_names']) if idx not in picks]) raw = raws[0] raw.append(raws[1:]) # set triggers triggers = [95000, 205000] # get threshold parameter args = sys.argv
import sys import numpy as np import matplotlib.pyplot as plt import mne from lib.load import cli_raws PLOTS = 6 raw = cli_raws()[0] raw.filter(l_freq=1, h_freq=100) ica = mne.preprocessing.ICA(n_components=0.9, method='fastica') ica.fit(raw) sources = ica.get_sources(raw) # alter amplitudes to get better plot for source in sources._data: for idx, amplitude in enumerate(source): source[idx] = amplitude / 5000.0 sources.plot() index = raw_input("Please enter index of blink channel: ") index = int(index) - 1