See how physiological data streaming in from BIOPAC acqknowledge can control an object in the scene. In this case a ball will change in size and color based on the physiological signal. You may need to adjust the position of the ball down if using 360 media.
importvizshape,vizinfo,viztaskimportsightlab_utils.sightlabasslfromsightlab_utilsimportbiopacndtfromsightlab_utils.settingsimport*# Initialize SightLab with Biopac enabledsightlab=sl.SightLab(biopac=True)sightlab.setTrialCount(1)# Load objectball=vizshape.addSphere(radius=0.2)ball.setScale(1.2,1.2,1.2)ball.alpha(0.5)ball.color(viz.BLUE)ball.setPosition(0,1.5,2)sightlab.addSceneObject('ball',ball)# Biopac configurationBUFFER_LENGTH=2allchannels=[]defoutputToScreen(index,frame,channelsInSlice):globalallchannelsfori,valueinenumerate(frame):rounded_value=round(value,4)# Round to 4 decimal places# Append value to bufferallchannels[i].append(rounded_value)iflen(allchannels[i])>BUFFER_LENGTH:allchannels[i].pop(0)# Log to custom trial datasightlab.setCustomTrialData(str(rounded_value),f"Channel_{i}")# Update ball position or colormove=(value-0.5)*0.5# Adjust scaling as needednew_y=1.5+moveball.setPosition(0,new_y,2)ifnew_y>1.4:ball.color(viz.GREEN)elifnew_y<1.0:ball.color(viz.RED)else:ball.color(viz.BLUE)# Biopac server setupacqServer=biopacndt.AcqNdtQuickConnect()enabledChannels=acqServer.DeliverAllEnabledChannels()dataServer=biopacndt.AcqNdtDataServer(acqServer.getSingleConnectionModePort(),enabledChannels)dataServer.RegisterCallback("OutputToScreen",outputToScreen)# Initialize data buffersfor_inenabledChannels:allchannels.append([0]*BUFFER_LENGTH)# Declare dataServer as a global variabledataServer=None# Experiment functiondefsightLabExperiment():globaldataServeryieldviztask.waitEvent(EXPERIMENT_START)foriinrange(0,sightlab.getTrialCount()):yieldviztask.waitKeyDown(' ')yieldsightlab.startTrial()# Stop the dataServer if it existsifdataServer:print("Stopping previous Biopac data server...")dataServer.Stop()# Reinitialize Biopac data server for each trialprint("Initializing Biopac data server...")dataServer=biopacndt.AcqNdtDataServer(sightlab.acqServer.getSingleConnectionModePort(),enabledChannels)dataServer.RegisterCallback("OutputToScreen",outputToScreen)dataServer.Start()yieldviztask.waitKeyDown(' ')yieldsightlab.endTrial()dataServer.Stop()# Schedule experimentviztask.schedule(sightlab.runExperiment)viztask.schedule(sightLabExperiment)