Brain Products (API)

Python support for Brain Products GMBH hardware.

Here we have implemented support for the Remote Control Server application, which allows you to control recordings, send annotations etc. all from Python.

class psychopy_brainproducts.brainproducts.RemoteControlServer(host='127.0.0.1', port=6700, timeout=1.0, testMode=False)

Provides a remote-control interface to BrainProducts Recorder.

Example usage:

import time
from psychopy import logging
from psychopy.hardware import brainproducts

logging.console.setLevel(logging.DEBUG)
rcs = brainproducts.RemoteControlServer()
rcs.open('testExp',
         workspace='C:/Vision/Workfiles/Standard Workspace.rwksp',
         participant='S0021')
rcs.openRecorder()
time.sleep(2)
rcs.mode = 'monitor' # or 'impedance', or 'default'
rcs.startRecording()
time.sleep(2)
rcs.sendAnnotation('124', 'STIM')
time.sleep(1)
rcs.pauseRecording()
time.sleep(1)
rcs.resumeRecording()
time.sleep(1)
rcs.stopRecording()
time.sleep(1)
rcs.mode = 'default'  # stops monitoring mode
property amplifier

Get/set the amplifier to use. Could be one of “ [‘actiCHamp’, ‘BrainAmp Family’,” “ ‘LiveAmp’, ‘QuickAmp USB’, ‘Simulated Amplifier’,” “ ‘V-Amp / FirstAmp’]

For Liveamp you should also provide the serial number, comma separated from the amplifier type.

Examples:

rcs = RemoteControlServer() rcs.amplifier = ‘LiveAmp’, ‘LA-05490-0200’ # OR rcs.amplifier = ‘actiCHamp’

close()

Closes the recording and deletes all associated workspace variables (e.g. when a participant has been completed)

dcReset()

Use this to reset any DC offset that might have accumulated if you aren’t using a high-pass filter

property expName

Get/set the name of the experiment or study (string)

The name will make up the first part of the EEG filename.

Example Usage:

rcs.expName = 'MyTestStudy'
property mode

Get/set the current mode.

Mode is a string that can be one of:

  • ‘default’ or ‘def’ or None will exit special modes

  • ‘impedance’ or ‘imp’ for impedance checking

  • ‘monitoring’ or ‘mon’

  • ‘test’ or ‘tes’ to go into test view

open(expName, participant, workspace)

Opens a study/workspace on the RCS server

Parameters

expNamestr

Name of the experiment. Will make up the first part of the EEG filename.

participantstr

Participant identifier. Will make up the second part of the EEG filename.

workspacestr

The full path to the workspace file (.rwksp), with forward slashes as path separators. e.g. “c:/myFolder/mySetup.rwksp”

openRecorder()

Opens the Recorder application from the Remote Control.

Neat, huh?!

property overwriteProtection

An attribute to get/set whether the overwrite protection is turned on.

When checking the attribute the state of rcs.overwriteProtection a call will be made to the RCS and the report is based on the response. There is also a variable rcs._overwriteProtection that is simply the stored state from the most recent call and does not make any further communication with the RCS itself.

Usage example:

rcs.overwriteProtection = True  # set it to be on
print(rcs.overwriteProtection)  # print current state
property participant

Get/set the participant identifier (a string or numeric).

This identifier will make up the center part of the EEG filename.

pauseRecording()

Pause recording EEG without ending the session.

resumeRecording()

Resume a paused recording

sendAnnotation(annotation, annType)

Sends a message to be logged on the Recorder.

The timing of annotations may be imprecise and this should not be trusted as a method of sending sync triggers.

Annotations can contain any ASCII characters except for “;”

Parameters

annotationstring

The description text to be sent in the annotation.

annTypestring

The category of the annotation which are user-defined strings (e.g. stimulus, response)

Example usage:

rcs.sendAnnotation("face003", "stimulus")
sendRaw(message, checkOutput='OK')

A helper function to send raw messages (strings) to the RCS.

This is normally only used for debugging purposes and is not needed by most users.

Parameters

messagestring

The string that will be sent

checkOutputstring (default=’OK’)

If a value is provided then this will be checked for by this function. If no check is needed then set checkOutput=None

startRecording()

Start recording EEG.

stopRecording()

Stop recording EEG.

property timeout

What is a reasonable timeout in seconds (initially set to 0.5)

For some systems (e.g. when the RCS is the same machine) you might want to set this to a lower value. For an unpredictable or slow network connection you might want to set this to a higher value.

property version

Reports the version of the RCS application

Example usage:

print(rcs.version)
waitForMessage(containing='', endswith='')

Wait for a message, optionally one that meets certain criteria

Parameters

containingstr

A string the message must contain

endswithstr

A string the message must end with (ignoring newline characters)

Returns

The (complete) message string if one was received or None if not

waitForState(stateName, permitted, timeout=10)
Helper function to wait for a particular state (or any attribute, for that matter)

to have a particular value. Beware this will wait indefinitely, so only call if you are confident that the state will eventually arrive!

Parameters

stateNamestr

Name of the state (e.g. “applicationState”)

permittedlist

List of values that are permitted before returning

property workspace

Get/set the path to the workspace file. An absolute path is required.

Example Usage:

rcs.workspace = 'C:/Vision/Worksfiles/testing.rwksp'

Back to top