Skip to content

Commit 422c653

Browse files
committed
replace with pynput
and fix other type issues
1 parent f401f97 commit 422c653

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

eegnb/analysis/streaming_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from eegnb import _get_recording_dir
2626
from eegnb.devices.eeg import EEG
2727
#from eegnb.devices.utils import EEG_INDICES, SAMPLE_FREQS
28+
from eegnb.analysis.utils import thres_stds
2829

2930
# this should probably not be done here
3031
sns.set_context("talk")

eegnb/analysis/utils.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from eegnb import _get_recording_dir
2626
from eegnb.devices.eeg import EEG
2727
from eegnb.devices.utils import EEG_INDICES, SAMPLE_FREQS
28+
from pynput import keyboard
2829

2930
# this should probably not be done here
3031
sns.set_context("talk")
@@ -529,14 +530,22 @@ def check_report(eeg: EEG, n_times: int=60, pause_time=5, thres_std_low=None, th
529530
print(f"\n\nLooks like you still have {len(bad_channels)} bad channels after {loop_index+1} tries\n")
530531

531532
prompt_time = time()
532-
print(f"Starting next cycle in 5 seconds, press C and enter to cancel")
533+
print(f"Starting next cycle in 5 seconds, press C and enter to cancel")
534+
c_key_pressed = False
535+
536+
def update_key_press(key):
537+
if key.char == 'c':
538+
globals().update(c_key_pressed=True)
539+
listener = keyboard.Listener(on_press=update_key_press)
540+
listener.start()
533541
while time() < prompt_time + 5:
534-
if keyboard.is_pressed('c'):
542+
if c_key_pressed:
535543
print("\nStopping signal quality checks!")
536544
flag = True
537-
break
545+
break
546+
listener.stop()
538547
if flag:
539-
break
548+
break
540549

541550
def fix_musemissinglines(orig_f,new_f=''):
542551

eegnb/cli/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def runexp(
6363
eeg, experiment, recdur, outfname = intro_prompt()
6464
else:
6565
# Random values for outfile for now
66-
outfname = generate_save_fn(eegdevice, experiment,7, 7)
66+
outfname = str(generate_save_fn(str(eegdevice), experiment,7, 7))
6767
if eegdevice == "ganglion":
6868
# if the ganglion is chosen a MAC address should also be provided
6969
eeg = EEG(device=eegdevice, mac_addr=macaddr)

examples/visual_n170/02r__n170_decoding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
results = pd.DataFrame(data=auc, columns=['AUC'])
128128
results['Method'] = methods
129129

130-
fig = plt.figure(figsize=[8,4])
130+
fig = plt.figure(figsize=(8, 4))
131131
sns.barplot(data=results, x='AUC', y='Method')
132132
plt.xlim(0.4, 0.9)
133133
sns.despine()

examples/visual_p300/02r__p300_decoding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
results = pd.DataFrame(data=auc, columns=['AUC'])
119119
results['Method'] = methods
120120

121-
plt.figure(figsize=[8,4])
121+
plt.figure(figsize=(8, 4))
122122
sns.barplot(data=results, x='AUC', y='Method')
123123
plt.xlim(0.2, 0.85)
124124
sns.despine()

examples/visual_ssvep/02r__ssvep_decoding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
results = pd.DataFrame(data=auc, columns=['AUC'])
152152
results['Method'] = methods
153153

154-
fig = plt.figure(figsize=[8,4])
154+
fig = plt.figure(figsize=(8, 4))
155155
sns.barplot(data=results, x='AUC', y='Method')
156156
plt.xlim(0.4, 1)
157157
sns.despine()

0 commit comments

Comments
 (0)