timeflux_bitalino.nodes.driver


driver

timeflux_bitalino.nodes.driver.TRANSFER
class timeflux_bitalino.nodes.driver.Bitalino(port, rate=1000, channels=('A1', 'A2', 'A3', 'A4', 'A5', 'A6'), sensors=None)[source]

Bases: timeflux.core.node.Node

BITalino driver.

This node connects to a BITalino device and streams data at a provided rate. It is based on the original BITalino Python library, with some performance improvements and careful timestamping.

Two output streams are provided. The default output is the data read from the analog and digital channels. The o_offsets output provides continuous offsets between the local time and the estimated device time. This enables drift correction to be performed during post-processing, although no significant drift has been observed during testing.

Variables
  • o (Port) – BITalino data, provides DataFrame.

  • o_offsets (Port) – Time offsets, provide DataFrame.

Parameters
  • port (string) – The serial port. e.g. COM3 on Windows; /dev/tty.bitalino-DevB on MacOS; /dev/ttyUSB0 on GNU/Linux.

  • rate (int) – The device rate in Hz. Possible values: 1, 10, 100, 1000. Default: 1000.

  • channels (tupple) – The analog channels to read from. Default: ('A1', 'A2', 'A3', 'A4', 'A5', 'A6').

  • sensors (dict) – The map of attached sensors. If set, transfer functions will be applied. e.g. {"A1": "ECG", "A3": "EMG"}. Default: None.

Example

graphs:

  - id: acquisition
    nodes:
    - id: bitalino
      module: timeflux_bitalino.nodes.driver
      class: Bitalino
      params:
        port: /dev/tty.BITalino-02-44-DevB
        rate: 1000
        sensors:
          A1: ECG
          A2: EEG
          A3: EDA
    - id: pub_bitalino
      module: timeflux.nodes.zmq
      class: Pub
      params:
        topic: bitalino
    - id: pub_offsets
      module: timeflux.nodes.zmq
      class: Pub
      params:
        topic: offsets
    edges:
    - source: bitalino
      target: pub_bitalino
    - source: bitalino:offsets
      target: pub_offsets
    rate: 30

  - id: display
    nodes:
    - id: subscribe
      module: timeflux.nodes.zmq
      class: Sub
      params:
        topics: [ bitalino, offsets ]
    - id: ui
      module: timeflux_ui.nodes.ui
      class: UI
    - id: debug
      module: timeflux.nodes.debug
      class: Display
    edges:
      - source: subscribe:bitalino
        target: ui:bitalino
      - source: subscribe:bitalino
        target: debug
    rate: 10

  # - id: record
  #   nodes:
  #   - id: sub
  #     module: timeflux.nodes.zmq
  #     class: Sub
  #     params:
  #       topics: [ bitalino, offsets ]
  #   - id: save
  #     module: timeflux.nodes.hdf5
  #     class: Save
  #   edges:
  #     - source: sub:bitalino
  #       target: save:bitalino
  #     - source: sub:offsets
  #       target: save:offsets
  #   rate: 1

  - id: broker
    nodes:
    - id: broker
      module: timeflux.nodes.zmq
      class: Broker

Notes:

Attention

Make sure to set your graph rate to an high-enough value, otherwise the device internal buffer may saturate, and data may be lost. A 30Hz graph rate is recommended for a 1000Hz device rate.

Instantiate the node.

update(self)[source]

Update the input and output ports.

terminate(self)[source]

Perform cleanup upon termination.