-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
executable file
·67 lines (47 loc) · 1.69 KB
/
client.py
File metadata and controls
executable file
·67 lines (47 loc) · 1.69 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
import socket
import os
import sys
import logging
from mne import Epochs, pick_types, events_from_annotations
from mne.datasets import eegbci
from mne.channels import make_standard_montage
from mne.io import concatenate_raws, read_raw_edf
def get_data(subject):
event_id = dict(T0=subject, T1=subject, T2=subject)
tmin, tmax = -1.0, 4.0
raw_fnames = eegbci.load_data(subject, [14])
raw = concatenate_raws([read_raw_edf(f, preload=True) for f in raw_fnames])
eegbci.standardize(raw)
montage = make_standard_montage('standard_1005')
raw.set_montage(montage)
raw.rename_channels(lambda x: x.strip('.'))
raw.filter(7.0, 30.0, fir_design='firwin', skip_by_annotation='edge')
events, _ = events_from_annotations(raw, event_id=event_id)
picks = pick_types(raw.info, meg=False, eeg=True, stim=False, eog=False,
exclude='bads')
epochs = Epochs(raw, events, event_id, tmin, tmax, proj=True, picks=picks,
baseline=None, preload=True)
labels = epochs.events[:, -1]
return epochs.get_data
def main():
if not os.getenv('SOCK_PATH'):
sock_path = '/tmp/eeg.sock'
else:
sock_path = os.getenv('SOCK_PATH')
user = input('Enter user ID for authentication: ')
# data = get_data(int(user))
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
sock.connect(sock_path)
except socket.error as err:
print('Error connecting to socket: {}'.format(err))
sys.exit(1)
try:
sock.sendall(bytes(user, 'utf-8'))
msg = sock.recv(4096)
print(msg.decode('utf-8'))
finally:
sock.close()
if __name__ == '__main__':
main()