-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
31 lines (23 loc) · 800 Bytes
/
main.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
import time
import mindwave
import pandas as pd
from datetime import datetime
headset = mindwave.Headset('COM6')
time.sleep(10)
# print headers
wave = headset.waves
keys = ['raw', 'attention', 'meditation'] + list(wave.keys())
print(''.join(f'{k:<14}' for k in keys))
starttime = time.time()
values = []
while True:
time.sleep(1/256 - ((time.time() - starttime) % (1/256)))
# print values
wave = headset.waves
values += [[datetime.now()] + [headset.raw_value, headset.attention, headset.meditation] + list(wave.values())]
print(''.join(f'{v:<14}' for v in values[-1]), end='\r')
# # save data every 10 lines
# if len(values) % 1024 == 0:
# df = pd.DataFrame(values)
# df.to_csv('raw.csv', mode='a', index=False, header=False)
# values = []