-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmuse-record.py
executable file
·46 lines (34 loc) · 1.03 KB
/
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
43
44
45
46
#Copyright (c) 2017, alexandre barachant
#All rights reserved.
#Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
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 address.")
(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')