Jump to content

Contributions:BioPacLogger: Difference between revisions

From BCI2000 Wiki
Lingling (talk | contribs)
No edit summary
Lingling (talk | contribs)
No edit summary
Line 18: Line 18:


==Functional Description==
==Functional Description==
Acquires data from BioPac MP160 system: 1)BN-RSPEC(respiration signal) 2)BN-PPGED(skin conductance measurement) 3)BN-EGG2(electrogastrogram) 4)BN-EMG2(Electromyography)
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.
 
In this tutorial, we will implement the MP160, BN-RSPEC, BN-EGG2, BN-EMG2, and BN-PPGED into BCI2000, which will allow us to acquire the respiration signal, electrogastrogram, electromyogram, and electrodermal signal.


==Integration into BCI2000==
==Integration into BCI2000==
Line 25: Line 27:


==Hardware Set Up==
==Hardware Set Up==
Figure 1 shows all the necessary hardware from BioPac, Make sure that you have MP160 and wireless amplifier, power supply for MP 160, Ethernet USB adapter, and Ethernet cable which could connect your BioPac with BCI2000 PC. The hardware connection is simple(Figure 2). Using the Ethernet cable plug on MP 160 and the other side plug on the Ethernet USB adapter. Then connect the adapter to the BCI2000 PC. Alternatively, if your PC got an Ethernet port, you can directly connect the PC with MP 160 using an Ethernet cable.
Figure 1 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 2). 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.
<gallery mode="traditional" widths=650px heights=600px>
<gallery mode="traditional" widths=650px heights=600px>
File:All_device_3_min.png|Figure 1: BioPac hardware.
File:All_device_3_min.png|Figure 1: BioPac hardware.
Line 32: Line 34:


==Calibration==
==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 electrodes, press “Calibrate”.
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.
 


==How does the BCI2000 source signal synchronize the MP160 signal in real-time? ==
==How does the BCI2000 source signal synchronize the MP160 signal in real-time? ==
Line 48: Line 49:


==Parameters==
==Parameters==
===BioPacSourceCh===
===BioPacCh===
The number of active channels of MP160. This number must exactly match the number of wireless transmitters you are planning to connect to MP 160.
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.


===BioPacChList===
===BioPacBlockSize===
The channel number list of connected channels, which must be in ascending order.
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).


===BioPacSourceChType===
===BioPacSamplingRate===
The list of the corresponding signal type matches the order of BioPacChList. So far, we have implemented respiration, EGG, EMG, and EDA signals, so only four signal types above are allowed.
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.  


===BioPacEachChSampleNum===
===BioPacChMatrix===
The number of samples in each channel to acquire from hardware API. For almost all cases, you can keep it as the default value of 200.
The information of the connected channels. You need to specify the channel ID and corresponding signal types in this matrix.
 
===BioPacSamplingRate===
The BioPac 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 for BN-RSPEC, BN-PPGED, BN-EGG2, and BN-EMG2 is 2000HZ. So in this case, the maximum sampling rate here is 2000HZ.


==State and Event Variables==
==State and Event Variables==
Line 68: Line 67:


==Data Scale==
==Data Scale==
Different BioPac amplifiers have different signal ranges. Respiration ranges from negative 10 to 10 voltage; EDA ranges from 0 to 50 microsiemens; EMG and EGG range from negative 10 to 10 micro-voltage.  
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 BioPac components will be stored as bci2000 events to be used for real-time feedback or evaluated after the experiment is complete.
These MP160 events will be stored as bci2000 events to be used for real-time feedback or evaluated after the experiment is complete.


{| class="wikitable"
{| class="wikitable"
Line 95: Line 94:
|}
|}


BCI2000 doesn’t record the data in voltages or microsiemens. We rescale the data to 32 unsigned integers. Below is the scale equation. min is the minimum value of data. max is the maximum value of data. For example, For EDA signal, min is 0, max is 50, for respiration, EGG, and EMG signal, min is negative 10, max is 10.
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.
<gallery mode="traditional" widths=340px heights=150px>
<gallery mode="traditional" widths=340px heights=150px>
File:Equation.png|Figure 4: Data Scale Equation.
File: Equation.png|Figure 4: Data Scale Equation.
</gallery>
</gallery>



Revision as of 16:15, 2 August 2022

Synopsis

The BioPacLogger module enables signal acquisition from BioPac MP160

Location

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

Versioning

Authors

Huiling Huang (huiling@neurotechcenter.org)

Version History

  • 2022-04-19: Initial public release by Huiling Huang (huiling@neurotechcenter.org)

Video Overview


EmbedVideo is missing a required parameter.


Functional Description

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.

In this tutorial, we will implement the MP160, BN-RSPEC, BN-EGG2, BN-EMG2, and BN-PPGED into BCI2000, which will allow us to acquire the respiration signal, electrogastrogram, electromyogram, and electrodermal signal.

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.

Hardware Set Up

Figure 1 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 2). 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.

How does the BCI2000 source signal synchronize the MP160 signal in real-time?

BCI2000 acquired the MP160 signal from a separate thread, which assigns samples by matching the timestamp between the source signal and the logger samples. BCI2000 does this assignment work within one BCI2000 block. The MP160 API does not return a timestamp for each sample, so we manually assign the timestamps to the MP160 samples after we get one block of samples from the API. This means the latency of the MP160 logger is one MP160 block duration plus the hardware buffer delay (roughly 25 ~27ms). That is MP160 latency = BioPacBlockSize/BioPacSamplingRate + (25~27ms).

Data loss

The duration is not identical for the MP160 to acquire every data block. Sometimes it is less than expected. So the start time we are assigning to the next block is a few milliseconds earlier than expected. So there is an overlap between the current and next block.(see figure 3 "overlap"). In this case, the later sample will cover the previous one. In reverse, there is a gap between the current and next block.(see figure 3 "gap"). During the gap, the sample keeps the previous value until it gets a new one.


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.

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.

See also

User Reference:Logging Input, Contributions:Extensions