-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreprocess.py
40 lines (34 loc) · 1.07 KB
/
preprocess.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import mne
import numpy as np
import matplotlib.pyplot as plt
%matplotlib qt
rawEEG = mne.io.read_raw_edf('EDF_EEG.edf', preload=True)
rawEEG.plot(block=False, duration=10.0, title='raw EEG data')
rawEEG.info
print(rawEEG.info['sfreq'])
print(rawEEG.info['nchan'])
print(rawEEG.info['ch_names'])
"""Filtering"""
rawEEG.filter(0.1, 30)
rawEEG.plot(block=False, duration=10.0, title='filtered EEG data')
EEGfiltered = rawEEG.copy().filter(0.1, 40)
EEGfiltered.save('EEGfiltered.fif')
"""Creating a standard EEG montage"""
montage = mne.channels.make_standard_montage('standard_1020')
rawEEG, montage(montage)
rawEEG.plot()
"""Importing necessary function for ICA"""
from mne.preprocessing import ICA
"""Creating ICA components"""
ICAComponents = ICA(15)
"""Fitting the data and plotting the components"""
ICAComponents.fit(raw_EEG)
ICAComponents.plot_components()
"""Excluding artifact components"""
ICAComponents.exclude = [1,2]
rawEEG_ICA = ICAComponents.apply(rawEEG)