-
Notifications
You must be signed in to change notification settings - Fork 2
/
get_data.py
39 lines (33 loc) · 1.34 KB
/
get_data.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
from pylsl import StreamInlet, resolve_stream # first resolve an EEG # stream on the lab network
from time import localtime, time
class lsl_control:
def __init__(self):
self.state = False
self.timelist = []
self.time = 0
self.data = 0
# 측정 종료
def stop_getting_lsl(self):
self.state = False
# 측정 다 했으면 전체 lsl data 리턴하기
return self.timelist
# 측정 시작
def start_getting_lsl(self):
self.state = True
print("looking for an EEG stream...")
streams = resolve_stream('type', 'EEG') # create a new inlet to read # from the stream
inlet = StreamInlet(streams[0])
# 다시 측정할 때 timelist 초기화
self.timelist = []
# state가 True일 때, 계속해서 뇌파 데이터 얻기 (state가 False일 때, 중단)
while self.state:
# get a new sample (you can also omit the timestamp part if you're not interested in it)
sample, timestamp = inlet.pull_sample()
##########################################################################
# 나중에 예은이한테 받은 정제한 데이터(집중도 데이터)를 self.data에 집어넣기
self.data = sample[1]
timezone = 60*60*9
self.time = (time()+timezone) * 1000
self.timelist.append((self.time, self.data))
inlet.close_stream()
return True