Tech Tip: Connecting Vizard to BIOPAC AcqKnowledge

May 26, 2020

Jeff Loomis

BIOPAC provides a large range of monitoring devices for detecting physical or physiological changes over time. The BIOPAC virtual reality platform provides:

  • Controlled and replicative experimental setups
  • Manipulation of the environment (and avatars) that would be impossible or prohibitively expensive in the real world
  • Synchronization of the events from the virtual world with physiological data
  • Biofeedback data transfer protocol for real-time digital communication, which allows the participant’s physiological feedback to control the VR world.

Using physical data with Vizard

Vizard supports interaction with the data provided from these devices using the biopacndt.py module, a Python API for connecting to BIOPAC’s AcqKnowledge software with Network Data Transfer (NDT)

Note: biopacndt.py is included with the NDT license; contact support@biopac.com if needed.

The connection to AcqKnowledge can be made locally or over the network. As long as the Respond to auto-discovery requests option is enabled in AcqKnowledge there is no need to specify a remote machine’s IP address in Vizard.

If you have AcqKnowledge installed, the biopacndt.py file is found in the following location: C:\Program Files\BIOPAC Systems, Inc\AcqKnowledge\Network Data Transfer Examples\Python 2\source Copy and paste the file to the Vizard Python folder: (C:\Program Files\WorldViz\Vizard\python). Placing files in the Vizard Python folder will ensure each Vizard project can load them.

Software setup in AcqKnowledge

Enable the NDT Network Data Transfer protocol in AcqKnowledge in order to stream data to and from Vizard. (NDT is a licensed feature add-on.)

  1. In AcqKnowledge, go to Display > Preferences > Networking
  2. Select the checkboxes for Enable network data transfer and Respond to auto-recovery requests.
  3. Restart the AcqKnowledge software to activate the Network Data Transfer.

This configuration only needs to be done once.

To see event markers in AcqKnowledge, have the events bar visible.

You can also toggle to show the “Event Palette” to see a timeline of events.

Vizard to AcqKnowledge

In the code below, Vizard sends a signal to drop an event marker in AcqKnowledge:


'''

Press A to toggle acquisition

Press spacebar to drop a marker

'''

import sys


import biopacndt 


import viz

import vizact

import vizinfo


# Connect to the AcqKnowledge server

try:

    acqServer = biopacndt.AcqNdtQuickConnect()

except biopacndt.ACQException:

    viz.log(viz.LOG_ERROR, 'Exiting application, no AcqKnowledge servers found')

    sys.exit()


viz.go()

vizinfo.InfoPanel()

viz.clearcolor(viz.SLATE)


#You can change the label “stimulus” to whatever you want the event to be labeled as

def insert_marker():

    acqServer.insertGlobalEvent('stimulus', '', '')


vizact.onkeydown(' ', insert_marker)

vizact.onkeydown('a', acqServer.toggleAcquisition)


AcqKnowledge to Vizard

In the following code, Vizard prints out the data streaming from AcqKnowledge:


'''

Press A to toggle acquisition

Press S to start the data server

Press D to stop the data server

The data server can only be started once

'''


import sys


import biopacndt


import viz

import vizact

import vizinfo


# Connect to the AcqKnowledge server.

try:

    acqServer = biopacndt.AcqNdtQuickConnect()

except biopacndt.ACQException:

    viz.log(viz.LOG_ERROR, 'Exiting application, no AcqKnowledge servers found')

    sys.exit()


# Change data connection method to single. The single data connection

# mode means that AcqKnowledge will make a single TCP network connection to

# deliver the data, all channels being delivered over that same connection.

if acqServer.getDataConnectionMethod() != 'single':

    acqServer.changeDataConnectionMethod('single')

    print('Data Connection Method Changed to: single')


def print_data(index, frame, channelsInSlice):

    print(index, frame)


enabledChannels = acqServer.DeliverAllEnabledChannels()

singleConnectPort = acqServer.getSingleConnectionModePort()

dataServer = biopacndt.AcqNdtDataServer(singleConnectPort, enabledChannels )

dataServer.RegisterCallback('print_data',print_data)


viz.go()

vizinfo.InfoPanel()

viz.clearcolor(viz.SLATE)


vizact.onkeydown('a', acqServer.toggleAcquisition)

vizact.onkeydown('s', dataServer.Start)

vizact.onkeydown('d', dataServer.Stop)



Stay Updated
Subscribe to our monthly Newsletter
CONTACT US 
Phone +1 (888) 841-3416
Fax +1 (866) 226-7529
813 Reddick St
Santa Barbara, CA 93103