Skip to content

Instructions: Triggering BioPac in tasks

Taylor Salo edited this page Feb 21, 2022 · 1 revision

Preamble: Using BioPac at the FIU CIS

ECG, EDA, and respiration modules are installed at the CIS and BioPac is linked to a computer that is separate from the scanner and stimulus (task) computers. You will need to include reference to physiological recording in your IRB and consent forms to use BioPac in your study. You will also need to purchase your own supplies in order to use EDA or ECG in your study.

Recommendations for your BioPac profile/procedure

  1. Increase the maximum segment duration from the default (30 min) to the maximum (3 hours).
  2. Automatically label your segments with the date and time of the segment start. This has second-level resolution.
    • You will need to hit "Escape" right after you start recording, and then don't hit it again. This changes the segment name to be the timestamp for when you hit Escape.
  3. Run one long segment throughout your full scan.
  4. Incorporate code below to send triggers to BioPac from your tasks, so you know when functional scans start and end.
  5. Save the file after the scan, then move it to wherever you'll work on it.
  6. Split the physio data based on the trigger timing (channel 4) and label based on the times (as compared to information from scan dicoms).

How to trigger BioPac in behavioral tasks in the scanner

Instructions by Katherine Bottenhorn and Taylor Salo

E-Prime

  1. To start, we would recommend adding a prompt to the task startup menu toggling BioPac/scanner usage. This way, you can include if statements to prevent serial port calls when testing locally.
  2. At the beginning of the experiment, in the inline script that sets up the output .txt:
If c.GetAttrib("BioPac") = "Yes" Then
    Serial.WriteString "RR"
End If
  1. Immediately after scanner trigger, in the same inline script that syncs the timing with the scanner timing:
If c.GetAttrib("BioPac") = "Yes" Then
    Serial.WriteString "FF"
End If
  1. After the task finishes:
If c.GetAttrib("BioPac") = "Yes" Then
    Serial.WriteString "00"
End If
  1. When setting up the experiment, the Serial device must be added to the experiment itself. The port number is COM2, the baudrate is 115200. When this device is added, it is automatically named "Serial", which is why the commands above are all Serial.WriteString.
  2. For testing locally, keep the Serial device turned off. Before you take the task to the scanner, turn the device on!

PsychoPy

  1. Import pyserial:
import serial
  1. When the task is initialized, but before the trigger pulse is sent, initialize the serial port:
ser = serial.Serial('COM2', 115200)
  1. Right before the trigger pulse, reset the signal. This way, if signal from a previous run/task was not stopped because that task was cancelled early, you will still get the necessary break in the signal to identify the new run/task.
ser.write('RR')
  1. Right after the trigger pulse, turn on the signal:
ser.write('FF')
  1. At the end of the task, close the serial port:
ser.write('00')
ser.close()
  1. If you are going to test locally, include a "BioPac" (Yes|No) option in the dialogue box at the beginning of the task and place all of the above lines in separate if statements.

Resources

  • For an example E-Prime task with successful BioPac integration, see the NBC lab's probabilistic selection task.
  • For an example PsychoPy task with successful BioPac integration, see the NBC lab's localizer task.