def main(): mne.utils.set_log_level('ERROR') layout = load_layout(MEG) print "Reading and processing data from files.." filenames = sys.argv[1:] new_components = [] for idx, fname in enumerate(filenames): print "Handling " + str(idx+1) + ". subject" raw = mne.io.read_raw_fif(fname, preload=True) picks = mne.pick_types(raw.info, eeg=True, meg=True) raw.drop_channels([ch_name for ix, ch_name in enumerate(raw.info['ch_names']) if ix not in picks]) raw.drop_channels(raw.info['bads']) fica = FourierICA(wsize=WSIZE, n_components=COMPONENTS, maxiter=7000, sfreq=raw.info['sfreq'], hpass=BAND[0], lpass=BAND[1]) fica.fit(raw._data) components = get_components(fica, raw.info, len(raw.times), layout) handle = plot_components(components, layout) input_ = int(raw_input("Which component to use: ")) if input_ == -1: continue new_components.append(components[input_ - 1]) import pdb; pdb.set_trace() print "kissa"
def main(): mne.utils.set_log_level('ERROR') if MEG: layout = None else: layout = load_layout() filenames = sys.argv[1:] components = [] for fname in filenames: print "Opening " + fname part = pickle.load(open(fname, "rb")) components.extend(part) plot_components(components, layout) import pdb; pdb.set_trace() print "kissa"
def main(): mne.utils.set_log_level('ERROR') layout = load_layout(MEG) filenames = sys.argv[1:] components = [] for fname in filenames: print "Opening " + fname part = pickle.load(open(fname, "rb")) components.extend(part) tses = [] for component in components: tses.append(_get_tse(component)) epochs = [] for i in range(len(components)): component_epochs = _get_epochs(components[i], tses[i]) # normalize for j, epoch in enumerate(component_epochs): component_epochs[j] = epoch / np.mean(tses[i]) epochs.extend(component_epochs) print "Total: " + str(len(epochs)) + " epochs." average = np.mean(epochs, axis=0) # smoothen? # average = np.convolve(average, np.ones((3,))/3, mode='valid') step = (LIMITS[0]+LIMITS[1]) / float(len(average)) times = np.array(range(len(average))) times = times * step - LIMITS[0] + step/2 plt.plot(times, average) plt.show()
# crop away eyes closed resting raws[0].crop(tmin=0, tmax=90) # drop bad and non-data channels 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.drop_channels(raw.info['bads']) raw = mne.concatenate_raws(raws) if MEG: layout = None else: layout = load_layout() wsize = 4096 sfreq = raw.info['sfreq'] states = [(0, 85), (95, len(raw.times)/sfreq)] # calculate fourier-ica fica = FourierICA(wsize=wsize, n_components=N_COMPONENTS, sfreq=sfreq, hpass=4, lpass=30, maxiter=7000) fica.fit(raw._data[:, raw.first_samp:raw.last_samp]) source_stft = fica.source_stft freqs = fica.freqs # plot components in sensor space on head topographies
mne.io.Raw(sys.argv[-1], preload=True, add_eeg_ref=False), ] for raw in raws: raw.add_proj([], remove_existing=True) # drop bad and non-data channels 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.drop_channels(raw.info['bads']) raw = mne.concatenate_raws(raws) layout = load_layout(MEG=True) wsize = 4096 sfreq = raw.info['sfreq'] states = [] events = mne.find_events(raw) # calculate fourier-ica fica = FourierICA(wsize=wsize, n_components=N_COMPONENTS, sfreq=sfreq, hpass=4, lpass=30, maxiter=7000) fica.fit(raw._data) source_stft = fica.source_stft