Skip to content

Commit b675be7

Browse files
committed
separate notch filter from general workflow
1 parent 5d393bc commit b675be7

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/explorepy/stream_processor.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def __init__(self, debug=False):
7878
self.reset_timer()
7979
self.packet_count = 0
8080
self.progress = 0
81+
self._notch_filter = None
8182

8283
def subscribe(self, callback, topic):
8384
"""Subscribe a function to a topic
@@ -312,13 +313,17 @@ def process(self, packet):
312313
self.last_exg_packet_timestamp = get_local_time()
313314
missing_timestamps = self.fill_missing_packet(packet)
314315
self._update_last_time_point(packet, received_time)
315-
self.dispatch(topic=TOPICS.raw_ExG, packet=packet)
316+
316317
self.packet_count += 1
317318
if self._is_imp_mode and self.imp_calculator:
318319
packet_imp = self.imp_calculator.measure_imp(
319320
packet=copy.deepcopy(packet))
320321
if packet_imp is not None:
321322
self.dispatch(topic=TOPICS.imp, packet=packet_imp)
323+
324+
self.dispatch(topic=TOPICS.raw_ExG, packet=self._notch_filter.apply(packet=packet, in_place=False))
325+
else:
326+
self.dispatch(topic=TOPICS.raw_ExG, packet=packet)
322327
try:
323328
self.apply_filters(packet=packet)
324329
except ValueError as error:
@@ -583,3 +588,11 @@ def fill_missing_packet(self, packet):
583588
timestamps = np.linspace(self._last_packet_timestamp + sps,
584589
packet.timestamp, num=missing_samples, endpoint=True)
585590
return timestamps[:-1]
591+
592+
def _add_notch_filter(self):
593+
self._notch_filter = ExGFilter(
594+
cutoff_freq=(61, 64),
595+
filter_type='notch_imp',
596+
s_rate=250,
597+
n_chan=SettingsManager(self.device_info['device_name']).get_channel_count()
598+
)

0 commit comments

Comments
 (0)