# HyPyP: a Hyperscanning Python Pipeline for inter-brain connectivity analysis

Anaël Ayrolles, Florence Brun, Phoebe Chen, Amir Djalovski, Yann Beauxis, Richard Delorme, Thomas Bourgeron, Suzanne Dikker, Guillaume Dumas

► To cite this version:

Anaël Ayrolles, Florence Brun, Phoebe Chen, Amir Djalovski, Yann Beauxis, et al. HyPyP: a Hyperscanning Python Pipeline for inter-brain connectivity analysis. Social Cognitive and Affective Neuroscience, 2021, 16 (1-2), pp.72-83. 10.1093/scan/nsaa141. pasteur-03325397

HAL Id: pasteur-03325397

https://pasteur.hal.science/pasteur-03325397

Submitted on 24 Aug 2021

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>
Social Cognitive and Affective Neuroscience, 2021, 72–83

doi:10.1093/scan/nsaa141

Advance Access Publication Date: 8 October 2020

Original Manuscript

OXFORD

Interpersonal Synchrony Special Issue

# HyPyP: a Hyperscanning Python Pipeline for inter-brain connectivity analysis

Anaël Ayrolles,¹,² Florence Brun,¹ Phoebe Chen,³ Amir Djalovski,⁴,⁵

Yann Beauxis,¹ Richard Delorme,¹,² Thomas Bourgeron,¹ Suzanne Dikker,³,⁶
and Guillaume Dumas¹,⁷,⁸,⁹

¹Department of Neuroscience, Institut Pasteur, Paris, France, ²Child and Adolescent Psychiatry Department, Assistance Publique - Hôpitaux de Paris, Robert Debré Hospital, Paris, France, ³Department of Psychology, New York University, New York City, USA, ⁴Baruch Ivcher School of Psychology, Center for Developmental Social Neuroscience, Interdisciplinary Center Herzliya, Baruch Ivcher School of Psychology, Herzliya, Israel, ⁵Department of Psychology, Bar-Ilan University, Ramat Gan, Israel, ⁶Department of Clinical Psychology, Free University Amsterdam, Amsterdam, The Netherlands, ⁷Center for Complex Systems and Brain Sciences, Florida Atlantic University, Center for Complex Systems and Brain Sciences, Boca Raton, FL, USA, ⁸Departement of Psychiatry, Université de Montréal, Montreal, QC, Canada and ⁹Precision Psychiatry and Social Physiology laboratory, CHU Sainte-Justine Centre de Recherche, Precision Psychiatry and Social Physiology Laboratory, Montreal, QC, Canada

Correspondence should be addressed to Guillaume Dumas, CHU Sainte-Justine Research Center 3175 Côte-Sainte-Catherine Road Montréal (Qc) H3T 1C5, Canada. E-mail: guillaume.dumas@ppsp.team

## Abstract

The bulk of social neuroscience takes a ‘stimulus-brain’ approach, typically comparing brain responses to different types of social stimuli, but most of the time in the absence of direct social interaction. Over the last two decades, a growing number of researchers have adopted a ‘brain-to-brain’ approach, exploring similarities between brain patterns across participants as a novel way to gain insight into the social brain. This methodological shift has facilitated the introduction of natural-istic social stimuli into the study design (e.g. movies) and, crucially, has spurred the development of new tools to directly study social interaction, both in controlled experimental settings and in more ecologically valid environments. Specifically, ‘hyperscanning’ setups, which allow the simultaneous recording of brain activity from two or more individuals during social tasks, has gained popularity in recent years. However, currently, there is no agreed-upon approach to carry out such ‘inter-brain connectivity analysis’, resulting in a scattered landscape of analysis techniques. To accommodate a growing demand to standardize analysis approaches in this fast-growing research field, we have developed Hyperscanning Python Pipeline, a comprehensive and easy open-source software package that allows (social) neuroscientists to carry-out and to interpret inter-brain connectivity analyses.

**Key words:** hyperscanning; inter-brain connectivity; non-parametric statistics; analysis pipeline; python
<figure><img src="image_2.png" /><figcaption>Fig. 1. Example of a hyperscanning application of the HyPyP toolbox for the study of dyadic social interactions. (A) Schematic representation of a hyperscanning setup with two participants engaging in reciprocal social interaction. (B) Recordings are split in epochs across time, and brain signals are converted into connectivity matrices containing both intra- and inter-brain connectivity measures. (C) By comparing groups of dyads or conditions, statistical modulation of the inter-brain connectivity can be visualized (illustration generated using HyPyP. See section 'Visualization').</figcaption></figure>

## Introduction

Social cognition involves the integration of biological, behavioral and social processes at both intra- and inter-individual levels (Fairhurst and Dumas, 2019). Paradoxically, most of social neuroscience research has investigated social cognition in isolated individuals exposed to pre-recorded social stimuli, in the absence of any real-time interpersonal dynamics (Hoehl and Markova, 2018). As a result, much remains unknown about how the human brain supports dynamic social interactions (Pfeiffer et al., 2013; Matusz et al., 2019). Neuroscientists recently developed new tools to directly study social interaction, both in controlled experimental settings and in more ecological valid environments (Hoehl and Markova, 2018; Redcay and Schilbach, 2019; Figure 1A). Specifically, 'hyperscanning' setups are increasingly used to simultaneously record brain activity from two or more individuals during social tasks (Czeszumski et al., 2020) and to investigate the co-variations in their brain activity related to their socio-behavioral interactions (Dumas et al., 2011; Babiloni and Astolfi, 2014; Czeszumski et al., 2020). Hyperscanning has been used to study neural synchronization in a wide-range of social interaction contexts, ranging from parent-infant gaze communication (Leong et al., 2017) to teacher-students classroom interactions (Dikker et al., 2017). However, there is currently no agreed-upon approach to carry out such 'inter-brain connectivity analysis', resulting in a scattered landscape of analysis techniques (Burgess, 2013). To accommodate these growing demands of standardized analysis approaches in a fast-growing research field, we developed Hyperscanning Python Pipeline (HyPyP), a comprehensive and easy to understand open-source software package that allows (social) neuroscientists to carry-out and interpret a wide range of inter-brain connectivity analyses. HyPyP can handle data from groups of two or more participants, with data collected either in a simultaneous hyperscanning recording context (Dumas et al., 2011) or in a non-simultaneous setup (Dmochowski et al., 2014). HyPyP encourages the community to share their analyses script in open source and to provide supporting documentation for each analysis measure to motivate its use to probe specific psychologically relevant processes. As such, we hope to serve as a platform where consensus can be reached within the research community with respect to which analysis approach is best suited for which research context.

## From a stimulus-brain approach to a brain-brain approach

Over the last two decades, social and cognitive neuroscience research has increasingly moved towards more naturalistic paradigms, using a variety of recording techniques including functional magnetic resonance imaging (fMRI), electroencephalography (EEG), magnetoencephalography and functional near-infrared spectroscopy (fNIRS). This was initially triggered by two needs: capturing the social brain in the context of daily life and capturing how being actively engaged in interaction is different from passively processing social stimuli (Hari and Kujala, 2009). Various, parallel, attempts were made to tackle the challenge to study social interaction directly, emphasizing multiple sub-dimensions. Some researchers, for instance, focused on the embodied and enactive aspects of social cognition (Thompson and Varela, 2001). Interactional dynamics are then grounded in the bi-directional sensorimotor coupling of people (De Jaegher et al., 2010); the dyad thus becomes a two-body dynamical system (Dumas et al., 2011). Others emphasized instead how our social cognition is fundamentally different in the interactive context, even if the interaction is not reciprocal. In other words, taking a second person perspective (Schilbach et al., 2013) or acting in a we-mode (Gallotti and Frith, 2013) changes our social brain. Interestingly, this delineates a two-dimensional space with one axis denoting offline vs online social cognition (Redcay and Schilbach, 2019), recognizing that one can mentalize and engage in metacognition about others without necessarily interacting in real-time with them (Sebanz et al., 2006; Gallotti and Frith, 2013; Shea et al., 2014), and another axis denoting the synchronized (i.e. symmetric) vs complementary (i.e. asymmetric) roles of people engaged in the interaction (Dumas et al., 2010; Konvalinka et al., 2014).

Beyond this 'interactive turn', social neuroscience has also followed a call for more naturalistic studies and ecological validity, to bring daily life into the lab, and even the lab into daily life (Dikker et al., 2019). Various researchers in the past few years have highlighted the need for such 'real-world' neuroscience studies for a range of reasons, including (a) the need to test the laboratory model of human social cognition in dynamic naturalistic contexts, (b) to address questions that might not be straightforwardly answered in a laboratory environment and (c) to reach populations that might not otherwise be easily
studied (Matusz et al., 2019; Shamay-Tsoowy and Mendelsohn, 2019). This move toward conducting neuroscience research in 'real-world' social settings has been made possible in part by the development of wireless EEG devices (Debener et al., 2012). Portable, affordable technology has enabled researchers to record brain activity from people 'in the wild', ranging from professional environments (Toppi et al., 2016), to artistic contexts (Cruz-Garza et al., 2017), and even inside classrooms (Dikker et al., 2017; Bevilacqua et al., 2019). This move is also supported by translational psychiatry where the social context and the environment can strongly affect how patients behave (Dumas et al., 2014; Bilek et al., 2017), especially for neurodevelopmental disorders (Leong and Schilbach, 2019; Markova et al., 2019).

Given these developments, it is no surprise that the hyperscanning technique (Montague et al., 2002) has gained considerable popularity, revealing new challenges for the study of interacting social brains (Konvalinka and Roepstorff, 2012; Babiloni and Astolfi, 2014). The associated multi-brain neuroscience mixed real-time hyperscanning studies—with focus on social interaction—and post-recording multi-brain analyses—with focus on naturalistic perception, e.g. neurocinema. First, fMRI results demonstrated how the brain dynamics are indeed different when humans are taking others into account in an interactive context (King-Casas et al., 2005) and how social dimension of natural stimuli tends to enhance similarity between brains (Hasson et al., 2012). Hyperscanning studies using either EEG or fNIRS studies then demonstrated how specific neuromarkers are associated with ongoing social coordination (Tognoli et al., 2007) and how a reciprocal interaction with others could bring the similarity of brain patterns to synchronization at the sub-second level (Dumas et al., 2010). These observations have since then been extended to various social tasks, even without any rhythmic coordination (Goldstein et al., 2018), thus demonstrating that inter-brain connectivity may be more than a signature of sensorimotor entrainment (Fairhurst and Dumas, 2019). Inter-brain connectivity may also constitute a marker of shared understanding (Schippers et al., 2010) or cooperation (Astolfi et al., 2020), and studies moving from dyads to groups also support how it is a robust signature of shared attention (Dmochowski et al., 2014; Dikker et al., 2017). Inter-brain connectivity is thus broader than hyperscanning, and the HyPyP library aims at supporting its use not only for simultaneous recording (Hasson et al., 2012; Poulsen et al., 2017) but also across a large range of measures. The HyPyP toolbox is illustrated in Figure 1. HyPyP tools can be used to perform multiple analyses to explore neural synchronizations at both intra- and inter-individual levels. These are discussed later in the overview of functionalities.

# Pipeline description

## Software specifications

The HyPyP library provides a suite of Python tools to manipulate hyperscanning data and inter-brain connectivity measures. Using a community-driven perspective, the code is open source, licensed under a three-clause Berkeley Software Distribution (BDS) license and editable at this address: https://github.com/GHFC/HyPyP.

Running HyPyP requires Python 3.7 (or higher) with major data science libraries, such as Scipy (Virtanen et al., 2020), scikit-learn (Pedregosa et al., 2011), Pandas (McKinney, 2010) and Matplotlib (Hunter, 2007). HyPyP also takes advantage of other

community-driven libraries, such as the MNE library (Gramfort et al., 2013) for the handling of M/EEG signals and Autoreject (Jas et al., 2016) for the pre-processing and rejection of artifacts. Lastly, some metrics supporting the connectivity measures also rely on the Astropy package (Collaboration et al., 2013; Price-Whelan et al., 2018).

## Overview of the functionalities

The HyPyP toolbox is designed to be integrated with MNE-Python (Gramfort et al., 2013), a software package that enables comprehensive M/EEG data analysis at the intra-brain level. HyPyP implements these analyses at an inter-brain level (Figure 1). You can find the complete documentation with an application programming interface description on 'HyPyP Docs' at the link (https://hypyp.readthedocs.io). A detailed tutorial with a toy-dataset is also available on the Github page (http://github.com/GHFC/HyPyP) and illustrates what the current version of HyPyP allows researchers in social neuroscience to do. It especially covers the following analysis steps for multi-person datasets (Figure 2):

**Load raw data.** Raw data files for each condition and participant need to be converted into epochs with the appropriate MNE function before using HyPyP. Epochs are one of the most common ways to analyze EEG signals; the MNE ecosystem has a dedicated object containing signals in a data array and all the associated parameters information—such as channel names, bad channels, frequency, sample frequency—in a metadata dictionary. Below, we illustrate how to load epochs from an example EEG dataset of two participants with the mne.read_epochs() function.

```
# Loading data files
epochs1 = mne.read_epochs(os.path.join('..', 'data',
                             "participant1-epo.fif"), preload=True)
epochs2 = mne.read_epochs(os.path.join('..', 'data',
                             "participant2-epo.fif"), preload=True)
```

**Pre-process data.** HyPyP includes tools to automatically pre-process data, but researchers are still strongly encouraged to manually inspect data and determine the most appropriate pre-processing strategy. Users can also import already pre-processed data (from EEGLAB for example) and proceed directly to the analysis steps with HyPyP. [prep.ICA_fit, prep.ICA.choice_comp, prep.AR_local] is an adaption of MNE-Python (Gramfort et al., 2013) and Autoreject (Jas et al., 2016) functions, taking epochs and returning them cleaned. This process involves rejecting bad epochs, rejecting or interpolating partially bad channels per participant, and then removing the same channels and the same epochs across participants. Thus, only channels and epochs that are 'good' for all the participants are preserved. Independent component analysis (ICA) removal is also matched between participants such that similar independent components (ICs) are rejected across participants. To improve decomposition quality (Winkler et al., 2015), the function filt removes slow drifts from raw data, then after epoching, ICA_fit prepares the signals by computing a global rejection threshold with Autoreject for bad channel rejection and pruning of highly artifacted epochs, and fits an ICA on the remaining set of epochs. ICAChoice_comp then plots ICs for each participant, lets the user choose the relevant component used as model for
<table><caption>**Table 1.** Inter-brain connectivity measures. References related to inter-brain level are in bold. Stationarity is defined as the stability of core characteristics of the time series (e.g. mean, variance, spectral characteristics) relative to the timescale of the analyses</caption><thead><tr><th>Category</th><th>Connectivity analysis</th><th>References</th><th>Linear/Non-linear interaction</th><th>Requires stationarity of EEG</th></tr></thead><tbody><tr><td>Coherency-based</td><td>coh (coherence)</td><td>Guevara and Corsi-Cabrera, 1996; Dikkeret al., 2017</td><td>Linear</td><td>Yes</td></tr><tr><td></td><td>imaginary_coh (imaginary coherence)</td><td>Nolte et al., 2004; Dikkeret al., 2019</td><td>Linear</td><td>Yes</td></tr><tr><td></td><td>wavelet_coh (wavelet coherence)</td><td>Catarino et al., 2013; Cui et al., 2012</td><td>Linear</td><td>Yes</td></tr><tr><td></td><td>envelope_corr (envelope correlation)</td><td>Mehrkanoon et al., 2014; Clerico et al., 2015; Zamm et al., 2018</td><td>Linear</td><td>Yes</td></tr><tr><td></td><td>pow_corr (power correlation)</td><td>Shaw, 1984; Guevara and Corsi-Cabrera, 1996</td><td>Linear</td><td>Yes</td></tr><tr><td></td><td>proj Pow Corr (projected power correlation)</td><td>Hipp et al., 2012; Dikker et al., 2019</td><td>Linear</td><td>Yes</td></tr><tr><td></td><td>ccorr (circular correlation)</td><td>Burgess, 2013; Goldstein et al., 2018</td><td>Non-linear</td><td>Yes</td></tr><tr><td>Phase synchrony</td><td>plv (phase-locking value)</td><td>Lachaux et al., 1999; Dumas et al., 2010</td><td>Non-linear</td><td>No</td></tr><tr><td></td><td>pli (phase lag index)</td><td>Stam et al., 2007; Stam et al., 2007</td><td>Non-linear</td><td>No</td></tr><tr><td></td><td>pdc (partial directed coherence; granger causality)</td><td>Baccalá and Sameshima, 2001; Fallani et al., 2010</td><td>Non-linear</td><td>Yes</td></tr><tr><td></td><td>transfer_entropy (transfer entropy)</td><td>Schreiber, 2000; Kraskov et al., 2004</td><td>Non-linear</td><td>No</td></tr><tr><td>Other analyses</td><td>cross-frequency analysis</td><td>Clerico et al., 2015; Müller and Lindenberger, 2014</td><td>-</td><td>-</td></tr><tr><td></td><td>lagged connectivity</td><td>Stephens et al., 2010</td><td>-</td><td>-</td></tr></tbody></table>
<figure><img src="image_3.png" /><figcaption>Fig. 2. Analysis pipeline for EEG datasets in HyPyP. Steps shown in blue are module-specific, extending functionalities offered by the Python-MNE environment, in coherence with the workflow.</figcaption></figure>

artifact rejection and applies ICA on epoch. AR_local applies
 local Autoreject in the second step:

# high-pass filtering
filt_raws = prep.filt(raws=[raw1, raw2])

# computing global AR and ICA on epochs
icas = prep.ICA_fit(epochs=[epochs1, epochs2],
n_components=15, method='infomax', fit_params=dict
(extended=True), random_state=42)

# selecting components semi-automatically and remove them

cleaned_epochs_ICA = prep.ICA.choice_comp(icas, epochs=
[epochs1, epochs2])

This is followed by a prompt asking which participant should
be used as a template and which IC from this participant should
be used as a template.

# Applying local AR for each participant rejecting bad epochs,
rejecting or interpolating partially bad channels per partici-
pant, and removing the same bad channels and epochs across
participants.

cleaned_epochs_AR = prep.AR_local(cleaned_epochs_ICA, verbose = True)
**Merge/split data.** [utils.merge] takes epochs from each participant to align and merge them into a single data file (whether participant data were recorded in one file or in separate files). This is particularly important when users have loaded their data into MNE and just want to concatenate multiple participants in the same MNE structure. For creating a hyper-dataset combining two recordings stored in epochs called epochs1 and epochs2, this is as simple as:

$$hyper_epo = \text{merge}(\text{epochs\_S1}=\text{epochs1}, \text{epochs\_S2}=\text{epochs2})$$

[utils.merge] also takes previously pre-processed recordings: users can load data directly to visualize them (bad channels are still taken into account).

Respectively, [utils.split] takes a single hyper-epoch with both participants' data merged and channel names indicating the participants 1 & 2 with "_1" and "_2", and split it into two single-participant epochs:

$$epochs1, epochs2 = \text{split}(\text{hyper_epo})$$

**Data analysis.** [analyses.pow] computes Welch power spectral density (PSD) from pre-processed epochs. fmin and fmax set the minimum (fmin) and maximum (fmax) frequencies over which PSD is computed. The parameter n}_fft states the length of the fast Fourier transform (FFT), and n}_per_seg states the length of each Welch segment. The exact frequency bins are calculated based on FFT parameters and are returned in freq_list. Here is a guide for determining n}_fft and n}_per「_seg: when n}_fft is None, n}_per「_seg determines the sample count of each segment for computing the PSD. A longer segment means higher frequency resolution and lower time resolution. N}_fft is used only if a zero-padded FFT is desired, and it has to be bigger or equal to n}_per「_seg. The segment length for FFT is thus n}_per「_seg if n}_fft is None or n}_fft if it is not. To estimate the power in the frequencies of interest, the segment length should be set to at least four times the period of the minimum frequency (e.g. if fmin is 4 Hz and the sampling rate is 1000 Hz, n}_per「_seg should be at least 1000, i.e. 1 second long). The user can either average PSD values over epochs (epochs_average = True) or preserve the complete time course. In the example below, the frequency-band-of-interest is restricted to Alpha_Low, frequencies for which PSD is actually

computed are returned in freq_list and PSD values are averaged across epochs:

psd1 = analyses.pow(preproc_S1, fmin=7.5, fmax=11, n}_fft=1000, n}_per「_seg=1000, epochs_average=True)

psd2 = analyses.pow(preproc_S2, fmin=7.5, fmax=11, n}_fft=1000, n}_per「_seg=1000, epochs_average=True)

data_psd = np.array([psd1.psd, psd2.psd])

[analyses.compute_freq_bands] and [analyses.compute_sync] take pre-processed epochs, the analytic signal, and return different measures of inter-individual brain connectivity (see Roadmap Table 2 for the metrics that are implemented). The resulting matrix from the connectivity analysis is a matrix of size (2 × channel count, 2 × channel count) and represents connectivities between every pair of channels among the two participants. Indexing the matrix yields four blocks of size (channel count, channel count). Thus, two of the four blocks represent inter-brain connectivities from participant A to B and from B to A, and the other two represent intra-brain connectivity within each individual, respectively (See Figure 1B). Most of the connectivity metrics implemented are not directional, and therefore the two inter-brain connectivity 'blocks' are exactly symmetrical. However, this is not true for causality measures (partial directed coherence [PDC] and transfer entropy), where connectivity from A to B and from B to A is different. Similarly to PSD, the user can either average the connectivity values over epochs (epochs_average = True) or preserve the complete time course.

First, the analytic signal per frequency band is computed, after which frequency- and time-frequency-domain connectivity is calculated. In the example below, circular correlation coefficient ('ccorr') is used. The results are then sliced to generate the inter-brain part of the matrix. This is exemplified below using Alpha_Low (frequencies); Cohens' D is computed for further analyses.

complex_signal = analyses.compute_freq_bands(data=[preproc_S1, preproc_S2], freq_bands)

result = analyses.compute_sync(complex_signal, mode='ccorr')

n_ch = len(epochs1.info['ch_names'])

theta, alpha_low, alpha_high, beta, gamma = result[, 0:n_ch, n_ch:2:n_ch]

<table><caption>**Table 2.** HyPyP roadmap of the core features</caption><thead><tr><th>Category</th><th>Pipeline functionality</th><th>HyPyP alpha</th><th>HyPyP beta</th><th>HyPyP release</th></tr></thead><tbody><tr><td>Data type</td><td>EEG/MEG</td><td>✓</td><td>✓</td><td>✓</td></tr><tr><td></td><td>Fnirs</td><td>-</td><td>-</td><td>✓</td></tr><tr><td rowspan="4">Pre-processing</td><td>Load raw datasets</td><td>✓</td><td>✓</td><td>✓</td></tr><tr><td>Pre-process data</td><td>✓</td><td>✓</td><td>✓</td></tr><tr><td>Load previously pre-processed data</td><td>✓</td><td>✓</td><td>✓</td></tr><tr><td>Temporally align datasets</td><td>✓</td><td>✓</td><td>✓</td></tr><tr><td rowspan="4">Data analysis (see also Roadmap Table 3)</td><td>Compute inter-brain connectivity</td><td>✓</td><td>✓</td><td>✓</td></tr><tr><td>Compute intra-brain connectivity</td><td>✓</td><td>✓</td><td>✓</td></tr><tr><td>Compute power spectral density</td><td>✓</td><td>✓</td><td>✓</td></tr><tr><td>Sources reconstruction</td><td>-</td><td>-</td><td>✓</td></tr><tr><td rowspan="4">Statistical analysis (See also Roadmap Table 4)</td><td>Group-mean differences</td><td>✓</td><td>✓</td><td>✓</td></tr><tr><td>Integrate behavioral variables</td><td>-</td><td>✓</td><td>✓</td></tr><tr><td>Integrate intra-brain analyses</td><td>-</td><td>✓</td><td>✓</td></tr><tr><td>Integrate group analysis</td><td>-</td><td>-</td><td>✓</td></tr><tr><td rowspan="3">Visualization</td><td>Visualize inter-brain connectivity</td><td>✓</td><td>✓</td><td>✓</td></tr><tr><td>Visualize intra-brain analysis</td><td>-</td><td>✓</td><td>✓</td></tr><tr><td>Visualize group connectivity</td><td>-</td><td>-</td><td>✓</td></tr></tbody></table>
<table><caption>**Table 3.** HyPyP roadmap of the analyses and visualization tools</caption><thead><tr><th>Analysis &amp; visualization</th><th>HyPyP alpha</th><th>HyPyP beta</th><th>HyPyP release</th></tr></thead><tbody><tr><td>Contrast between two conditions (A vs. B)</td><td>✓</td><td>✓</td><td>✓</td></tr><tr><td>Display statistical map</td><td>✓</td><td>✓</td><td>✓</td></tr><tr><td>Simulated dataset</td><td>-</td><td>✓</td><td>✓</td></tr><tr><td>Integrate behavioral coding</td><td>-</td><td>✓</td><td>✓</td></tr><tr><td>Compare intra- &amp; inter-individual metrics</td><td>-</td><td>-</td><td>✓</td></tr><tr><td>Searchlight analysis connectivity × behavior</td><td>-</td><td>-</td><td>✓</td></tr><tr><td>Frequency correlations</td><td>-</td><td>-</td><td>✓</td></tr><tr><td>High-def visualization options</td><td>-</td><td>-</td><td>✓</td></tr><tr><td>Meta-connectivity analysis</td><td>-</td><td>-</td><td>✓</td></tr><tr><td>Integrate other continuous data (e.g. physiological, movement)</td><td>-</td><td>-</td><td>✓</td></tr></tbody></table>

<table><caption>**Table 4.** HyPyP roadmap of the documentation</caption><thead><tr><th>Documentation</th><th>HyPyP alpha</th><th>HyPyP beta</th><th>HyPyP release</th></tr></thead><tbody><tr><td>Code documentation</td><td>✓</td><td>✓</td><td>✓</td></tr><tr><td>Tutorial documentation</td><td>-</td><td>✓</td><td>✓</td></tr><tr><td>Detailed metrics documentation</td><td>-</td><td>✓</td><td>✓</td></tr><tr><td>Guidelines about psychological processes associated with inter-brain metrics</td><td>-</td><td>-</td><td>✓</td></tr></tbody></table>

<figure><img src="image_4.png" /><figcaption>**Fig. 3.** Permutation statistics for inter-brain connectivity measures. (A) Schematic representation of a hyperscanning experimental design. (B) Example of null hypothesis testing with permutation. Inter-brain connectivity measures are either calculated for the same participants but randomizing time or for fake pairs generated by randomizing pairing of participants in the same condition/group or between the condition/group.</figcaption></figure>

$$
\begin{align*}
\text{values} &= \text{alpha\_low} \\
\text{values} &= -\text{npotts}(\text{np}\cdot\text{diag}(\text{values})) \\
\text{C} &= (\text{values} - \text{np}\cdot\text{mean}(\text{values}[\cdot])) / \text{np}\cdot\text{std}(\text{values}[\cdot])
\end{align*}
$$

This process can also be applied to intra-individual brain connectivity to support single participant analysis. In addition, the mode argument in the function can take different connectivity measurements (see section 'Inter-brain connectivity measures'). This generates connectivity matrices for each epoch (Figure 1B).

Similar to the inter-brain analyses, results are sliced to generate the intra-brain part of the matrix, exemplified here with Alpha_Low and Cohens' D.

for i in [0, 1]:
theta, alpha_low, alpha_high, beta, gamma = result[i::2, i:i+4, 2]

values_intra = alpha_low
values_intra -= np.np.diag(values_intra))
C_intra = (values_intra - np.mean(values_intra[i:i+4])) / np.std(values_intra[i:i+4])

Cross-spectral density (CSD) values can also be sampled directly for statistical analyses:

result_intra.append(C_intra)

Statistics. [stats.statsCond] and [stats.statscluster] are adapted from MNE-Python statistical tests: a parametric t-test corrected for multiple comparisons and a non-parametric cluster-level statistical permutation test using a pre-defined threshold (alpha), corrected with channel connectivity across space and frequencies (freq_list, ch_con_freq). Both functions take PSD, intra- or inter-individual brain connectivity measurements (result or data) and return statistical values. Permutation tests can be leveraged to test a number of null hypotheses, ranging from modulation of inter-brain synchronization within dyads to between groups of participants (Figure 3). Permutation makes it possible to calculate connectivity measures either for the same participants but randomizing time or for fake pairs generated by randomizing pairing of participants in either the same condition/group or between the condition/group (Figure 3B). Clustering allows reducing familywise errors due to multiple comparisons by clustering neighboring quantities that exhibit
the same effect. The neighborhood is corrected by space (adjacent sensors over the scalp) and frequencies (adjacent frequency bins). We use the test argument to define the nature of the test used to compare groups or conditions. The test can be a t-test for independent or paired samples ('ind ttest' or 'rel ttest'), a one-way ANOVA test ('f oneway') or a multiple-way ANOVA test ('f multipleway') (if multiple-way ANOVA, the number of levels for each factor is specified with the factor_level argument).

The HyPyP simple parametric t-test is based on the MNE function stats.permutations_t_test() to which we added a false discovery rate correction for multiple comparisons.

$$\text{statsCondTuple} = \text{stats.statsCond}(\text{data}=\text{data_psd}, \text{epochs}=\text{preproc\_S1}, \text{n\_permutations}=5000, \text{alpha}=0.05)$$

For non-parametric cluster-based permutations, we created a matrix of a priori channel connectivity within individuals based on the channels' position. In HyPyP, the permutation test can be used for comparing either two groups of PSD matrices or two groups of inter-brain synchrony matrices. Note that for both types of comparison, we are using the same matrix as adjacency prior, assuming both EEG were recorded with the same montage. This means that in the case of inter-brain connectivity matrix comparison, clusters of inter-brain connections are counted based on the distance between their ends on each brain according to the channel locations; in the case of PSD matrix comparison, clusters are counted based on the channel locations on one brain.

The following example is for comparing two groups' PSD in the Alpha Low band.

$$\text{con\_matrixTuple} = \text{stats.con\_matrix}(\text{preproc\_S1}, \text{freqs\_mean}=[7.5, 11]) \\ \text{ch\_con\_freq} = \text{con\_matrixTuple.ch\_con\_freq}$$

Below two fake groups are created for PSD comparison: one with two instances of 'participant1' and the other with two instances of 'participant2'.

$$\text{data_group} = [\text{np.array}([\text{psd1.psd}, \text{psd1.psd}]), \text{np.array}([\text{psd2.psd}, \text{psd2.psd}])] \\ \text{statscluster} = \text{stats.statscluster}(\text{data}=\text{data_group}, \text{test}=\text{ind ttest}, \text{factor\_level}=\text{None}, \text{ch\_con\_freq}=\text{scipy.sparse.}) \\ \text{bsr\_matrix}(\text{ch\_con\_freq}), \text{tail}=0, \text{n\_permutations}=5000, \text{alpha}=0.05)$$

The HyPyP non-parametric cluster-based permutations test can also be used to compare intra-brain connectivity values between participants. To that end, a matrix is created of a priori connectivity between channels across space and frequencies based on their position.

$$\text{con\_matrixTuple} = \text{stats.con\_matrix}(\text{epochs}=\text{preproc\_S1}, \text{freqs\_mean}=\text{np.arange}[7.5, 11], \text{draw}=\text{False})$$

Note that for inter-brain connectivity measures, the resulting frequency bins are every integer frequency between fmin and fmax with a 1 Hz spectral resolution regardless of the data structure because the FFT window parameters are adaptive. For PSD, however, the resulting frequency bins are determined based on the specific FFT window parameters and are returned in 'freq_list'. The spectral resolution may thus differ from 1 Hz depending on the parameters.

For CSD, values are averaged across each frequency, so you do not need to take frequency into account to correct clusters.

$$\text{ch\_con} = \text{con\_matrixTuple.ch\_con}$$

Here again, two fake groups are created with twice the 'participant1' and twice the 'participant2'. Here we have, for example, in the Alpha_Low band:

$$\text{Alpha\_low} = [\text{np.array}([\text{result\_intra}[0], \text{result\_intra}[0]]), \text{np.array}([\text{result\_intra}[1], \text{result\_intra}[1]])] \\ \text{statscluster\_intra} = \text{stats.statscluster}(\text{data}=\text{Alpha\_Low}, \text{test}=\text{ind ttest}, \text{factor\_level}=\text{None}, \text{ch\_con\_freq}=\text{scipy.sparse.}) \\ \text{n\_permutations}=5000, \text{alpha}=0.05)$$

Finally, intra-brain connectivity values can be compared to a surrogate signal. For now, creating a surrogate signal has not been implemented in HyPyP, but the user can compare intra-connectivity between subjects. No a priori connectivity between channels is considered between the two participants. In the Alpha_Low band, for example (see earlier), two fake groups are again created with twice the 'participant1' and twice the 'participant2':

$$\text{data} = [\text{np.array}([\text{values}, \text{values}]), \text{np.array}([\text{result\_intra}[0], \text{result\_intra}[0]])] \\ \text{statscluster} = \text{stats.statscluster}(\text{data}=\text{data}, \text{test}=\text{ind ttest}, \text{factor\_level}=\text{None}, \text{ch\_con\_freq}=\text{None}, \text{tail}=0, \text{n\_permutations}=5000, \text{alpha}=0.05)$$

**Visualization.** T values for statistical analyses can be visualized for all channels or for significant channels only.

For example:

```
# visualize T values for channels for HyPyP parametric t test with FDR correction
viz plot significant sensors(T Obs plot=statsCondTuple.T Obs, epochs=preproc S1)
```

```
# visualize T values for significant channel only for HyPyP parametric t test with FDR correction
viz plot significant sensors(T Obs plot=statsCondTuple.T Obs, epochs=preproc S1)
```

Statistical modulation of the inter-brain connectivity can also be visualized. [viz.viz_2D_topomap_inter, viz.viz_3D_inter] take channel locations and the matrix of inter-individual brain connectivity to visualize inter-brain links projected on either 2D topographic maps or 3D head models. Links are represented by 10th order Bezier curves; shape can be modulated with the [steps] parameter. Only values over the user-defined threshold are plotted. The sequential red color map is used for positive connectivity values, the blue for negative. Line thickness increases with the strength of the connectivity. Bad channels are excluded after pre-processing and are displayed on the visualization models with a cross (as opposed to the points that are used for good channels) to clearly distinguish between channels for which there was no significant inter-brain link and channels that were excluded prior to analysis (see Figure 1C for an example of 3D-visualization generated using HyPyP).
```
# Visualization of inter-brain connectivity in 2D
viz.viz_2D_topomap_inter(epochs1, epochs2, C, threshold=2,
                             steps=10, lab=True)
```

```
# Visualization of inter-brain connectivity in 3D
viz.viz_3D_inter(epochs1, epochs2, C, threshold=2, steps=10,
                   lab=False)
```

## Inter-brain connectivity measures

To measure the connectivity between two signals, we can measure the similarity in their power, phase or both (Table 1). Amplitude or envelope correlation (power correlation, envelope correlation and projected power correlation [PPC]) estimates power similarity. Phase synchrony (phase locking value [PLV], phase locking index [PLI] and circular correlation [CCorr]) measures the phase similarity, while coherency-based metrics (coherence, wavelet coherence and imaginary coherence) measure the similarity of both power and phase. Thus, the choice of appropriate connectivity metric depends on the nature of what the experimenter is interested in. For example, for neural processes, the similarity between participants' cognitive states is better reflected in the amplitude or envelope correlation because their dynamics are on a larger time scale. For ongoing cognitive processing, with a finer-grained account of neural content and timing, the phase synchrony measures might be more relevant. Following existing hyperscanning studies and functional connectivity network studies, HyPyP natively includes common measures of phase synchrony, power synchrony, coherence-based connectivity and directed measures of casualty or information transfer (Astolfi et al., 2007). We will continue adding and documenting measures on the HyPyP project page (https://pypi.org/project/HyPyP/), with the ultimate goal of formulating testable linking hypotheses between connectivity metrics and psychological processes, as such promoting consensus within the hyperscanning research field with regard to analysis choices. Here, we briefly describe the core connectivity measures that are implemented in HyPyP.

Although inter-brain connectivity metrics are often grounded in functional connectivity measures used in single-brain studies, the experimental design and underlying mechanism differ significantly. Unlike intra-brain synchrony, inter-brain synchronization is not driven by physical connections between brain sources and cannot be explained by information transfer through neuronal oscillations (Dumas et al., 2012). In addition, hyperscanning studies sometimes adopt a naturalistic paradigm without trigger-locking events. These distinctions result in hyperscanning studies' mixed methodologies and complex functional interpretation of the results.

Our toolbox addresses these different needs: HyPyP provides a variety of connectivity options, as mentioned earlier, along with functionalities to explore and compare them. First, when metrics are computed in the frequency domain, we calculate them from the analytic signal instead of spectral densities, which is more suited for nonstationary brain data in naturalistic paradigms (Lowet et al., 2016). According to Lowet et al., phase synchronization process is inherently non-stationary because it comes with systematic frequency variations over time, but the phase representation computed from cross-spectral density assumes stationarity. Estimating phase from the analytic signal using Hilbert transform, on the other hand, generates instantaneous phase representation, and thus does not assume

stationarity. Second, a connectivity matrix is calculated for inter- and intra-brain channel pairs for all epochs (Figure 1B), resulting in a space-time-frequency representation convenient for data exploration. To facilitate a deeper understanding of the metrics, we provide an example hyperscanning dataset to test hyper-connectivities metrics. With regard to statistical tests, we include a traditional t-test with possibility of multiple comparisons correction through cluster-based permutation test. Future implementations will include correlation with behavioral coding, meta-analyses across different metrics and analyses of variance combining groups and conditions. On top of these analyses, we offer 2D and 3D visualizations of hyper-connections between brains and we will implement an equivalent for connectivity within brains.

Correlation and coherence are traditional linear methods to estimate brain connectivity. Correlation coefficients of blood-oxygen-level dependent signal (BOLD) signals in hyperscanning fMRI studies have been found to characterize joint attention (Koike et al., 2016) and increase during social context in cinema (Hasson et al., 2004). Coherence, on the other hand, is more commonly used in fNIRS and EEG studies. Wavelet coherence is commonly employed in fNIRS hyperscanning studies, such as to study cooperative and competitive behaviors (Cui et al., 2012; Osaka et al., 2014), imitation (Holper et al., 2012), verbal communication (Jiang et al., 2012; Jiang et al., 2015), decision-making (Tang et al., 2016) and learning (Pan et al., 2018). In EEG hyperscanning, coherence has been used to study classroom social dynamics (Dikker et al., 2017). As an alternative, the imaginary part of the coherence captures time-lagged synchronization only, removing zero-lagged spurious synchronizations caused by volume condition, i.e. only useful at the intra-brain level (Nolte et al., 2004; Dikker et al., 2019).

Non-linear brain connectivity metrics are also implemented in HyPyP, including versions of phase synchrony, power correlation and causality measures. The most commonly used phase synchrony measure is PLV, which was employed to estimate synchronization in joint action (Dumas et al., 2010 2011), verbal interaction (Perez Repetto et al., 2017), decision-making (Tang et al., 2016) and other tasks. PLI is similar to PLV but designed for events based experimental designs. It has been adopted in a series of musical coordination studies (Lindenberger et al., 2009; Sänger et al., 2012). CCorr measures the covariance of phase variance between two data streams and is more robust to coincidental synchrony (Burgess, 2013) compared to PLV or PLI. CCorr has seen an increasing popularity and has been successfully implemented in studies investigating touch (Goldstein et al., 2018), learning (Bevilacqua et al., 2019) and language (Perez Repetto et al., 2017).

Correlation between PSD and envelope in EEG data has long been used in single-brain studies (Shaw, 1984; Guevara and Corsi-Cabrera, 1996) and also adopted in hyperscanning (Zamm et al., 2018). PPC, a version of power correlation between orthogonalized time series to discount spurious synchronization (Hipp et al., 2012), has been found to be correlated with personality traits in naturalistic interaction (Dikker et al., 2019).

Recent studies have advocated for establishing causal interpretations of synchrony values (Dean and Dunsmuir, 2016). For inferring causality in a multivariate dataset, there are autoregressive modeling and information-theoretic approaches, represented by Granger causality (GC) and transfer entropy (TE), respectively. GC and TE are based on the predictive ability of one series on the other's future; they are equivalent under the Gaussian distribution. In EEG studies, GC is often operationalized
through partial directed coherence (PDC), the frequency-domain method for GC. PDC has been found to be associated with altruistic or cooperative behaviors in hyperscanning studies (Fallani et al., 2010; Astolfi et al., 2012; Toppi et al., 2016; Ciaramidaro et al., 2018). Compared to GC, TE does not require a model and is thus more sensitive to nonlinear interactions (Schreiber, 2000). Its application in EEG hyperscanning was proposed by some groups (Liu and Pelowski, 2014) but has not yet been explored much.

Here is a list of short definitions of each metric:

* Coherence: the squared magnitude of cross-spectral density between x and y, divided by the autospectral density of x and y, respectively.

* Imaginary coherence: the absolute value of the imaginary part of the coherence.

* Wavelet coherence: the cross-correlation between two signals as a function of frequency and time, detecting time-localized synchrony in nonstationary signals.

* Envelope correlation: Pearson correlation between the envelope of two signals.

* Power correlation: Pearson correlation between the power of two signals.

* PPC: Pearson correlation between the signal envelopes after the projection of one signal on the other has been removed.

* CCorr: Pearson correlation between the angle values of two signals.

* PLV: variability of the phase difference between two signals over time.

* Phase lag index: the amount of asymmetry of the relative phase distribution (Aydore et al., 2013).

* PDC (GC in the frequency domain): the amount of spectral information in the future of y that can be predicted from the past of x.

* TE: equivalent to GC under the Gaussian distribution, can better handle non-linearity.

## Roadmap

To our knowledge, HyPyP is the first comprehensive toolbox dedicated to quantifying brain connectivity across multiple participants. Tables 2–4 list the roadmap for HyPyP iterations. These roadmaps are subject to change and are actively maintained on the HyPyP project page (pypi.org/project/HyPyP).

We aim to integrate the study of behavioral variables from inter to intra-brain level and extend statistical and visualization functions to group analyses. Also, taking advantage of MNE source level functionality, we aim to integrate source-level hyperscanning to complement our channel-level visualization. In addition to streamlining and implementing these functionalities (listed in Tables 2–4), we will continue releasing documentation around the pipeline, including documented code, tutorial materials and guidelines for linking hypotheses between connectivity metrics and psychological processes. The toolbox is designed with consideration for the complexity and multi-dimensionality of hyperscanning studies. By incorporating the time course, behavioral data and meta-analyses, we hope the toolbox can support the discovery of functional and behavioral correlates of connectivity metrics in multi-brain studies.

## Conclusion

The HyPyP is an analysis toolbox designed to support (social) neuroscientists interested in comparing brain data across two or more participants. It already integrates the core tools to run inter-brain connectivity measures from pre-processing to visualization and will continue to be improved upon in a community-driven fashion. The specific tools provided in HyPyP will facilitate standardized inter-individual neurophysiological analyses to support scientific progress and replicability in social neuroscience research.

## Acknowledgements

The authors wish to thank: Denis Engemann for his early help regarding the MNE and the Autoreject libraries; Alexandra P. Key and Sahana Nagabhushan Kalburgi (Vanderbilt Kennedy Center) as well as Nigel Janssens and Lena Adel (Free University Amsterdam) for working with us to test pipeline functionalities; Yafeng Pan (Karolinska Institutet), Ihshan Gumilar, and Yufang Yaang for their precious feedback and interactions at the early stage of HyPyP development.

## Funding

This project is supported by the Institut Pasteur, INSERM, FondaMental Foundation, Ecole Normale Supérieure from Lyon, APHP, DHU Protect, Bettencourt-Schueler Foundation, Cognacq Jay Foundation, Conny-Maeva Foundation, Fondation de France, Labex BioPsy, a grant from Pierre Deniker Foundation, a grant from Congrès Français de Psychiatrie CFP-BM-2019-03, National Science Foundation Award #1661016, Netherlands Organisation for Scientific Research Award #406.18.G0.024. GD is funded by the Institute for Data Valorization (IVADO), Montreal, and the Fonds de recherche du Québec (FRQ).

## Conflict of interest

The authors declare that there is no conflict of interest.

## References

* Astolfi, L., Cincotti, F., Mattia, D., et al. (2007). Comparison of different cortical connectivity estimators for high-resolution EEG recordings. *Human Brain Mapping*, 28, 143–57.

* Astolfi, L., Toppi, J., Borghini, G., et al. (2012). Cortical activity and functional hyperconnectivity by simultaneous EEG recordings from interacting couples of professional pilots. In: 2012 Annual International Conference of the IEEE Engineering in Medicine and Biology Society. p. 4752–55.

* Astolfi, L., Toppi, J., Ciaramidaro, A., et al. (2020). Raising the bar: can dual scanning improve our understanding of joint action? *NeuroImage*, 216, 116813.

* Aydore, S., Pantazis, D., Leahy, R.M. (2013). A note on the phase locking value and its properties. *NeuroImage*, 74, 231–44.

* Babiloni, F., Astolfi, L. (2014). Social neuroscience and hyperscanning techniques: past, present and future. *Neuroscience and Biobehavioral Reviews*, 44, 76–93.

* Baccalá, L.A., Sameshima, K. (2001). Partial directed coherence: a new concept in neural structure determination. *Biological Cybernetics*, 84, 463–74.
Bevilacqua, D., Davidesco, I., Wan, L., et al. (2019). Brain-to-brain synchrony and learning outcomes vary by student-teacher dynamics: evidence from a real-world classroom electroencephalography study. *Journal of Cognitive Neuroscience*, 31, 401–11.

Bilek, E., Stößel, G., Schäfer, A., et al. (2017). State-dependent cross-brain information flow in borderline personality disorder. *JAMA Psychiatry*, 74, 949–57

Burgess, A.P. (2013). On the interpretation of synchronization in EEG hyperscanning studies: a cautionary note. *Frontiers in Human Neuroscience*, 7, 881.

Catarino, A., Andrade, A., Churches, O., et al. (2013). Task-related functional connectivity in autism spectrum conditions: an EEG study using wavelet transform coherence. *Molecular Autism*, 4, 1.

Ciaramidaro, A., Toppi, J., Casper, C., et al. (2018). Multiple-brain connectivity during third party punishment: an EEG hyperscanning study. *Scientific Reports*, 8, 6822.

Clerico, A., Gupta, R., Falk, T.H. (2015). Mutual information between inter-hemispheric EEG spectro-temporal patterns: a new feature for automated affect recognition. In: 2015 7th International IEEE/EMBS Conference on Neural Engineering (NER). p. 914–17.

Collaboration, T.A., Robitaille, T.P., Tollerud, E.J., et al. (2013). Astropy: a community Python package for astronomy. *Astronomy and Astrophysics*, 558, A33.

Cruz-Garza, J.G., Brantley, J.A., Nakagome, S., et al. (2017). Deployment of mobile EEG technology in an art museum setting: evaluation of signal quality and usability. *Frontiers in Human Neuroscience*, 11, 527.

Cui, X., Bryant, D.M., Reiss, A.L. (2012). NIRS-based hyperscanning reveals increased interpersonal coherence in superior frontal cortex during cooperation. *NeuroImage*, 59, 2430–37

Czeszumski, A., Eustergerling, S., Lang, A., et al. (2020). Hyperscanning: a valid method to study neural inter-brain underpinnings of social interaction. *Frontiers in Human Neuroscience*, 14, 39.

De Jaegher, H., Di Paolo, E., Gallagher, S. (2010). Can social interaction constitute social cognition? *Trends in Cognitive Sciences*, 14, 441–47.

Dean, R.T., Dunsmuir, W.T. (2016). Dangers and uses of cross-correlation in analyzing time series in perception, performance, movement, and neuroscience: The importance of constructing transfer function autoregressive models. *Behavior Research Methods*, 48, 783–802.

Debener, S., Minow, F., Emkes, R., et al. (2012). How about taking a low-cost, small, and wireless EEG for a walk? *Psychophysiology*, 49, 1617–21.

Dikker, S., Michalareas, G., Oostrik, M., et al. (2020). Crowdsourcing neuroscience: inter-brain coupling during face-to-face interactions outside the laboratory. *NeuroImage*, 117436.

Dikker, S., Wan, L., Davidesco, I., et al. (2017). Brain-to-brain synchrony tracks real-world dynamic group interactions in the classroom. *Current Biology: CB*, 27, 1375–80.

Dmochowski, J.P., Bezdek, M.A., Abelson, B.P., et al. (2014). Audience preferences are predicted by temporal reliability of neural processing. *Nature Communications*, 5, 4567.

Dumas, G., Chavez, M., Nadel, J., et al. (2012). Anatomical connectivity influences both intra- and inter-brain synchronizations. *PLoS One*, 7, e36414.

Dumas, G., Kelso, J.A., Nadel, J. (2014). Tackling the social cognition paradox through multi-scale approaches. *Frontiers in Psychology*, 5, 882.

Dumas, G., Lachat, F., Martinerie, J., et al. (2011). From social behaviour to brain synchronization: review and perspectives in hyperscanning. *IRBM*, 32, 48–53.

Dumas, G., Nadel, J., Soussignan, R., et al. (2010). Inter-brain synchronization during social interaction. *PLoS One*, 5, e12166.

Fairhurst, M., Dumas, G. (2019). Reciprocity and alignment: quantifying coupling in dynamic interactions.

Fallani, F.D.V., Nicosia, V., Sinatra, R., et al. (2010). Defecting or not defecting: how to “read” human behavior during cooperative games by EEG measurements. *PLoS One*, 5, e14187.

Gallotti, M., Frith, C.D. (2013). Social cognition in the we-mode. *Trends in Cognitive Sciences*, 17, 160–65.

Goldstein, P., Weissman-Fogel, I., Dumas, G., et al. (2018). Brain-to-brain coupling during handholding is associated with pain reduction. *Proceedings of the National Academy of Sciences of the United States of America*, 115, E2528–37.

Gramfort, A., Luessi, M., Larson, E., et al. (2013). MEG and EEG data analysis with MNE-Python. *Frontiers in Neuroscience*, 7, 267.

Guevara, M.A., Corsi-Cabrera, M. (1996). EEG coherence or EEG correlation? *International Journal of Psychophysiology*, 23, 145–53.

Hari, R., Kujala, M.V. (2009). Brain basis of human social interaction: from concepts to brain imaging. *Physiological Reviews*, 89, 453–79.

Hasson, U., Ghazanfar, A.A., Galantucci, B., et al. (2012). Brain-to-brain coupling: a mechanism for creating and sharing a social world. *Trends in Cognitive Sciences*, 16, 114–21.

Hasson, U., Nir, Y., Levy, I., et al. (2004). Intersubject synchronization of cortical activity during natural vision. *Science*, 303, 1634–40.

Hipp, J.F., Hawellek, D.J., Corbetta, M., et al. (2012). Large-scale cortical correlation structure of spontaneous oscillatory activity. *Nature Neuroscience*, 15, 884–90.

Hoehl, S., Markova, G. (2018). Moving developmental social neuroscience toward a second-person approach. *PLoS Biology*, 16, e3000055.

Holper, L., Scholkmann, F., Wolf, M., (2012). Between-brain connectivity during imitation measured by fNIRS. *Neuroimage*, 63, 212–22.

Hunter, J.D. (2007). Matplotlib: a 2D graphics environment. *Computing in Science & Engineering*, 9, 90–95.

Jas, M., Engemann, D., Raimondo, F., et al. (2016). Automated rejection and repair of bad trials in MEG/ EEG. In: *6th International Workshop on Pattern Recognition in Neuroimaging (PRNI)*.

Jiang, J., Dai, B., Peng, D., et al. (2012). Neural synchronization during face-to-face communication. In: *Journal of Neuroscience*, 32, 16064–69.

Jiang, J., Chen, C., Dai, B., et al. (2015). Leader emergence through interpersonal neural synchronization. *Proceedings of the National Academy of Sciences*, 112, 4274–79.

King-Casas, B., Tomlin, D., Anen, C., et al. (2005). Getting to know you: reputation and trust in a two-person economic exchange. *Science*, 308, 78–83.

Koike, T., Tanabe, H.C., Okazaki, S., et al. (2015). Neural substrates of shared attention as social memory: A hyperscanning functional magnetic resonance imaging study. *NeuroImage*, 125, 401–12.

Konvalinka, I., Bauer, M., Stahlhut, C., et al. (2014). Frontal alpha oscillations distinguish leaders from followers: multivariate decoding of mutually interacting brains. *Neuroimage*, 94, 79–88.

Leong, V., Byrne, E., Clackson, K., et al. (2017). Speaker gaze increases information coupling between infant and adult brains. *Proceedings of the National Academy of Sciences of the United States of America*, 114, 13290–95.
Leong, V., Schilbach, L. (2019). The promise of two-person neuroscience for developmental psychiatry: using interaction-based sociometrics to identify disorders of social interaction. *The British Journal of Psychiatry*, **215**, 636-38.

Lindenberger, U., Li, S.-C., Gruber, W., et al. (2009). Brains swinging in concert: cortical phase synchronization while playing guitar. *BMC Neuroscience*, **10**, 22.

Leong, V., Byrne, E., Clackson, K., et al. (2017). Speaker gaze increases information coupling between infant and adult brains. *Proceedings of the National Academy of Sciences of the United States of America*, **114**, 13290-95.

Liu, T., Pelowski, M. (2014). Clarifying the interaction types in two-person neuroscience research. *Frontiers in Human Neuroscience*, **8**, 276.

Lowet, E., Roberts, M.J., Bonizzi, P., et al. (2016). Quantifying neural oscillatory synchronization: a comparison between spectral coherence and phase-locking value approaches. *PLoS One*, **11**, e0146443.

Markova, G., Nguyen, T., Hoehl, S. (2019). Neurobehavioral interpersonal synchrony in early development: the role of interactional rhythms. *Frontiers in Psychology*, **10**, 2078.

Matusz, P.J., Dikker, S., Huth, A.G., et al. (2019). Are we ready for real-world neuroscience? *Journal of cognitive neuroscience*, **31**, 327-38.

McKinney, W. (2010). Data structures for statistical computing in python. In: *Proceedings of the 9th Python in Science Conference*. Austin, TX, 51-56.

Mehrkanoon, S., Breakspear, M., Britz, J., et al. (2014). Intrinsic coupling modes in source-reconstructed electroencephalography. *Brain Connectivity*, **4**, 812-25.

Montague, P.R., Berns, G.S., Cohen, J.D., et al. (2002). Hyperscanning: simultaneous fMRI during linked social interactions. *NeuroImage*, **16**, 1159-64.

Müller, V., Lindenberger, U. (2014). Hyper-brain networks support romantic kissing in humans. *PLoS One*, **9**, e112080.

Nolte, G., Bai, O., Wheaton, L., et al. (2004). Identifying true brain interaction from EEG data using the imaginary part of coherency. *Clinical Neurophysiology: Official Journal of the International Federation of Clinical Neurophysiology*. **115**, 2292-2307.

Osaka, N., Minamoto, T., Yaoi, K. et al. (2014). Neural Synchronization During Cooperated Humming: A Hyperscanning Study Using fNIRS. *Procedia - Social and Behavioral Sciences*, **126**, 241-43.

Pan, Y., Novembre, G., Song, B. et al. (2018). Interpersonal synchronization of inferior frontal cortices tracks social interactive learning of a song. *NeuroImage*, **183**, 280-290.

Pedregosa, F., Varoquaux, G., Gramfort, A. et al. (2011). Scikit-learn: Machine learning in Python. *The Journal of Machine Learning Research*, **12**, 2825-30.

Perez Repetto, L., Jasmin, E., Fombonne, E. et al. (2017). Longitudinal Study of Sensory Features in Children with Autism Spectrum Disorder. *Autism Research and Treatment*, **2017**.

Pfeiffer, U.J., Timmermans, B., Vogeley, K., et al. (2013). Towards a neuroscience of social interaction. *Frontiers in Human Neuroscience*, **7**, 22.

Poulsen, A.T., Kamronn, S., Dmochowski, J., et al. (2017). EEG in the classroom: synchronised neural recordings during video presentation. *Scientific Reports*, **7**, 43916.

Price-Whelan, A.M., Sipőcz, B.M., Günther, H.M., et al. (2018). The Astropy Project: building an inclusive, open-science project and status of the v2.0 core package. *arXiv preprint arXiv:1801.02634*

Redcay, E., Schilbach, L. (2019). Using second-person neuroscience to elucidate the mechanisms of social interaction. *Nature Reviews. Neuroscience*, **20**, 495-505.

Sänger, J., Müller, V., Lindenberger, U. (2012). Intra- and inter-brain synchronization and network properties when playing guitar in duets. *Frontiers in Human Neuroscience*, **6**.

Schilbach, L., Timmermans, B., Reddy, V., et al. (2013). Toward a second-person neuroscience. *Behavioral and Brain Sciences*, **36**, 393-414.

Schippers, M.B., Roebroeck, A., Renken, R., et al. (2010). Mapping the information flow from one brain to another during gestural communication. *Proceedings of the National Academy of Sciences*, **107**, 9388-93.

Schreiber, T. (2000). Measuring information transfer. *Physical Review Letters*, **85**, 461.

Sebanz, N., Bekkering, H., Knoblich, G. (2006). Joint action: bodies and minds moving together. *Trends in Cognitive Sciences*, **10**, 70-76.

Shamay-Tsoory, S.G., Mendelsohn, A. (2019). Real-life neuroscience: an ecological approach to brain and behavior research. *Perspectives on Psychological Science: A Journal of the Association for Psychological Science*, **14**, 841-59.

Shaw, J.C. (1984). Correlation and coherence analysis of the EEG: a selective tutorial review. *International Journal of Psychophysiology*, **1**, 255-66.

Shea, N., Boldt, A., Bang, D., et al. (2014). Supra-personal cognitive control and metacognition. *Trends in Cognitive Sciences*, **18**, 186-93.

Stam, C.J., Nolte, G., Daffertshofer, A. (2007). Phase lag index: assessment of functional connectivity from multi channel EEG and MEG with diminished bias from common sources. *Human Brain Mapping*, **28**, 1178-93.

Stephens, G.J., Silbert, L.J., Hasson, U. (2010). Speaker-listener neural coupling underlies successful communication. *Proceedings of the National Academy of Sciences*, **107**, 14425-30.

Tang, H., Mai, X., Wang, S., et al. (2016). Interpersonal brain synchronization in the right temporo-parietal junction during face-to-face economic exchange. *Social Cognitive and Affective Neuroscience*, **11**, 23-32.

Thompson, E., Varela, F.J. (2001). Radical embodiment: neural dynamics and consciousness. *Trends in Cognitive Sciences*, **5**, 418-25.

Tognoli, E., Lagarde, J., DeGuzman, G.C., et al. (2007). The phi complex as a neuromarker of human social coordination. *Proceedings of the National Academy of Sciences*, **104**, 8190-95.

Toppi, J., Borghini, G., Petti, M., et al. (2016). Investigating cooperative behavior in ecological settings: an EEG hyperscanning study. *PLoS One*, **11**, e0154236.

Virtanen, P., Gommers, R., Oliphant, T.E., et al. (2020). SciPy 1.0: fundamental algorithms for scientific computing in Python. *Nature methods*, **17**, 261-72.

Winkler, I., Debener, S., Müller, K.-R., et al. (2015). On the influence of high-pass filtering on ICA-based artifact reduction in EEG-ERP. In: *2015 37th Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC)*. IEEE, p. 4101-05.

Zamm, A., Debener, S., Bauer, A.-K.R., et al. (2018). Amplitude envelope correlations measure synchronous cortical oscillations in performing musicians: amplitude envelopes measure inter-brain synchrony. *Annals of the New York Academy of Sciences*, **1423**, 251-63.