-
Notifications
You must be signed in to change notification settings - Fork 0
/
sorter_node_paper2.py
62 lines (52 loc) · 2.62 KB
/
sorter_node_paper2.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from pyneurode.processor_node.GUIProcessor import GUIProcessor
from pyneurode.processor_node.Processor import *
from pyneurode.processor_node.ProcessorContext import ProcessorContext
from pyneurode.processor_node.FileReaderSource import FileReaderSource
from pyneurode.processor_node.SpikeSortProcessor import SpikeSortProcessor
from pyneurode.processor_node.SyncDataProcessor import SyncDataProcessor
import pyneurode as dc
import logging
import dearpygui.dearpygui as dpg
from pyneurode.processor_node.AnalogVisualizer import *
from pyneurode.processor_node.SpikeClusterVisualizer import SpikeClusterVisualizer
from pyneurode.processor_node.LatencyVisualizer import LatencyVisualizer
from pyneurode.processor_node.ZmqSource import ZmqSource
'''
GUI design architecture:
have one single GUI node in the main thread where all the others can connect to
- Different windows will be shown for different message type
- Provide different common visualization for common types
- Need to provide a mechanism to link the message to the visualization type
- provide a easy to use interface to build new visualization plugin
'''
if __name__ == '__main__':
# Create a context object that manages some global states
with ProcessorContext() as ctx:
# Initialize the processors we need
zmqSource = ZmqSource(adc_channel=20)
spikeSortProcessor = SpikeSortProcessor(interval=0.001,
min_num_spikes=2000)
syncDataProcessor = SyncDataProcessor(interval=0.02)
gui = GUIProcessor()
# Connect the processors to each others. The filters
# specify what type of messages are sent through that connection
zmqSource.connect(spikeSortProcessor, filters='spike')
spikeSortProcessor.connect(syncDataProcessor)
zmqSource.connect(syncDataProcessor, 'adc_data')
# Connect to the GUI processors so that messages can
# be visualized
zmqSource.connect(gui, 'adc_data')
syncDataProcessor.connect(gui)
spikeSortProcessor.connect(gui, ['df_sort','metrics'])
# Initialize the set of visualizers
analog_vis = AnalogVisualizer('Synchronized signals',
scale=20, buffer_length=1000)
cluster_vis = SpikeClusterVisualizer('cluster_vis')
# Register the visualizers to the GUI processor
gui.register_visualizer(analog_vis,filters=['synced_data'])
gui.register_visualizer(cluster_vis, filters=['df_sort'])
# Register all the processors to the context
ctx.register_processors(zmqSource, spikeSortProcessor,
syncDataProcessor,gui)
# Start all processors
ctx.start()