File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ def __init__(self):
14
14
self .setWindowTitle ("Real-Time EOG Monitor - Eye Blink Detection" )
15
15
self .setGeometry (100 , 100 , 800 , 400 )
16
16
17
+ self .stream_active = True # Flag to check if the stream is active
18
+ self .last_data_time = None # Variable to store the last data time
19
+
17
20
# Create layout
18
21
layout = QVBoxLayout ()
19
22
central_widget = QWidget ()
@@ -99,6 +102,7 @@ def __init__(self):
99
102
def update_plot (self ):
100
103
samples , _ = self .inlet .pull_chunk (timeout = 0.0 , max_samples = 30 )
101
104
if samples :
105
+ self .last_data_time = time .time () # Store the last data time
102
106
for sample in samples :
103
107
# Overwrite the oldest data point in the buffer
104
108
self .eog_data [self .current_index ] = sample [0 ]
@@ -132,6 +136,12 @@ def update_plot(self):
132
136
133
137
# Update the blink plot with the current blink data
134
138
self .blink_curve .setData (self .time_data , self .blink_data )
139
+ else :
140
+ if self .last_data_time and (time .time () - self .last_data_time ) > 2 :
141
+ self .stream_active = False
142
+ print ("LSL stream disconnected!" )
143
+ self .timer .stop ()
144
+ self .close ()
135
145
136
146
def detect_blinks (self , filtered_eog ):
137
147
mean_signal = np .mean (filtered_eog )
You can’t perform that action at this time.
0 commit comments