Filters#

Event filter nodes are the primary way of interacting with event streams in Samna. They are configured from Python and run in the C++ backend; enabling high performance while being easy to use.

Filter nodes#

Filter nodes come in three types

Source#

Source nodes can only produce events and only have an output. They are the beginning of any filter chain and typically attached to event producing device models. Source nodes can also be instantiated from Python and used to inject events into a filter chain periodically or on request.

Sink#

Sink nodes are the opposite of source nodes. They only consume events and terminate any filter chain. Sink nodes are found on device models where they send all consumed events to the device. They can also be instantiated in Python as buffer nodes that capture all consumed events and provide them when polled.

Filter#

A filter node has both an input and an output, it is effectively both a source and a sink. Filters work on collections of events and can perform any operation on the collection. Common operations include performing inference on network out, type conversion, splitting streams, forwarding to a network sink, and droppping events based on pattern matching.

Special nodes#

ZMQ streamers#

ZMQ source and sink nodes can be used to transmit events streams over a network. These nodes are used when connecting to the GUI, but can also be used to transmit events between any two instances of Samna.

ZMQ sink#

The ZMQ sink node can be connected as any sink to a filter chain. Any events consumed by the ZMQ sink will be broadcast on the TCP/IP address and port configured in the sink node.

ZMQ source#

The ZMQ source node can be connected as any source to a filter chain. It receives event streams on the TCP/IP addresses configured in the node and sources them on its output.

Devices nodes#

Device models contain a source node and a sink node. Events sent to the sink node will be sent to the device and events produced by the device will appear in the source node.

EventFilterGraph#

Filters can be composed in an EventFilterGraph to perform more complex operations. The EventFilterGraph is a directed acyclic graph of filter nodes.

Filter graph construction is done with the high level EventFilterGraph.sequential method, which adds all the nodes given as a list and connects them sequentially. The method returns a list of handles to the nodes added to the graph, which can be used to manipulate the nodes or for further connections.

Creating a node#

Nodes can be created either inside or outside a filter graph. When a node is created inside a filter graph, the graph will take care of evaluating the node filter function when the node receives input. If a node is created outside a filter graph then you must call the evaluation functions of the node yourself.

To add a node in a graph

[member_sel] = graph.sequential(["DynapcnnMemberSelect"])

To create a node outside a graph, instantiate the node directly. Subsequently the node can be connected to a filter graph using the sequential method.

sink = samna.BasicSinkNode_dynapcnn_event_output_event()
graph.sequential([member_sel, sink])
node.get_events() # get all the events accumulated in the buffer sink

Connecting nodes#

Nodes that are passed as a list to Grahp.sequential() are automatically connected.

graph = samna.graph.EventFilterGraph()
crop_node, decimate_node = graph.sequential(["DvsEventCrop", "DvsEventDecimate"])

EventFilterGraph also offers access to the low level connect method to connect nodes directly, which is used internally by the sequential method.

Branching and merging#

Branches are created by using a node already in the graph as the first node in a sequential call. Conversely merges are created by using an existing node as the last node in a sequential call.

graph = samna.graph.EventFilterGraph()
# Create first path
node1, node2_1, node3 = graph.sequential([speck2_source, "SpeckMemberSelect", sink_node])
# Create second path
_, node2_2, _ = graph.sequential([node1, "SpeckSpikeCount", node3])

Examples#

Instantiation a sink and reading from it in Python#

The BasicSinkNode that we saw earlier is a node that captures all events sent to it and accumulates them until read by calling the BasicSinkNode.get_events() function. Other nodes in the filter system will not retain the events passing through them, and the events being processed are not available for reading in Python unless the filtering system is explicity set up to stream the events to a BasicSinkNode.

Here is an example from earlier where we also poll the BasicSinkNode for new events.

graph = samna.graph.EventFilterGraph()
buffer_node = samna.BasicSinkNode_dynapcnn_event_output_event()
graph.sequential(["DynapcnnMemberSelect", buffer_node])

while true:
    new_events = buffer_node.get_events()
    do_something(new_events)

Streaming events#

One of the main features of the filtering system is the ability to stream across process and network boundaries. This can be achieved using the ZMQ receiver and streamer nodes. We use these nodes to connect event streams to the GUI for display.

# the visualizer contains a ZMQ receiver, we can open it with an endpoint
samnagui.run_visualizer("tcp://0.0.0.0:40000", 0.75, 0.75)

# Add a streamer node that streams visualization events to our graph
[streamer_node] = graph.sequential(["VizEventStreamer"])
# stream on the same endpoint as the receiver is listening to
streamer_node.set_streamer_endpoint("tcp://0.0.0.0:40000")

Now all events reaching the streamer_node will be transmitted and received by the receiving node in the GUI.

Filtering events with predicates#

Some filters allow for setting the predicates they will use to let events through or discard them. One of these filters is the MemberSelect which only you filter events based on a whitelisted set of parameters.

graph = samna.graph.EventFilterGraph()
[filter] = graph.sequential(["DynapcnnMemberSelect"])

filter.set_white_list([0,1,2], "layer") # only events from layers 0,1,2 will pass through

Available Filters#

In addition to the available filters listed below, users can define their own filters as described in JIT Filters. For filters that can be instantiated for different boards, the JIT built-in filters described here provide a convenient alternative.

class CameraToVizConverter#

Creates a filter node that pulls DVS events from camera and converts them to raw image events for visualization.

class DynapcnnDvsToVizConverter#

Creates a filter node that converts pulls DVS events from a DYNAP-CNN output event stream and converts them to raw image events for visualization.

class SpeckDvsToVizConverter#

Creates a filter node that converts pulls DVS events from a Speck output event stream and converts them to raw image events for visualization.

class Speck2DvsToVizConverter#

Creates a filter node that converts pulls DVS events from a Speck2 output event stream and converts them to raw image events for visualization.

class Dynapse1EventToVizConverter#

Creates a filter node that converts pulls DVS events from a Dynapse1 output event stream and converts them to raw image events for visualization.

class CameraToSpeckInput#

Creates a filter node that converts from event camera DvsEvent to Speck input events. The camera events will become Speck Spike events where the polarity is mapped to feature and x,y maps to x,y. The target layer will be the DVS pre-processing layer on Speck.

class CameraToSpeck2Input#

Creates a filter node that converts from event camera DvsEvent to Speck2 input events. The camera events will become Speck2 DVS events where the polarity is mapped to feature and x,y maps to x,y. The target layer will be the DVS pre-processing layer on Speck2.

class CameraToSpeck2bInput#

Creates a filter node that converts from event camera DvsEvent to Speck2b input events. The camera events will become Speck2b DVS events where the polarity is mapped to feature and x,y maps to x,y. The target layer will be the DVS pre-processing layer on Speck2b.

class CameraToSpeck2bMiniInput#

Creates a filter node that converts from event camera DvsEvent to Speck2bMini input events. The camera events will become Speck2bMini DVS events where the polarity is mapped to feature and x,y maps to x,y. The target layer will be the DVS pre-processing layer on Speck2bMini.

class CameraToSpeck2cMiniInput#

Creates a filter node that converts from event camera DvsEvent to Speck2cMini input events. The camera events will become Speck2cMini DVS events where the polarity is mapped to feature and x,y maps to x,y. The target layer will be the DVS pre-processing layer on Speck2cMini.

class CameraToSpeck2dMiniInput#

Creates a filter node that converts from event camera DvsEvent to Speck2dMini input events. The camera events will become Speck2dMini DVS events where the polarity is mapped to feature and x,y maps to x,y. The target layer will be the DVS pre-processing layer on Speck2dMini.

class CameraToSpeck2eInput#

Creates a filter node that converts from event camera DvsEvent to Speck2e input events. The camera events will become Speck2e DVS events where the polarity is mapped to feature and x,y maps to x,y. The target layer will be the DVS pre-processing layer on Speck2e.

class CameraToSpeck2etInput#

Creates a filter node that converts from event camera DvsEvent to Speck2et input events. The camera events will become Speck2et DVS events where the polarity is mapped to feature and x,y maps to x,y. The target layer will be the DVS pre-processing layer on Speck2et.

class CameraToSpeck2fInput#

Creates a filter node that converts from event camera DvsEvent to Speck2f input events. The camera events will become Speck2f DVS events where the polarity is mapped to feature and x,y maps to x,y. The target layer will be the DVS pre-processing layer on Speck2f.

class CameraToSpeck3Input#

Creates a filter node that converts from event camera DvsEvent to Speck3 input events. The camera events will become Speck3 DVS events where the polarity is mapped to feature and x,y maps to x,y. The target layer will be the DVS pre-processing layer on Speck3.

class CameraToDynapcnnInput#

Creates a filter node that converts from event camera DvsEvent to DYNAP-CNN input events. The camera events will become DYNAP-CNN Spike events where the polarity is mapped to feature and x,y maps to x,y. The target layer will be the DVS pre-processing layer on Dynapcnn.

class Davis346Center128ToDynapcnnInput#

Filter events in a specific area(a rectangle whose left top corner is [109, 65] and right bottom corner is [238, 194]) of davis346 camera input and transform events to dynapcnn input events.

class EventTypeFilter#

Pass or reject specific type of event from all types of event.

get_available_types()#
Returns:

a str list which contains all available names for event types, the first one is the variant type name.

set_desired_type(new_desired_type)#
Parameters:

new_desired_type (str) – the type name which indicates the event type to pass, only this type of events will pass the filter node.

get_desired_type()#
Returns:

the desired event type name.

set_rejected_type(new_rejected_type)#
Parameters:

new_rejected_type (str) – the type name which indicates the event type to reject, all other types of events will pass the filter node.

get_rejected_type()#
Returns:

the rejected event type name.

Available instances for different boards:

  • SpeckEventTypeFilter_InputEvents

  • SpeckEventTypeFilter_OutputEvents

  • Speck2bOutputEventTypeFilter

  • Speck2bInputEventTypeFilter

  • Speck2bMiniOutputEventTypeFilter

  • Speck2cMiniOutputEventTypeFilter

  • Speck2dMiniOutputEventTypeFilter

  • Speck2eOutputEventTypeFilter

  • Speck2fOutputEventTypeFilter

  • Speck3OutputEventTypeFilter

  • Speck2bMiniInputEventTypeFilter

  • Speck2dMiniInputEventTypeFilter

  • Speck2eInputEventTypeFilter

  • Speck2etInputEventTypeFilter

  • Speck2fInputEventTypeFilter

  • DynapcnnInputEventTypeFilter

  • DynapcnnOutputEventTypeFilter

  • DvsSynsInputEventTypeFilter

  • DvsSynsOutputEventTypeFilter

  • XyloImuOutputEventTypeFilter

  • Mc3632OutputEventTypeFilter

class EventCrop#

Creates a cropping filter for DVS type events. Events within the region of interested will be recentered in the output image space and forwarded. Events outside will be dropped.

set_roi(xtl, ytl, xbr, ybr)#

Set the region of interest that will be cropped out of the input image space. The region is defined using the top left and bottom right corners of a rectangle. The region of interest defines the output image space which spans x coordinates [xtl, xbr] and y coordinates [ytl, ybr].

Parameters:
  • xtl (int) – Top left x coordinate of the cropping rectangle.

  • ytl (int) – Top left y coordinate of the cropping rectangle.

  • xbr (int) – Bottom right x coordinate of the cropping rectangle.

  • ybr (int) – Bottom right y coordinate of the cropping rectangle.

Available instances for different boards:

  • DvsEventCrop

  • DvsSynsDvsEventCrop

  • Speck2eDvsEventCrop

  • Speck2eSpikeEventCrop

  • Speck2fDvsEventCrop

  • Speck2fSpikeEventCrop

  • Speck3DvsEventCrop

  • Speck3SpikeEventCrop

  • PostClusteringEventCrop

class DvsEventDecimate#

Creates a decimate filter for camera DVS events. The decimate filter uses the decimation fraction M/L to drop events in the stream.

A fraction of M/L will let through L out of M events.

Example: Let M/L be 10/1. Then 1 out of every 10 events will be let through.

Note: Only L=1 is currently supported.

set_decimation_fraction(M, L)#
Parameters:
  • M (int) – The nominator in the decimation fraction.

  • L (int) – The denominator in the decimation fraction.

class DvsEventRescale#

Creates a rescaling filter node for camera DVS events.

The rescale node scales the input image by width_coeff and height_coeff, in the way of width = width / width_coeff and height = height / height_coeff.

This filter does not perform interpolation and non integer scaling factors are therefore unlikely to work well as events will not be spaced evenly in the output image space.

set_rescaling_coefficients(width_coeff, height_coeff)#
Parameters:
  • width_coeff (float) – The coefficient to scale width.

  • height_coeff (float) – The coefficient to scale height.

class MemberSelect#

Creates a filter node that filters events with specific attribute values from all events.

As different types of event can have the same attribute name, in order for MemberSelect to filter on a single type of events, it is strongly suggested that events should be filtered by EventTypeFilter first before passing them to MemberSelect.

void setWhiteList(whiteList, attrName)
Parameters:
  • whiteList (List[int]) – Attribute values that are going to pass, events with other values will be discarded. Values should be of the same type of event member type, currently only two types are supported : int and string.

  • attrName (string) – The name of attribute in the event. e.g. if we are going to deal with layer attribute, we can use "layer".

Available instances for different boards:

  • SpeckMemberSelect

  • Speck2MemberSelect

  • Speck2bMemberSelect

  • Speck2bMiniOutputMemberSelect

  • Speck2bMiniInputMemberSelect

  • Speck2cMiniInputMemberSelect

  • Speck2cMiniOutputMemberSelect

  • Speck2dMiniInputMemberSelect

  • Speck2eInputMemberSelect

  • Speck2etInputMemberSelect

  • Speck2fInputMemberSelect

  • Speck2dMiniOutputMemberSelect

  • Speck2eOutputMemberSelect

  • Speck2fOutputMemberSelect

  • DvsSynsInputMemberSelect

  • DvsSynsOutputMemberSelect

  • DynapcnnMemberSelect

  • Speck3MemberSelect

class BackgroundNoiseRater#

Calculate event rate of dvs events and spikes, which is :

dvs and spike event count / (last timestamp - first timestamp)

get_result()#
Returns:

Get accumulated event rate since setup.

get_result_per_polarity()#
Returns:

Get event rate of two polarities since setup respectively.

get_raw_result()#
Returns:

Get event rate for each pixel, which is a two dimensional array of size (y scale, x scale).

get_raw_result_per_polarity()#
Returns:

Get event rate for each polarity and pixel, which is a three dimensional array of size (2, y scale, x scale).

setup(x, y)#
Parameters:
  • x (int) – The x scale to count.

  • x – The y scale to count.

Clear accumulated data and set x scale and y scale, all dvs event and spike with x coordinate within [0, x - 1] and y coordinate within [0, y - 1] will be taken into account.

reset()#

Setup again with previous x scale and y scale.

Available instances for different boards:

  • Speck2cMiniBackgroundNoiseRater

  • Speck2dMiniBackgroundNoiseRater

  • Speck2eBackgroundNoiseRater

  • Speck2fBackgroundNoiseRater

  • Speck3BackgroundNoiseRater

  • DvsSynsBackgroundNoiseRater

class Forward#

Do nothing but forward all events.

Available instances for different boards:

  • SpeckForward

  • Speck2bForward

  • Speck2bMiniForward

  • Speck2dMiniForward

  • Speck2eForward

  • Speck2fForward

  • DynapcnnForward

class DvsToVizConverter#

Creates a filter node that filters DVS events and Spike events from all output events.

Available instances for different boards:

  • SpeckDvsToVizConverter

  • Speck2DvsToVizConverter

  • Speck2bDvsToVizConverter

  • DynapcnnDvsToVizConverter

  • Speck2bMiniDvsToVizConverter

  • Speck2cMiniDvsToVizConverter

  • Speck2dMiniDvsToVizConverter

  • Speck2eDvsToVizConverter

  • Speck2fDvsToVizConverter

  • Speck3DvsToVizConverter

  • Dvs128DvsToVizConverter

  • DvsSynsDvsToVizConverter

class VizEventStreamer#

Creates a tcp sender node that sends raw image events for visualization.

set_streamer_endpoint(newEndpoint)#

Set the sending tcp endpoint which will be bound by the streamer.

get_connected_receiver_count()#
Returns:

Get receiver count connected to this streamer.

wait_for_receiver_count(count, timeout_milli_sec)#
Returns:

Actual receivers count after wait.

Wait for receivers count to be greater than or equal to a specific number

is_receiver_connected(receiver_id)#
Returns:

Whether specific receiver is connected.

class VizEventReceiver#

Creates a tcp receiver node that receives raw image events for visualization.

set_receiver_endpoint(endpoint)#

Set the receiving tcp endpoint which is used to connect streamer.

is_connected()#
Returns:

If current receiver is connected to a streamer or not.

wait_for_connect(timeout_milli_sec)#
Returns:

Connected or not.

Wait to be connected or timeout.

reconnect()#

Reconnect using previous endpoint.

get_id()#
Returns:

Get id string of this receiver.

class EventRescaleNode#

Rescale coordinate of dvs events from output of a camera.

set_rescaling_coefficients(widthCoeff, heightCoeff)#
Parameters:
  • widthCoeff (float) – Width coefficient to divide x coordinate.

  • heightCoeff (float) – Height coefficient to divide y coordinate.

reset()#

Reset width and height coefficient to 1.

class SpikeCollectionNode#

Pick spike events from output events and divide them into collections according to time intervals.

set_interval_milli_sec(interval)#
Parameters:

interval (int) – The time interval in milliseconds that we divide the spike events.

get_interval_milli_sec()#
Returns:

The time interval in milliseconds.

Available instances for different boards:

  • SpeckSpikeCollectionNode

  • Speck2SpikeCollectionNode

  • Speck2bSpikeCollectionNode

  • Speck2bMiniSpikeCollectionNode

  • Speck2cMiniSpikeCollectionNode

  • Speck2dMiniSpikeCollectionNode

  • Speck2eSpikeCollectionNode

  • Speck2fSpikeCollectionNode

  • DynapcnnSpikeCollectionNode

class SpikeCountNode#

Count spike events. it sums spike events in each collection grouping by feature value.

set_feature_count(feature_count)#
Parameters:

feature_count (int) – Feature value count. it should be set before this filter is applied. e.g. if 2 is set, then all feature value in spike events should be in [0, 1]

get_feature_count()#
Returns:

Feature value count.

Available instances for different boards:

  • SpeckSpikeCountNode

  • Speck2SpikeCountNode

  • Speck2bSpikeCountNode

  • DynapcnnSpikeCountNode

  • Speck2bMiniSpikeCountNode

  • Speck2cMiniSpikeCountNode

  • Speck2dMiniSpikeCountNode

  • Speck2eSpikeCountNode

  • Speck2fSpikeCountNode

class MajorityReadoutNode#

calc readout events from spike collections in specific way.

Available instances for different boards:

  • SpeckMajorityReadoutNode

  • Speck2MajorityReadoutNode

  • Speck2bMajorityReadoutNode

  • DynapcnnMajorityReadoutNode

  • Speck2bMiniMajorityReadoutNode

  • Speck2cMiniMajorityReadoutNode

  • Speck2dMiniMajorityReadoutNode

  • Speck2eMajorityReadoutNode

  • Speck2fMajorityReadoutNode

class CustomFilterNode#

A custom filter node that receive a callback(usually a python callback) to transform inside. Since it utilizes python function in C++, it will have some impact on the performance of the graph which should be fairly negligible from the user perspective when there are not so many events. However, using the CustomFilterNode implies performance penalties when a lot of events must be handled (like one million per second). For high performance applications the JIT filters are recommended.

There is a drawback of this filter: the stop method of this filter should be called manually before graph.stop() and program ends, if not called the program might deadlock on exit.

Please note that this node will be replaced by the JIT node in the future.

set_filter_function(filter_func)#
Parameters:

filter_func (function) – Set the python callback function that receives an array of input events and return an array of output events.

stop()#

It will stop the python callback from executing and should be called manually before graph.stop() and program ends.

Available instances for different boards:

  • SpeckCustomFilterNode

  • Speck2CustomFilterNode

  • Speck2bCustomFilterNode

  • DynapcnnCustomFilterNode

  • Speck2bMiniCustomFilterNode

  • Speck2cMiniCustomFilterNode

  • Speck2dMiniCustomFilterNode

  • Speck2eCustomFilterNode

  • Speck2fCustomFilterNode

class MeasurementToVizConverter#

A filter that transform power measurement events to viz events.

class DvsEventClusterFilterNode#

Spatial and temporal filter of events.

set_spatial_relation_threshold(threshold)#
Parameters:

threshold (int) – Threshold to determine if event is spatially related to the collected events.

set_spatial_distance_threshold(threshold)#
Parameters:

threshold (int) – Distance that determines if two events are spatially related.

set_black_noise_timeconstant(timeconstant)#
Parameters:

timeconstant (int) – Time in us that get suppressed by black noise filter.

set_black_noise_distance(distance)#
Parameters:

distance (int) – Distance of events to compare to determines black noise.

set_time_collected_events(time)#
Parameters:

time (int) – Maximum time in us events will be stored in the buffer.

get_collected_events()#
Returns:

The collected events.

get_collected_events_length()#
Returns:

Number of currently collected events.

reset()#

Clears the collected event buffer.

class DvsEventEfficientClusterFilterNode#

A more efficient implementation of the DvsEventClusterFilterNode.

set_spatial_relation_threshold(threshold)#
Parameters:

threshold (int) – Threshold to determine if event is spatially related to the collected events.

set_spatial_distance_threshold(threshold)#
Parameters:

threshold (int) – Distance that determines if two events are spatially related.

set_black_noise_timeconstant(timeconstant)#
Parameters:

timeconstant (int) – Time in us that get suppressed by black noise filter.

set_number_events_to_activate_black_noise_filter(count)#
Parameters:

count (int) – Number of events necessary to activate black noise filter.

set_maximum_collected_events(count)#
Parameters:

count (int) – Maximum number of events to process in the filter.

set_time_collected_events(time)#
Parameters:

time (int) – Maximum time in us events will be stored in the buffer.

get_collected_events()#
Returns:

The collected events.

get_collected_events_length()#
Returns:

Number of currently collected events.

reset()#

Clears the collected event buffer.

class ImageReconstructFilter#

The ImageReconstructFilter accumulates streams of events to reconstruct an image. The filter accepts both DVS or spike events as input and produces a samna.events.Frame event as output. The algorithm is an accumulator with exponential decay and is tunable with parameters. Events fed to the filter, must have a monotonically increasing time stamp. Out of order events are ignored.

reset()#

Resets the internal pixel potentials and timing state of the filter. Parameters changed through setters are not reset to their defaults.

set_filter_size(size_x, size_y)#
Parameters:
  • size_x (int) – Width of the filter resolution.

  • size_y (int) – Height of the filter resolution.

set_event_contribution(contribution)#
Parameters:

contribution (float) – Contribution amount of a single event.

set_decay_contribution(contribution)#
Parameters:

contribution (float) – Rate of decay.

set_potentials(min_potential, max_potential)#

Set the potential limits for the pixels. max_potential must be strictly greater than min_potential. Calling this method resets the internal state of the filter.

Parameters:
  • min_potential (float) – Minimum potential of a pixel.

  • max_potential (float) – Maximum potential of a pixel.

set_synchronous_decay(enable)#
Parameters:

enable (bool) – Enable synchronous decay when generating a frame.

set_frame_rate(limit)#
Parameters:

limit (int) – Maximum number of frames per second to generate.

Available instances for different boards:

  • dynapcnnBDvsImageReconstructFilter

  • Speck2DvsImageReconstructFilter

  • Speck2bDvsImageReconstructFilter

  • Speck2bMiniDvsImageReconstructFilter

  • Speck2cMiniDvsImageReconstructFilter

  • Speck2dMiniDvsImageReconstructFilter

  • Speck2eDvsImageReconstructFilter

  • Speck2fDvsImageReconstructFilter

  • Speck3DvsImageReconstructFilter

  • DvsEventImageReconstructFilter

class Dynapse1NeuronSelect#

Pass spikes of selected neurons from all received spikes.

set_neurons(neuron_ids)#

Select neurons to be monitored.

Parameters:

neuron_ids (list[tuple(int,int,int)]) – list of neuron ids (chip,core,neuron) of selected neurons to be monitored.

reset()#

Reset filter to pass all spikes.

class Dynapse1NeuronTrace#

Implementation of event-driven exponentially-decaying spiking traces of a list of monitored neurons, which can be used to implement STDP-like learning algorithms or to track the instantaneous firing rates.

The Dynapse1NeuronTrace node receives spikes, maintains the neuron traces of monitored neurons, and generates samna.dynapse1.Dynapse1Trace events whenever a trigger neuron fires. The neuron traces are updated as the following:

  • When a monitored neuron fires, its trace value will be increased according to

  • When the trigger neuron spikes, all traces of monitored neurons be decreased/decayed

exponentially from the last update point.

The monitored neurons, trigger neurons and time constants of the exponentially-decaying traces can be set using function set_neurons. Also, Dynapse1NeuronTrace has the following private attributes that affect the trace tracking which can be checked/configured by the get/set functions below.

method#

The way how the trace is increased when a monitor neuron spikes. Default value is “increase_by”.

  • “increase_by”: increase by a constant value.

  • “increase_to”: increase to a constant value.

Type:

string

increment#

The constant value of trace increase. Default value is 1.

Type:

float

value_only_at_trigger#

It’s “true” by default so that the filter node only generates samna.dynapse1.Dynapse1Trace event with traces of all monitored neurons only when a trigger neuron fires. If it’s “false”, when a monitored neurons fires, a samna.dynapse1.Dynapse1Trace event with only trace of that neuron will be generated additionally by the filter. It can be useful when you want to observe the detailed trajectory of the traces.

Type:

bool

value_before_spike#

It’s “true” by default so that when a monitored neuron spikes, the trace value before the increase will be stored, otherwise the trace value after increment will be captured. For STDP algorithms, “true” is needed for the traces.

Type:

bool

set_neurons(trace_map_neuron_ids, trigger_neuron_ids, tau_list)#

Select neurons to be monitored.

Parameters:

trace_map_neuron_ids (list[tuple(int,int,int)]) – list of neuron ids (chip,core,neuron)

of selected neurons to be monitored. :param list[tuple(int,int,int)] trigger_neuron_ids: list of neuron ids (chip,core,neuron) of selected neurons that trigger trace event generation. :param list[int] tau_list: list of time constants for traces of monitored neurons, in microsecond.

set_trace_parameters(method, increment)#

Change method and increment.

Parameters:
  • method (str) – string of increase method, can be “increase_by” or “increase_to”.

  • increment (float) – constant value of the trace increase.

set_tau_list(trace_neuron_ids, tau_list)#

Change trace time constants of some monitored neurons.

Parameters:

trace_neuron_ids (list[tuple(int,int,int)]) – list of neuron ids (chip,core,neuron)

of some monitored neurons. :param list[int] tau_list: list of time constants, in microsecond.

set_tau(tau)#

Set time constants for all neuron traces.

Parameters:

tau (int) – time constant, in microsecond.

set_value_only_at_trigger(value_only_at_trigger)#

Change value_only_at_trigger.

Parameters:

value_only_at_trigger (bool) – value_only_at_trigger.

set_value_before_spike()#

Change value_before_spike.

Parameters:

value_before_spike (bool) – value_before_spike.

get_tau_list(trace_neuron_ids)#

Get tau_list of trace_neuron_ids.

Parameters:

trace_neuron_ids (list[tuple(int,int,int)]) – list of monitored neuron ids in trace map.

Returns:

list[int]: tau_list of trace_neuron_ids.

get_method()#

Get method of trace increase.

Returns:

str: method.

get_increment()#

Get constant value of trace increase.

Returns:

float: increment.

get_value_only_at_trigger()#

Get value_only_at_trigger.

Returns:

bool: value_only_at_trigger.

get_value_before_spike()#

Get value_before_spike.

Returns:

bool: value_before_spike.

reset_traces_to_zero()#

Reset all traces values to 0.

reset()#

Clear out stored trace map, delete monitored neurons and trigger neurons lists. Reset the trace parameters (increment, method, value_only_at_trigger and value_before_spike) to default values.

Sinks#

BasicSinkNode_<T>

This filter is defined for T:

  • _dynapcnn_event_output_event

  • _camera_event_dvs_event

  • _speck2_event_output_event

  • _dynapse1_dynapse1_event

  • _dynapse1_dynapse1_trace

  • _pollen_event_output_event

A basic sink node that captures any output event from the DYNAP-CNN. Events received by the sink node will accumulate until they are read from the sink with one of its methods.

get_events()#

Clear the event accumulation buffer and return previously accumulated events.

Returns:

A list of DYNAP-CNN output events.

get_events_blocking(timeout)#

Performs the same function as get_events() in a blocking manner that waits for events to be available before returning.

Parameters:

timeout (int) – Time out period in milliseconds.

Returns:

A list of events or empty list if timeout is reached.

get_n_events(n, timeout)#

Tries to get n events from the buffer. If there are less than n events available after the time out period, the currently accumulated events are returned.

Parameters:
  • n (int) – Number of events to wait for.

  • timeout (int) – Time out period in milliseconds.

Returns:

A list with at most n events.