forked from alexandrebarachant/muse-lsl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
muse-record.py
42 lines (31 loc) · 890 Bytes
/
muse-record.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
41
42
from muse import Muse
from time import sleep
import numpy as np
import pandas as pd
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-a", "--address",
dest="address", type='string', default="00:55:DA:B0:06:D6",
help="device mac adress.")
(options, args) = parser.parse_args()
full_time = []
full_data = []
def process(data, timestamps):
full_time.append(timestamps)
full_data.append(data)
muse = Muse(options.address, process)
muse.connect()
muse.start()
while 1:
try:
sleep(1)
except:
break
muse.stop()
muse.disconnect()
full_time = np.concatenate(full_time)
full_data = np.concatenate(full_data, 1).T
res = pd.DataFrame(data=full_data,
columns=['TP9', 'AF7', 'AF8', 'TP10', 'Right AUX'])
res['timestamps'] = full_time
res.to_csv('dump.csv', float_format='%.3f')