Jump to content

Contributions:BioPacLogger

From BCI2000 Wiki

Synopsis

The MP160 is implemented as both a BCI2000 source module and as a “logger.” As a source module, the MP160 is treated as the time base for data acquisition. This means that any peripheral devices will be sampled with respect to the MP160. You should implement the MP160 as a bci2000 source module if this is your primary electrophysiological signal acquisition device. As a logger, the MP160 is implemented alongside a primary electrophysiological amplifier. This means data acquired from the MP160 is resampled to the primary source device. You should implement the MP160 as a logger if you are using it to acquire additional biometric information (such as skin conductance or respiration) but want to use another device for your primary electrophysiological amplifier.

On this wiki page, we will discuss implementing the MP160 as a BCI2000 logger.

Location

http://www.bci2000.org/svn/trunk/src/private/Extensions/BioPacLogger

Versioning

Authors

Huiling Huang (huiling@neurotechcenter.org)

Juergen Mellinger (mellinger@neurotechcenter.org)

William Engelhardt (engelhardt@neurotechcenter.org)

Video Overview



Integration into BCI2000

To enable the extension in your CMake configuration, enable EXTENSIONS_BIOPACLOGGER in the Extensions folder of the CMake GUI and then generate the BCI2000 Visual Studio solution in CMake. Next, open the solution with Visual Studio and rebuild the BCI2000FrameworkSigSrcModule. Then rebuild any signal source module with which you want to use the extension. Once the extension is built into the source module, you can enable it by appending --BioPacLogger=1 to the source module start executable command in your batch file.

BCI2000 and MP160 Synchronization

OverView

This section outlines how BCI2000 acquires and synchronizes the MP160 signal. BCI2000 runs a separate thread from the main thread, matches timestamps with source samples to assign them, and addresses the absence of timestamps in MP160's raw data. In this context, a block represents a block of samples. After acquiring a block of samples from the API, BCI2000 manually assigns timestamps to each sample, resulting in a delay of at least one block. Additionally, the hardware jitter delay typically falls between 25 and 27ms. Consequently, BCI2000 calculates the overall latency as follows:

Latency = BioPacBlockSize / BioPacSamplingRate + (25~27ms).

Data Loss

Data loss can occur due to variations in the interval acquisition time for each MP160 data block. Consider a block size of 100 samples (as referenced in Figure 1) with the MP160 sampling rate being 1000Hz. Ideally, BCI2000 should acquire a block of data in 100ms. However, the actual time may vary. The following scenarios explain potential instances of data loss:

    • Scenario 1:** BCI2000 starts acquiring block#1 in only 97ms and begins acquiring the next block at 198ms. Given the manual assignment of timestamps, the last sample's timestamp in block#1 remains at 200ms. This overlap between block#1 and block#2, from 198ms to 200ms, leads BCI2000 to discard the earlier data, resulting in data loss.
    • Scenario 2:** BCI2000 starts acquiring block#2 at 198ms and completes it at 309ms, 11ms later than expected. The acquisition of the next block then begins at 310ms. However, because the last sample of block#2 has a timestamp of 298ms, a gap occurs between block#2 and block#3.

Hardware Set Up

Figure 2 shows all the necessary hardware from MP160. Make sure you have the MP160 and a wireless amplifier, the power supply for the MP160, an Ethernet USB adapter, and an Ethernet cable that can connect your MP160 with the BCI2000 PC. You will also need the Windows BCI2000 PC that will be running BCI2000. The hardware connection is simple(Figure 3). Using the Ethernet cable, plug one end into the MP160 and the other end into the Ethernet USB adapter. Then connect the adapter to the BCI2000 PC. Alternatively, if your PC has an Ethernet port, you could directly connect the PC with the MP160 using an Ethernet cable.

Calibration

For skin conductance measurements, we need to first calibrate the amplifier before data are acquired. After configuration setup, press “Set Config”, and a dialog will pop up. Then disconnect the leads to the electrodes and press “Calibrate”. Once the calibration is successful, you can reconnect the patient and record data.

Data Scale

Different MP160 amplifiers have different signal ranges. Respiration ranges from negative 10 to 10 volts. EDA ranges from 0 to 50 micro siemens. EMG and EGG range from negative 10 to 10 millivolts. These MP160 events will be stored as bci2000 events to be used for real-time feedback or evaluated after the experiment is complete.

Signal Info
Signal Type Signal Range Signal Resolution
Respiration [-10, 10] V 13 bits
EDA [0, 50] µS 13 bits
EGG [-10, 10] mV 16 bits
EMG [-10, 10] mV 16 bits

BCI2000 events can only be stored as unsigned integers. This means the units of the various MP160 signals (voltage or siemens in the examples above) are not stored. Signals acquired from the MP160 logger are rescaled to 32bit unsigned integers. To convert back to the original signal scaling, use the following scaling equation(Figure 4). Min is the minimum value of data. Max is the maximum value of data. For example, For the EDA signal, the min is 0, and the max is 50. For respiration, EGG, and EMG signals, the min is negative 10, and the max is 10.


Parameters

BioPacCh

The number of connected channels of the MP160. This number must exactly match the number of wireless transmitters you are planning to connect to the MP160.

BioPacBlockSize

The number of samples acquired from the MP160 at a time. The recommended range is 100 ms to 8 seconds. The latency of the MP160 signal is one MP160 block duration plus the hardware buffer delay (roughly 25 ~27ms). That is MP160 latency = BioPacBlockSize/BioPacSamplingRate + (25~27ms).

BioPacSamplingRate

The MP160 supports the following sampling rates: 0.1, 0.125, 0.2, 0.25, 0.4, 0.5, 0.625, 1, 1.25, 2, 2.5, 4, 5, 6.25, 10, 20, 25, 40, 50, 62.5, 100, 125, 200, 250, 400, 500, 625, 1000, 1250, 2000, 2500, 4000, 5000, 6250, 10000, 12500, 20000, 25000, 40000, 50000, 100000, 20000HZ. The maximum Sampling Rate is 1000Hz in the logger module.

BioPacChMatrix

The information of the connected channels. You need to specify the channel ID and corresponding signal types in this matrix.

State and Event Variables

BioPac_chX is the signal from channel X. X is the channel number.


See also

User Reference:Logging Input, Contributions:Extensions