Module: network

Network input/output.

Includes nodes that can read packets from external network destinations or write packets to external network destinations. Nodes for different protocols (e.g., TCP, LSL, OSC) are included.

LSLInput

Receive data from the Lab Streaming Layer.

This node allows you to read a multi-channel stream from LSL (e.g., from an EEG device) in real time. In addition, this node can also read from a second stream that has event markers (for instance, from another application). Important: Note that the current version of this node does not dejitter the time stamps by itself, so if you do plotting or event- based processing, you must follow this node by a Dejitter Timestamps node to remove the jitter. The Lab Streaming Layer supports many different devices, such as EEG headsets, eye trackers, motion capture devices, audio, video, human-interface devices, and so on. With this node, you can read from any of these in a unified manner. On each tick of the NeuroPype scheduler, this node will output a packet that has all data from the given input stream(s) that came in since the last tick (which may be empty if there is no new data, and which may have a different length on each tick). Correspondingly, this node outputs either one or two streams depending on whether you include a marker stream. Check the below link for more information on LSL.

More Info...

Version 1.0.0

Ports/Properties

  • set_breakpoint
    Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

    • verbose name: Set Breakpoint (Debug Only)
    • default value: False
    • port type: BoolPort
    • value type: bool (can be None)
  • data
    Data received.

    • verbose name: Data
    • default value: None
    • port type: DataPort
    • value type: Packet (can be None)
    • data direction: OUT
  • query
    LSL query string that identifies the data stream to search for. The simplest form is type='Modality' where modality can be EEG, Audio, VideoRaw, Gaze, MoCap, Control, or any other type string. The inlet will connect to an LSL stream that has its type field set to this value (and if there are multiple matches, the most recently created one of them will be connected to). If you have multiple devices with the same type on the network (e.g., possibly including playback or other users), it is recommended to make the query less broad by using the stream name, as in name='BioSemi', or starts-with(name,'BioSemi') for any stream starting with a given string (in which case you might also need to specify type='EEG' if there is a marker stream that starts with the same string. (Use Tools/LSL Streams in the Pipeline Designer to show current streams.) It is also possible to include the hostname using the 'and' keyword, as in: type='EEG' and hostname='MyLaptop1'. Other rarely-used fields include channel_count, nominal_srate, and source_id. The syntax is that of an XPath predicate, and supports many other features.

    • verbose name: Query
    • default value: type='EEG'
    • port type: StringPort
    • value type: str (can be None)
  • marker_query
    LSL query string to find a marker stream. If non-empty, this node will try to connect to a marker stream in addition to the data stream, and once connected, the packets returned by this node will have both streams in them. The basic marker query is: type='Markers'. If there are multiple matching streams, the most recently created one of them will be connected to, but you can make it less broad by including the name of your marker stream in the query, as in: type='Markers' and name='SNAP-Markers'. You can also include the hostname if there are other machines with streams with the same name on the network (see help for the 'query' parameter for additional information on advanced syntax).

    • verbose name: Marker Query
    • default value:
    • port type: StringPort
    • value type: str (can be None)
  • max_buflen
    Maximum amount of data to buffer. In seconds. If more data than this remains in flight between the sender and receiver (e.g., because the network cable was unplugged, or your app was paused and stopped picking up data), then you will lose some data samples. In all other cases, the data sent will be delivered in order without omissions.

    • verbose name: Maximum Buffer Length
    • default value: 30
    • port type: IntPort
    • value type: int (can be None)
  • max_chunklen
    Desired chunk length for transmission. In samples. This allows to override the preferred chunk size that the sender should send over the wire (if 0, the sender's preferred chunk size is used). Setting this does not guarantee that the returned packets will have this size, but it can be used as a hint to optimize transmission size, e.g., to tune network latency and overhead.

    • verbose name: Desired Chunk Length
    • default value: 0
    • port type: IntPort
    • value type: int (can be None)
  • max_blocklen
    Maximum packet size emitted by node. This setting allows to return the data buffered in the LSL node in packets no larger than this size (in samples). This is mostly for internal performance optimization, but can also be used to keep subsequent nodes from stalling when a long packet would be received after a pause (instead, the graph will progressively process the accumulated buffer and remain responsive).

    • verbose name: Maximum Output Packet Size
    • default value: 1024
    • port type: IntPort
    • value type: int (can be None)
  • recover
    Recover lost streams. Whether to attempt silent recovery of a lost LSL stream. There is usually no need to disable this feature.

    • verbose name: Recover Lost Streams
    • default value: True
    • port type: BoolPort
    • value type: bool (can be None)
  • channel_names
    Override channel labels. If a list is provided, the channel labels of the data stream will be overridden accordingly.

    • verbose name: Override Channel Labels
    • default value: []
    • port type: ListPort
    • value type: list (can be None)
  • nominal_rate
    Override sampling rate. If set, the nominal sampling rate of the packets emitted by this node will be set to this value.

    • verbose name: Override Sampling Rate
    • default value: None
    • port type: FloatPort
    • value type: float (can be None)
  • diagnostics
    Enable diagnostics. Can be used to monitor what kinds of data is being received from LSL, for debugging purposes.

    • verbose name: Enable Diagnostics
    • default value: False
    • port type: BoolPort
    • value type: bool (can be None)
  • resolve_minimum_time
    Network scanning time to discover duplicate streams. If more than one stream is on the LSL network that matches the given query, this node will connect to the most recently created one of them. In order to ensure that all streams on the network have been discovered and none has been missed, the node will wait for at least this amount of time (in seconds).

    • verbose name: Network Scanning Time
    • default value: 0.5
    • port type: FloatPort
    • value type: float (can be None)

LSLOutput

Stream data out via the Lab Streaming Layer.

This node will stream the incoming data out over the LSL network, so that other programs or computers can pick up the data stream. LSL is an easy-to-use way to make time-series data available on the network, and is usable from a wide range of prgramming languages and operating systems. Important: keep in mind that the streams that you are sending to LSL will remain visible until you reset the graph, so when you are using LSL Inlets to acquire data, remember that you may still have streams on the network that are easily confused with real device streams (e.g., when you use broad queries such as type='EEG'). When using this node it is worth noting that, in LSL, all data is a multi-channel time series; if your packets have additional axes, like frequency, feature, and so on, these will be automatically vectorized into a flat list of channels. Also, if you send data with multiple instances into this node, subsequent instances will be concatenated along time, so the data seen by receiveers will appear continuous and non-segmented (channels by samples). Check out the below link for more information on LSL.

More Info...

Version 1.0.0

Ports/Properties

  • set_breakpoint
    Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

    • verbose name: Set Breakpoint (Debug Only)
    • default value: False
    • port type: BoolPort
    • value type: bool (can be None)
  • data
    Data to send.

    • verbose name: Data
    • default value: None
    • port type: DataPort
    • value type: Packet (can be None)
    • data direction: IN
  • stream_name
    Name of output data stream on LSL. Data will be published on LSL under this stream name.

    • verbose name: Stream Name
    • default value: OutStream
    • port type: StringPort
    • value type: str (can be None)
  • stream_type
    Type of output data stream. The LSL data stream will have this content-type. For control signals, the content type is usually Control. For raw data, content-types such as EEG, Gaze, Audio, VideoRaw, MoCap, etc. are commonly used. See also LSL documentation on content types for more info.

    • verbose name: Stream Type
    • default value: Control
    • port type: StringPort
    • value type: str (can be None)
  • source_id
    Unique data source identifier. If you assign this, then data receivers will be able to auto-recover your stream if you stop and restart your sender pipeline under the same ID. It is highly recommended to set this.

    • verbose name: Source Id
    • default value:
    • port type: StringPort
    • value type: str (can be None)
  • send_markers
    Send markers. This will open a second output stream on LSL that transmits marker contents (if a marker chunk is present in your data), with content-type Markers.

    • verbose name: Send Markers
    • default value: False
    • port type: BoolPort
    • value type: bool (can be None)
  • marker_name
    Name of the marker stream on LSL. Marker data will be published in LSL under this stream name.

    • verbose name: Marker Stream Name
    • default value: OutStream-markers
    • port type: StringPort
    • value type: str (can be None)
  • marker_source_id
    Unique data source identifier. If you assign this, then data receivers will be able to auto-recover your stream if you stop and restart your sender pipeline under the same ID. It is highly recommended to set this.

    • verbose name: Marker Source Id
    • default value:
    • port type: StringPort
    • value type: str (can be None)
  • srate
    Override sampling rate. Allows you to override the nominal sampling rate of your stream. Usually the sampling rate will be correct, but e..g, if you collapse the data down to only one sample per tick (e.g., machine learning predictions), your sampling rate will equal NeuroPype's tick rate (25Hz by default).

    • verbose name: Override Sampling Rate
    • default value: None
    • port type: FloatPort
    • value type: float (can be None)
  • chunk_len
    Preferred output chunk length. This is the preferred length of chunks sent over the network, in samples. If set to 0, the same chunk length that goes into the node will be used.

    • verbose name: Preferred Chunk Length
    • default value: 0
    • port type: IntPort
    • value type: int (can be None)
  • max_buffered
    Maximum output buffer length. The maximum amount of data that is buffered for network transmission, in seconds. If your connection is interrupted for longer than this, your receiver will lose some data. However, excessively long buffers provide little value for real-time processing, where it is of no use to receive outdated data (and can hurt if the recipient has to process all these data).

    • verbose name: Max Output Buffer
    • default value: 60
    • port type: IntPort
    • value type: int (can be None)
  • use_numpy_optimization
    Use Numpy optimization in pylsl. You need a version of pylsl that supports this.

    • verbose name: Use Numpy Optimization
    • default value: False
    • port type: BoolPort
    • value type: bool (can be None)
  • use_data_timestamps
    Use timestamps in data. This requires that the timestamps originally stem from some LSL clock (e.g., LSLInput node).

    • verbose name: Use Data Timestamps
    • default value: True
    • port type: BoolPort
    • value type: bool (can be None)
  • reset_if_labels_changed
    Reset the outlet if the channel labels changed. If labels change in rapid succession, this can stall downstream inlets until the changes are complete.

    • verbose name: Reset If Labels Changed
    • default value: False
    • port type: BoolPort
    • value type: bool (can be None)
  • ignore_signal_changed
    Do not reset outlet in case of a signal-changed notification. Since resetting the outlet causes a hitch in downstream processing, this option allows not resetting the outlet when details of the preceding graph are changed. Note that this can cause crashes (e.g., if the channel count changes), but it will work in case of only changes to the signal content.

    • verbose name: Ignore Signal Changed
    • default value: False
    • port type: BoolPort
    • value type: bool (can be None)

OSCOutput

Send data stream to a remote OSC receiver.

This node sends numeric data out as a multi-channel stream, using OSC over a UDP transport. Note that due to the nature of UDP, it is possible to lose data packets. If your packets have additional axes, like frequency, feature, and so on, these will be automatically vectorized into a flat list of channels. Also, if you send data with multiple instances into this node, subsequent instances will be concatenated along time, so the data seen by receivers will appear continuous and non-segmented (channels by samples).

More Info...

Version 1.0.0

Ports/Properties

  • set_breakpoint
    Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

    • verbose name: Set Breakpoint (Debug Only)
    • default value: False
    • port type: BoolPort
    • value type: bool (can be None)
  • data
    Data to send.

    • verbose name: Data
    • default value: None
    • port type: DataPort
    • value type: Packet (can be None)
    • data direction: IN
  • destination_host
    Hostname or IP address of the data receiver. Using 127.0.0.1 here will be the local machine.

    • verbose name: Receiver Hostname Or Ip
    • default value: 127.0.0.1
    • port type: StringPort
    • value type: str (can be None)
  • destination_port
    UDP port at which the data receiver is listening for connections.

    • verbose name: Receiver Port
    • default value: 9001
    • port type: IntPort
    • value type: int (can be None)
  • message_address
    Address to use for the messages. This is the OSC address under which messages will be sent.

    • verbose name: Message Address
    • default value: /data
    • port type: StringPort
    • value type: str (can be None)

TCPInput

Receive data stream from inbound TCP connection.

This node receives numeric data as a multi-channel stream in an easy-to-parse text format, with customizable value and sample separators. This node acts as a TCP server and will listen for connections from a remote TCP client.

More Info...

Version 1.0.0

Ports/Properties

  • set_breakpoint
    Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

    • verbose name: Set Breakpoint (Debug Only)
    • default value: False
    • port type: BoolPort
    • value type: bool (can be None)
  • data
    Data received.

    • verbose name: Data
    • default value: None
    • port type: DataPort
    • value type: Packet (can be None)
    • data direction: OUT
  • listen_port
    TCP port number on which this receiver is listening for connections.

    • verbose name: Listen Port
    • default value: 57318
    • port type: IntPort
    • value type: int (can be None)
  • channel_separator
    Separating character or string that delimits individual channel values. The output will be a character stream where channel values are separated by this character.

    • verbose name: Channel Separator
    • default value: ,
    • port type: StringPort
    • value type: str (can be None)
  • sample_separator
    Separating character or string that delimits multi-channel samples. The output will be a character stream where channel values are separated by this character.

    • verbose name: Sample Separator
    • default value:

    • port type: StringPort

    • value type: str (can be None)
  • sampling_rate
    Nominal sampling rate of the data stream.

    • verbose name: Sampling Rate
    • default value: 125
    • port type: IntPort
    • value type: int (can be None)

TCPOutput

Output data via TCP.

This node can act either as a TCP client or a TCP server. Supports various kinds of message encodings and encoded content.

More Info...

Version 2.0.0

Ports/Properties

  • set_breakpoint
    Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

    • verbose name: Set Breakpoint (Debug Only)
    • default value: False
    • port type: BoolPort
    • value type: bool (can be None)
  • data
    Data to send.

    • verbose name: Data
    • default value: None
    • port type: DataPort
    • value type: Packet (can be None)
    • data direction: IN
  • role
    Connection role. If set to client, then this node will actively connect to the given host/port where the other process is expected to be listening. If set to server, then this node will bind on the given port and IP address and listen for incoming connections.

    • verbose name: Client/server Role
    • default value: client
    • port type: EnumPort
    • value type: object (can be None)
  • host
    Hostname or IP address to use. In client mode, this identifies host to which to connect (e.g., 127.0.0.1 for local machine). In server mode, this node will bind on this IP address, which restricts from where incoming connections are accepted (127.0.0.1 restricts to connections from the same machine, and 0.0.0.0 allows incoming connections from anywhere).

    • verbose name: Tcp Hostname/ip
    • default value: 127.0.0.1
    • port type: StringPort
    • value type: str (can be None)
  • port
    TCP port to use. In client mode, this will connect to a (possibly remote) service listening on this port. In server mode, this node will itself listen on this port for connections.

    • verbose name: Tcp Port
    • default value: 57318
    • port type: IntPort
    • value type: int (can be None)
  • encoding
    Encoding format to use. CSV is the simplest one but only supports a flat 1d array per message. The other formats are fully general. JSON is human-readable, universally supported, and easy to parse, msgpack is binary and quite efficient (also commonly supported), yaml is human-readable and quite commonly supported, and pickle is binary and quite python-specific

    • verbose name: Message Encoding
    • default value: csv
    • port type: EnumPort
    • value type: object (can be None)
  • content
    Data content to transmit per message. The sample is the simplest one and contains just an array of channel values. Sample+ts includes the time-stamp as the last value. Ndarray is the n-way array for a given block. This only supports a single applicable stream in the data. Block is that plus axis descriptions. Chunk is a block plus meta-data. Packet is a dictionary/mapping of multiple named chunks.

    • verbose name: Content To Send
    • default value: sample
    • port type: EnumPort
    • value type: object (can be None)
  • subset
    Subset of chunks to consider for transmission.

    • verbose name: Stream Subset To Send
    • default value: both
    • port type: EnumPort
    • value type: object (can be None)