Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Active information sampling varies across the cardiac cycle

Authors: Stella Kunzendorf 1,2 , Felix Klotzsche 2,3 , Mert Akbal 2 , Arno Villringer 2,3, Sven Ohl 4,5, & Michael Gaebler 2,3,6

1 Charité – Universitätsmedizin Berlin


3 Berlin School of Mind and Brain

4 Bernstein Center of Computational Neuroscience, Berlin

5 Humboldt-Universität zu Berlin

6 Universität Leipzig

Corresponding author: Stella Kunzendorf

For access to participants' data please contact: stella.kunzendorf[-at-]

Abstract Perception and cognition oscillate with fluctuating bodily states. For example, visual pro-cessing was shown to change with alternating cardiac phases. Here, we study the role of the heartbeat for active information sampling—testing whether humans implicitly act upon their environment so that relevant signals appear during preferred cardiac phases. During the encoding period of a visual memory experiment, participants clicked through a set of emotional pictures to memorize them for a later recognition test. By self-paced key press, they actively prompted the onset of shortly presented (100-ms) pictures. Simultaneously recorded electrocardiograms allowed us to analyse the self-initiated picture onsets relative to the heartbeat. We find that self-initiated picture onsets vary across the cardiac cycle, showing an increase during cardiac systole, while memory performance was not affected by the heartbeat. We conclude that active information sampling integrates heart-related signals, thereby extending previous findings on the association between body-brain interactions and behaviour.

For a detailed description of the study, have a look at our manuscript on bioRxiv: (

1. Prerequisites

Programs you need to install prior to the analysis:

  • Our code is computed in the R Statistical Environment (v3.4.3) with RStudio version 1.0.136 (RStudio Team, 2016)

Programs used for preprocessing the cardiac data (participants' preprocessed cardiac data available upon request):

  • EEGlab (Delorme & Makeig, 2004) was used as signal analysis tool to read bdf files from ECG recording with an ActiveTwo AD amplifier (Biosemi, Amsterdam, Netherlands)
  • Electrical events indicating the beginning of each cardiac cycle (R peaks) were extracted from the ECG signal with Kubios 2.2 (Tarvainen et al., 2014,

2. Setup

1. Clone the 0303_INCASI repository


2. Maintain the following file structure on your computer

0303_INCASI contains 5 file paths:

  • _dataframes (saved dataframes from analysis)
  • _figures (saved plots)
  • _functions (computed functions for analysis)
  • _scripts (scripts for analysis)
  • _variables (data for additional variables of inter-individual differences: heart rate variability, trait anxiety, interoceptive awareness)
  • if you want to run your own preprocessing, please contact the author (SK; details see above) for the (almost) raw data (output from Kubios analysis for each participant; 0303_INCASI_data)

  • keep this data folder (0303_INCASI_data) in the same directory as the cloned repo (0303_INCASI)

  • your folder structure should look like this:

  • For the main analysis (skipping preprocessing), directly open script 0303_INCASI_analysis.Rmd (data folder 0303_INCASI_data not needed)

  • If you have done your own preprocessing (and you have the folder 0303_INCASI_data), please change the parameter use_own_preproc_data in the setup chunk of 0303_INCASI_analysis.Rmd to TRUE

  • The file pathways are then created within the script (setup chunk)

3. Scripts

The scripts are to be run in the following order. Preprocessing can be skipped since output dataframes are provided under _dataframes. Main analysis can be run directly.

3.1. Preprocessing

3.1.1. Compute ECG-templates to prepare extraction of individual systole


1. T-template

  • ECG-template from Rpeak until end of T-wave is computed for each participant

  • Systole end is defined by T-wave end in individual ECG-templates

    • 1.A. Create list of dataframes to prepare averaged ECG template for each subject

    • 1.B. Create averaged ECG template (containing RST waves) for each participant and crop out template part that contains T-wave

    • 1.C. Compute Trapez area approach (Vázquez-Seisdedos et al., 2011): Create function to find end of T-wave in template

    • 1.D. Apply trapez_area function to find T-wave end in template

    • 1.E. Compare t-template with actual ECG trace (check correlations and check visually)

2. Q-template

  • ECG-template from Q-wave onset until Rpeak for each participant

  • Q-wave onset is needed as start point for the pre-ejection phase (PEP, determined by regression equation, see preprocessing_b, based on Weissler et al., 1968)

  • The PEP is then substracted from the whole interval (Q-wave until T-wave end) to determine the systolic ejection period (see preprocessing_b)

    • 2.A. Create list of dataframes to prepare averaged ECG template for each subject

    • 2.B. Create averaged ECG template (containing QRST waves) for each participant and define interval from Q-wave onset until Rpeak

3. Overall check of defined cardiac intervals

  • Determined cardiac intervals (i.e., pre-ejection phase, ejection phase, from preprocessing_b) are needed for this step

    • 3.A. Visual Check of systole template (systolic ejection-phase) in participants ECG templates

    • 3.B. Visual Check of cardiac intervals in real ECGlead

3.1.2. Prepare dataframes


1. Load behavioural data into log file

Behavioural data (from stimulation) is loaded into dataframe (one row per trial), and split into 3 dataframes according to experimental sessions:

  • log_encode : encoding period
  • log_recall : recognition period
  • log_rate : rating period

2. Define detection variables (for analysis recognition phase)

3. Analyse memory performance (recognition phase)


1. Prepare long dataframe: LOG_ENCODE

  • Long df with one row per trial

1.A. Compute regression equation (Weissler et al.,1968) to determine pre-ejection period

  • 1.B. Analysis of behavior relative to the heartbeat

  • 1.B.1. For each key press, define the relative timepoint within the R-R interval, the R-R interval length, and the respective heart rate

    • The relative phase of each key press (i.e. picture onset) is computed within the cardiac cycle, indicated in the ECG as the interval between the previous and the following R peak
  • 1.B.2. For each key press, define the circular onset and cardiac phase (cf. Manuscript Figure 2)

    • Circular analysis: to exploit the oscillatory (repeating cycle of cardiac events) character of the heartbeat

      • According to its relative timing within this R-R interval, radian values between 0 and 2π are assigned to each stimulus (Ohl et al., 2016; Pikovsky, Rosenblum, & Kurths, 2003; Schäfer, Rosenblum, Kurths, & Abel, 1998).
    • Binary analysis: to exploit the phasic (two distinct cardiac phases: systole and diastole) character of the heartbeat

      • To account for inter-individual differences in cardiac phase lengths, participant-specific phases are computed based on the ECG (for detailed description of the binning procedure cf. Manuscript Supplementary Methods)
      • Picture onsets are binned into either individual systole, diastole, or non-defined cardiac phases (pre-ejection period, 50ms security window between end of stystole and start of diastole)
  • 1.B.3. Recognition (hits, misses) is defined relative to the cardiac phase (systole, diastole) of picture onset in encoding

1.C. Additional variables (inter-individual variables, rating values) are added to the dataframe

2. Prepare short data frame: DATA_BINS

  • Short df with one row per participant

3.2. Circular functions

Functions to compute within-subject (1. level) and group-level (2. level) circular analysis.


Aim: Create circular plots to show distribution of stimulus onsets relative to the cardiac cycle (encoding period)

circ_click(x, val = "all_val", ray1 = F, plot1 = F, H_rad1 = F, mean1 = F, ray2 = F, plot2 = F, H_rad2 = F, mean2 = F)

Function variables:

  • x: list of participants, or specified participant e.g. "inc25"
  • val: "all_val" = default mode: run over all valences
    • for specific valence specify val = "positiv", val = "negativ", val = "neutral"

1. level analyis (within-subject) default mode = F, select variables to be computed by writing = T:

  • ray1: table with results of rayleigh test, dip test
  • plot1: draw circular plot (c.f. 0303_INCASI_analysis.Rmd, 1.A.1)
  • H_rad1: circular values of 120 trials
  • mean1: mean of circular

2. level analyis (group-level)

  • ray2: result rayleigh test
  • plot2: circular plot (c.f. 0303_INCASI_analysis.Rmd, 1.A.2)
  • H_rad2: circular values of participant means
  • mean2: second level mean

Exemplary function input:

  • Compute circular analysis for participant 25, plot 1.level analysis, and display rayleigh-test output
  • Function output c.f. Manuscript Figure 2.b.

circ_click("inc25", plot1 = T, ray1 = T)


Aim: Create circular plots to show distribution of stimulus onsets (encoding) for correctly (hits) and erroneously (misses) recognised pictures

circ_click_mem(x, det = "hit_miss", val = "all_val", ray1 = F, plot1 = F, H_rad1 = F, mean1 = F, ray2 = F, plot2 = F, H_rad2 = F, mean2 = F) {

Function variables (see also above)

  • det: "hit_miss" = default mode: compute hits and misses (= all old pictures)
    • specify: det = "HIT", det = "MISS"

3.3. Run analysis


  • Caveat: If you have done your own preprocessing (and you have the folder 0303_INCASI_data), please change the parameter use_own_preproc_data in the setup chunk of 0303_INCASI_analysis.Rmd to TRUE


1. Encoding - cardiac influence on visual sampling

1.A. Circular analysis

  • 1.A.1. Exemplary participant-level analysis (c.f. Manuscript Figure 1.b.)

  • 1.A.2. Group-level analysis

  • 1.A.3. Bootstrapping analysis (c.f. Manuscript Figure 2.a)

1.B. Binary analysis

  • 1.B.1. Define ratios for both phases (systole, diastole)

  • 1.B.2. Run analysis: Compare systolic and diastolic ratio (paired t-test)

  • 1.B.3. Plot results with ggplot (c.f. Manuscript Figure 2.b)

2. Recognition - cardiac influence on recognition memory

2.A. Circular analysis

  • 2.A.1. Exemplary participant-level analysis

  • 2.A.2. Group-level analysis

2.B.Binary analysis

  • General Linear mixed models (GLMMs) for binomial data with subject as random factor (c.f. Manuscript Table 1)

    • m0: recognition memory ~ 1 + (1|subject)
    • m1: recognition memory ~ valence + (1|subject)
    • m2: recognition memory ~ valence * cardiac phase + (1|subject) (main model of interest)
  • Dependent variable: recognition memory (coding: 0 = miss, 1 = hit)

  • Independent within-subject variables:

    • cardiac phase: 0 = diastole, 1 = systole
    • valence: three valence levels (positive, negative, neutral), contrast-coded with neutral as baseline condition:
      positive-neutral, negative-neutral
  • Model significance tested with Likelihood ratio tests (LRT)

  • 2.B.1. Prepare dataframe for GLMM analysis

  • 2.B.2. Compute overall mean recognition performance

  • 2.B.3. Run models m0, m1

  • 2.B.4. Run model m2

  • 2.B.5. Refine GLMM analyses (cf. Revision: Reviewer 2, comment #2)

    • Add picture as random factor (m0_p, m1_p, m2_p)
    • Add individual ratings as fixed effect (m3, m4)


1. Correlation of self-paced sampling with inter-individual differences (cf. Revision: Reviewer 1, comment #1)

  • 1.A. Prepare dataframe and include inter-individual differences

    • Heart rate variability (RMSSDl: log-transformed to mitigate skewedness and centred to the mean)
    • Trait Anxiety (STAIz: z-transformed)
    • Interoceptive Awareness (IAz: z-transformed)
  • 1.B. Run correlations

  • 1.C. Plot correlations (c.f. Manuscript Figure 3)

2. Correlation of recognition memory with inter-individual differences

  • 2.A. Prepare dataframe and include inter-individual differences (RMSSDl, STAIz, IAz, see above)

  • 2.B. Run correlations

  • 2.C. Plot correlations (c.f. Manuscript Figure 4)

3. Analyse ratings: Subjective perception of picture emotionality (normative vs. individual ratings)

  • 3.A. Normative and individual means of picture ratings for arousal and valence

  • 3.B. Run tests to compare normative vs. individual ratings

    • Run mixed-design ANOVAs to test ratings across rating category (normative, individual) and valence
    • Run two-sided paired ttests for normative vs. individual arousal ratings across each valence level
  • 3.C. Plot normative vs. individual ratings (c.f. Manuscript Figure 5)

4. Test match of picture features (EmoPicS)

  • 4.A. Test match of physical picture features (luminance, contrast, complexity)

  • 4.B. Test match of high-level picture features (person count, social interaction, close-ups, eye contact)


1. Correlations of individual systoles and heart rate (HR)

  • 1.A. Summary of cardiac phases relative to HR

  • 1.B. Test correlations

  • 1.C. Plot correlations (c.f. Manuscript Figure S1)

2. Ranges and lengths of cardiac phases

  • 2.A. Summary of cardiac phase ranges and lengths

  • 2.B. Plot phase ranges and lengths (c.f. Manuscript Figure S2)

    • Cumulative frequency
    • Mean phase ranges for each participant (relative to R-peak)


Delorme, A., & Makeig, S. (2004). EEGLAB: an open sorce toolbox for analysis of single trail EEG dynamics including independent component analysis. Journal of Neuroscience Methods, 134, 9–21. [URL] (

Ohl, S., Wohltat, C., Kliegl, R., Pollatos, O., & Engbert, R. (2016). Microsaccades Are Coupled to Heartbeat. Journal of Neuroscience, 36(4), 1237–1241.[URL] (

Pikovsky, A., Rosenblum, M., & Kurths, J. (2003). Synchronization: A Universal Concept in Nonlinear Sciences. Cambridge Nonlinear Science Series 12, 432. [URL] (

R Core Team (2017). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. [URL] (

RStudio Team (2016). RStudio: Integrated Development for R. RStudio, Inc., Boston, MA. [URL] (

Schäfer, G., Rosenblum, M. G., Kurths, J., & Abel, H. H. (1998, March 19). Heartbeat synchronized with ventilation. Nature. Nature Publishing Group. [URL] (

Tarvainen M. P., Niskanen J. P., Lipponen J. A., Ranta-Aho P. O., Karjalainen P. A. (2014). Kubios HRV – heart rate variability analysis software. Comput. Methods Programs Biomed., 113, 210–220. [URL] (

Vázquez-Seisdedos, C. R., Neto, J. E., Marañón Reyes, E. J., Klautau, A., de Oliveira, R. C., & Limão de Oliveira, R. C. (2011). New approach for T-wave end detection on electrocardiogram: Performance in noisy conditions. BioMedical Engineering OnLine, 10(1), 77. [URL] (

Weissler, A. M., Harris, W. S., & Schoenfield, C. D. (1968). Systolic Time Intervals in Heart Failure in Man. Circulation, 37(2), 149–159. Retrieved from [URL] (

5. License

This code is being released with a permissive open-source license. You should feel free to use or adapt this code as long as you follow the terms of the license, which are enumerated below. If you make use of or build on the computed functions and/or behavioural/ecg analyses, we would appreciate that you cite the paper.

MIT License

Copyright (c) [2018] [Stella Kunzendorf, Felix Klotzsche, Mert Akbal, Arno Villringer, Sven Ohl, & Michael Gaebler]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.



No description, website, or topics provided.






No releases published


No packages published