Table 1
Cuspis’ functions.
| NAME | PURPOSE |
|---|---|
| setApi | Set the BHAPI to use. |
| setDaq | Set the DAQ to use. |
| openApi | Switch on the BHAPI. |
| closeApi | Switch off the BHAPI. |
| plotLiveSignal | Plot the ECG in real time. |
| recSignal | Record the ECG for a specific duration. |
| getEcgThresh | Compute the ECG threshold for triggering a trial. |
| prepStim | Defines the settings for the stimulus presentation. |
| triggerTrial | Trigger the stimulus presentation according to a threshold and specific stimulus settings. The stimulus presentation can be single or multiple (cardio-visual stimulation). |
| plotTrial | Plot the trial data: onsets and offsets of events. |



Figure 1
ECG inside the MRI scanner. All things being equal, participants’ compliance and preparation determine the legibility of the ECG’s R-waves used in the cardiac cycle manipulation. The figure shows the ECG of a participant who did not comply with the researcher’s instructions (top) and another one who did (bottom).

Figure 2
Threshold estimation. The function getEcgThresh detects the R-waves and estimates a threshold as a percentage of the average R-wave amplitude. The detected R-waves are marked with a circle, while the threshold is displayed as a red horizontal line.



Figure 3
Trial’s plot. The function plotTrial shows the ECG used in a specific trial, as well as the events of interest. The onsets of detected R-waves and presented stimuli are marked by orange and green vertical lines, respectively. The offset of the stimulus is marked by a green square. The threshold used for the cardiac-contingent presentation of the stimuli is also shown as a dashed, horizontal line.

| Machine Id: | {4DC18DB1-CDD5-4599-979E-BCD2D81DF186} |
| Operating System: | Windows 10 Home 64-bit (10.0, Build 19044) (19041.vb_release.191206-1406) |
| Language: | English (Regional Setting: English) |
| System Manufacturer: | Dell Inc. |
| System Model: | Inspiron 15 7000 Gaming |
| BIOS: | 01.00.05 (type: UEFI) |
| Processor: | Intel(R) Core(TM) i5-7300HQ CPU @ 2.50GHz (4 CPUs), ~2.5GHz |
| Memory: | 8192MB RAM |
| Available OS Memory: | 8058MB RAM |
| Page File: | 10473MB used, 4753MB available |
| Windows Dir: | C:\WINDOWS |
| DirectX Version: | DirectX 12 |
| DX Setup Parameters: | Not found |
| User DPI Setting: | 120 DPI (125 percent) |
| System DPI Setting: | 96 DPI (100 percent) |
| DWM DPI Scaling: | Disabled |
| Miracast: | Available, with HDCP |
| Microsoft Graphics Hybrid: | Supported |
| DirectX Database Version: | 1.4.6 |
| DxDiag Version: | 10.00.19041.2075 64bit Unicode |
| MATLAB: | 9.10.0.1669831 (R2021a) Update 2 |
| BHAPI: | 2.2 |
| Psychtoolbox: | 3.0.17 - Flavor: beta - Corresponds to SVN Revision 12153 |
