## 1. Introduction

Over the past decades, a paradigm shift has taken place in studying the human brain, moving from a local to a more network-based perspective, giving rise to the field of network neuroscience. This evolution has, in part, been driven by the concept of graphs in math. A graph (network) consists of a set of vertices (nodes), which are connected by edges (links). In neuroimaging-based network neuroscience, brain regions identified by any given method of parcellation are considered the nodes of the network, while links can either be defined as white matter connections between brain regions (structural networks) or as statistical interdependencies between the time series of brain regions (functional networks) (Bondy and Murty, 2008; Fair et al., 2009; Power et al., 2010; Rubinov and Sporns, 2010; Sporns, 2010, 2012; Fornito et al., 2016).

Mesoscopic structures or groups formed by interactions between nodes of a network, called modules, clusters or communities, can be quantified by a variety of detection methods (Fortunato, 2010). Nodal interactions are typically represented by an adjacency matrix (*A*) of the network, where each element *i, j* of *A* (called *a*_{ij}) is the weight of the connection or strength of interaction between nodes i and j. Modules are usually determined based on the general idea of maximizing the number/weight of within-group and minimizing the number/weight of between-group links. Modules can then be considered as entities in the network that can be modified individually without affecting the rest of the network. Modularity measures have been shown to be useful as a biomarker of disease, including epilepsy (Chavez et al., 2010), Alzheimer’s disease (Brier et al., 2014), schizophrenia, bipolar, and major depressive disorder (Ma et al., 2020). However, brain modularity has also been associated with normal variation in cognition: Individuals with lower whole-brain modularity performed better in complex tasks, while those with higher modularity showed an advantage in simple tasks (Yue et al., 2017). Whereas the ‘static’ community detection methods employed in the above-mentioned studies consider the brain’s connectivity averaged over time (based on only one adjacency matrix per subject as a single-layer network), other methods have assessed changes in community structure over time (Meunier et al., 2009; Newell et al., 2009; Bassett et al., 2011; Calhoun et al., 2014; Alavash et al., 2015; Sporns and Betzel, 2016). These dynamic approaches take into account that a node can frequently change its connections depending on which state the brain is in, both during resting-state (RS) and during the performance of tasks. Here, changes in modular structure are captured by a sequence of adjacency matrices (*A*_{t}), thus creating multi-layer networks. The adjacency matrices are typically calculated using a sliding-window approach on nodal time series, in which the window length reflects the time scale of interest (Fornito et al., 2016). Subsequently, dynamic module detection methods can be applied to these time-dependent multi-layer networks to not only characterize changes of modules over time, but also to determine how nodes change their affiliation [the module/group they belong to] as a function of time. The latter can be thought of as the flexibility of a node (Bassett et al., 2011; Betzel and Bassett, 2017) and is defined based on the consecutive presence of nodes in different modules over time (Meunier et al., 2010; Calhoun et al., 2014). These measures of flexibility enable us to track time-dependent changes and thereby track phenomena of both integration and segregation in the brain (Bassett et al., 2011; Braun et al., 2015). It offers the opportunity to study which brain nodes are more likely to change their affiliation over time and thereby which brain regions are rather consistently associated with a certain brain module, forming a backbone for the constantly changing network. For example, a recent study by Harlalka et al. (2019) suggested higher symptom severity in autism spectrum disorder to be associated with more connectivity flexibility in visual and sensorimotor areas during rest. Braun et al. (2015) demonstrated that individuals with more connectivity flexibility in frontal cortices have enhanced memory performance and score better on neuropsychological tests measuring cognitive flexibility, suggesting that dynamic network reconfiguration may form a fundamental mechanism underlying executive function. For a broader discussion on modularity and flexibility findings, see Karwowski et al. (2019).

A data driven widely used method to calculate brain network flexibility is based on the Louvain community detection algorithm by Blondel et al. (2008). This algorithm aims to optimize the variable *Q*, initially introduced for a single layer network by Newman (2006), and later modified for multi-layer networks by others (Mucha et al., 2010; Bazzi et al., 2016; Vaiana and Muldoon, 2018).

More specifically: Where *A* is the Adjacency matrix of the network, *A*_{ijs} is the weight of connection between nodes *i* and *j* in layer *s*. γ_{s} is the resolution parameter for layer *s*, *i* and *j* are indices of nodes, and *s* and *r* indices of layers. *k*_{is} is the degree of node *i* in layer *s*. *m*_{s} is proportional to the sum of weights in layer *s*. *C*_{jsr} refers to the connection of node *j* to itself in different layers. *c*_{is} is the defined module/cluster of node *i* in layer *s*. Finally, *Q* captures how good the grouping is compared to a null-model (here random).

Although, this and similar methods have undoubtedly contributed to our understanding of brain dynamics, these come with a cost: Given the random nature of algorithms like Louvain, the resulting clusters may differ each time the algorithm is run on the same adjacency matrix. As such, brain modules show variation within and across participants, which is overcome by running the algorithm multiple times to reach a consensus on the modular structure (Lancichinetti and Fortunato, 2012). However, this can be a computationally expensive process, while the identified modules may in the end have low biological plausibility or at least cannot be interpreted straightforwardly.

Here, we introduce a new method to capture nodal flexibility and brain network reconfiguration using a fast and intuitive method based on a set of template modules. This offers three main advantages over the existing methods:

1. It is computationally more efficient and deterministic compared to the Louvain (and similar) algorithm.

2. It offers high replicability, as it uses the same set of module templates for all subjects and time scales. This ensures comparability between subjects and studies, which is one of the current concerns in the field (Hallquist and Hillary, 2018).

3. It gives researchers the opportunity to choose the best-fitting, or biologically most relevant module templates for each study.

Although the exact computational complexity of the Louvain algorithm is not mentioned in the literature, it is suggested to be essentially linear in the number of links in the graph (Lancichinetti and Fortunato, 2009). But the complexity mentioned is regarding the one time run of the greedy algorithm. The Louvain algorithm starts with assigning a distinct community to each network node. In the initial phase then, there are as many communities as nodes. It then evaluates the gain in modularity [difference between Q values for different cases] that would result from removing each node i from its community and placing it in the community of j for each of its neighbors j. The i-th node is then placed in the community with the greatest positive gain. If there is no positive gain, node i remains in its original community. This process is repeated until no further improvement is possible, at which point the first phase is finished. This first phase concludes when a local modularity maximum is reached and no individual move can improve modularity. The output of the algorithm is dependent on the order in which the nodes are considered. The second phase of the algorithm involves the construction of a new network whose nodes are the communities discovered in the first phase. To accomplish this, the weights of the links between the new nodes are determined by adding the weights of the links between nodes in the respective two communities. In the new network, links between nodes of the same community result in self-loops for this community. Once this second phase is complete, the algorithm’s initial phase can be reapplied to the resulting weighted network again. This 2-phase process is repeated until there are no more modifications and maximum modularity is achieved. A partitioning of the network is achieved through this process of repeating the 2-phase until the Q cannot be improved, but to find a reliable final representative partition that doesn’t depend on the order in which the algorithm chooses the nodes, this whole process is repeated several times until a consensus is reached (Blondel et al., 2008). On the other hand, our template-based method, gives the same deterministic value each time and does not need repetition or a consensus-finding step. We believe that the deterministic nature of the template-method can be interpreted as the intrinsic “efficiency factor”. The sum is always linear to the number of links and we need one time of adding the weights to find the total weight of connections to each module.

In this work we describe our proposed method in detail and apply it to a real-life dataset that was previously assessed using a Louvain-like locally greedy heuristic algorithm (Blondel et al., 2008; Braun et al., 2015). Compared to the previous work, we demonstrate that our method is equally successful in capturing a brain reconfiguration pattern that mimics the stimulation periods of an externally-cued working memory task, yet in our case can be directly related to well-known functional brain networks as well.

## 2. Methods

### 2.1. Concept and steps

Before going into mathematical detail, let us first explain the concept behind the method. Consider the brain as a network, in which each region of the brain (defined by any arbitrary parcellation) is a node, each co-activation between any two nodes is an edge, and each node belongs to an a-priori defined set of nodes, termed a module. As a first step, we consider that each node has an a-priori affiliation to one of the predefined template modules or in other words, belongs to an a-prioiri template module. The affiliation is determined as the template module with which each node has the largest spatial overlap. Next, the strengths of all edges between each node and all members of every module are summed. When a node is more strongly connected to nodes affiliated with another module than to nodes of its own predefined module, then this node will receive another affiliation than its a-priori one. This can now be extended to a dynamic scenario, in which node affiliations can be determined for a range of consecutive time points. Some nodes might change their affiliation over time, while others do not. The ratio of nodes changing affiliation with respect to all nodes is what we are interested in. We understand this ratio as a measure of flexibility of the brain. In other words, the more nodes switch affiliation between consecutive time points, the more flexibility in network dynamics we assume. See Figure 1 for a summary of these steps.

**Figure 1**. Schematic overview of the template-based flexibility method. **(A)** Each node has an a-priori affiliation to a template module, not allowing overlap. In this paper, we use the Brainnetome atlas for node definition (Fan et al., 2016) and the FIND Lab network templates as predefined modules [http://findlab.stanford.edu/; Shirer et al., 2012]. Importantly, matrix M, describing the a-priori module affiliation for each node, is predetermined and serves as a reference. **(B)** Using a sliding-window approach, an adjacency matrix is constructed for each time window by calculating Pearson correlation coefficients between the time series of all possible pairs of nodes. Then, for each node and time window the reference module receiving the highest normalized connection weight will serve as the new modular affiliation for that node in that time window. **(C)** Last, the number of affiliation changes between affiliation vector in *t* and its successive vector in *t* + 1 is defined as the flexibility *F*_{t} of the network between two time points. The average of *F*_{t} across participants (called $\overline{{F}_{t}}$) can be plotted for all consecutive time points (an example presented later in Figure 3).

The steps to calculate this flexibility measure are listed below in detail:

1. An a-priori affiliation is assigned to each node to form the following matrix M:

Where *N*_{reg} is the number of regions (nodes) and *N*_{mod} number of a-priori modules. Each row of this matrix belongs to a node and, in the first-approximation case in this paper, has only one non-zero element that indicates the a-priori modular affiliation of the node. For example, in row 1 the fourth column is 1, which means that the first node has an a-priori affiliation to template module 4.

Note that we assign all nodes that do not show any overlap with the template modules to a last, artificial module to not exclude these nodes in calculating the flexibility metric.

2. Next, for each node we extract the mean time series across all volumes of the fMRI scan. We then divide our time-series into smaller windows using a sliding-window approach. For each time window, an adjacency matrix is constructed using Pearson correlation coefficients between all possible node pairs. The adjacency matrix at time-window *t* is defined as *A*_{t} of shape *N*_{reg} × *N*_{reg}:

3. Now, we want to calculate how each node is connected to the nodes that are the predefined members of each of the template modules, as defined in *M*. To this end, we sum the absolute values of all the weights from one node to all the nodes affiliated to each of the modules, so that each node has *N*_{mod} [in our subsection 2.2 analysis: 15] different values (one weighted sum for links to each module), indicating the strength of its links with the predefined members of each of the template modules. In mathematical terms, we calculate the matrix *S*′ as follows:

where |*A*|_{t} matrix elements are the absolute values of *A*_{t} elements and the matrix has the dimension *N*_{reg} × *N*_{reg}. Row i of *S*′ belongs to the region *i* and each column *j* shows the sum of absolute connection weights of *i* to the members of *j*-th module. As the predefined modules differ in size, the *S*′ matrix elements are then normalized to the number of regions affiliated by template definition to the modules, creating a new matrix called *S* [dividing each matrix element ${S}_{ij}^{\prime}$ by the number of regions affiliated to the *j*th template module]. Importantly, to be able to compare the elements of *S*, we normalize it in a way that the sum of each row is one. This normalization step has no effect on the output of the next steps but is rather to increase the interpretability at this stage. The normalized numbers thus represent which portion of each node’s connections is to which module. We call this new matrix, $\overline{S}$.

4. With $\overline{S}$, we have the ratio of affiliations to each module calculated for all nodes. From these, the strongest module affiliation per node is chosen as the winner which together form an affiliation vector for time window t; we call this vector Ω_{t}:

where $ArgMax({\overline{S}}_{i*})$ points to the name/number (argument) of the winner module in row i of matrix $\overline{S}$.

5. Following steps 2-4 for consecutive time windows, we calculate one Ω_{t} for each window t. The *flexibility* of the network denoted by *F* is then defined as the ratio of regions that change their affiliation from one window to the next to the total number of network regions, or:

where ω denotes an element of vector Ω. The Kronecker delta ${\delta}_{{\omega}_{i}^{s},{\omega}_{j}^{t}}$ is 1 if ${\omega}_{i}^{s}={\omega}_{j}^{t}$ and 0 otherwise. The ∑ then counts the number of nodes that did not change their affiliation between windows *t* and *t* + 1. Note that as a side-product of calculating Ω, we can output a vector describing the affiliations over time for each node separately as well by making a vector of the same element in Ω_{t = 1, ..,Nt}:

Where *N*_{t} is the total number of time windows. This output can be used for further region-specific analysis.

6. Where we apply the method to real-life data (see subsection 2.2) we also calculate the average *flexibility* over time for a sample (cohort of subjects), ${\overline{F}}_{t}$, by simply summing the flexibility over all participants and divide it by the sample size (*N*_{sub}).

### 2.2. Application on a previously studied dataset

In our application study, we used 331 participants of the 344 participants included in Braun et al. (2015): Thirteen subjects were excluded due to scanning artifacts, exceeding movement or insufficient image quality. Functional MRI data were acquired at three sites during performance of an N-back task: the Life and Brain Center of the University of Bonn, the Central Institute of Mental Health Mannheim, and Charité – Universitätsmedizin Berlin. The study was approved by the Medical Ethics Committee of the three study sites and all participants provided written informed consent. At all sites, a Siemens Trio 3T MRI scanner (Siemens Healthcare, Erlangen, Germany) was used with identical sequences: gradient-echo EPI, 28 slices, slice thickness 4mm (1mm gap), field of view 192 x 192 x 140 mm, acquisition matrix 64 x 64, TR (repetition time) 2s, TE (echo time) 30 ms, flip angle 80°. The task was presented in a blocked fashion. Four blocks of 0-back and 2-back each (30s duration) were alternated, starting with the 0-back condition. Participants were asked to either press the button corresponding to the number shown on the screen (0-back) or the number that was shown 2 steps ago (2-back). See Figure 2 for more information on the task. Python packages nilearn, Scikit-learn and matplotlib are used for visualization purposes in this manuscript (Hunter, 2007; Pedregosa et al., 2011). Standard preprocessing was conducted using SPM8 (Penny et al., 2011) and included motion correction (participants with >3mm translation and >1.7° rotation between volumes were excluded), slice-time correction, spatial smoothing with a FWHM of 9 mm, high-pass temporal filtering with a 128s cutoff, and normalization to the Montreal Neurological Institute (MNI) template space with 3 mm isotropic voxel size. A detailed description of data acquisition and preprocessing is provided in Esslinger et al. (2009). Mean time-courses of the 246 Brainnetome Atlas regions (Fan et al., 2016) were extracted from the preprocessed data of the 331 subjects. In line with Braun et al. (2015), a 15-volume window length with 14 volumes overlap was chosen for the sliding-window analysis (Figures 2C, D), generating in total 114 windows for each subject. For every window, we calculated an adjacency matrix using Pearson correlation coefficients between all possible pairs of the 246 regions mean time series [using scipy.stats.pearsonr Virtanen et al. (2020)]. Considering that the N-back working memory task consisted of 30 s alternating blocks of 0-back and 2-back, the 15-volume window (30 s length) allows for one window purely reflecting a single condition block. For more information on selection of the window length see Braun et al. (2015) and Leonardi and Ville (2015).

**Figure 2**. Task and signals. **(A)** Example of the N-back working memory task with a 0-back and 2-back condition, during which participants were asked to choose the value that was either shown at the current step or 2 steps ago, respectively. **(B)** Four blocks of each condition were presented in alternated fashion for 30 s. **(C)** After preprocessing, mean time courses were extracted from 246 Brainnetome atlas regions (Fan et al., 2016). **(D)** Windowed time series were extracted using a sliding-window approach, moving a window of 15 time points over the time series one volume at a time.

The a-priori modules (Matrix M) were selected based on 14 well-described functional connectivity template networks (modules) in Shirer et al. (2012) by the FIND lab (http://findlab.stanford.edu/). As described before, a 15th (artificial) module was added comprising all atlas regions that did not overlap with any of the 14 template networks. The a-priori affiliations of all atlas regions can be found in Table 1 and the labels of the FIND lab templates in Table 2.

**Table 1**. Region a-priori Affiliation, columns marked “R” are region numbers and “M” columns are a-priori modular affiliations.

To obtain a broader view of the meso-scale dynamics, the modular allegiance matrix T and integration matrix R were calculated using the methods from Braun et al. (2015). Each element *t*_{i,j} of modular allegiance matrix T shows the ratio of windows where node i and j were present in the same module relative to all windows. To calculate the T for each condition, we separated windows with 80% of their time-points in one condition and ignored the others.

To calculate the integration matrix R with elements *r*_{k,l}, which show the strength of co-working between modules k and l, when we have *N*_{mod} modules {*M*_{1}, *M*_{2}, …*M*_{Nmod}}, we first use all the T matrix elements [link between two regions] with one end (region) in module k and the other end (region) in module l to extract I matrix elements (*i*_{k,l}). It can be written as:

where k and l are two modules, |*M*_{k}| shows the size of module *M*_{k}. Then we normalize the I elements with division by internal connections of both modules and call the resulting elements elements of matrix R:

R is the integration matrix.

## 3. Results

Figure 3A shows the N-back flexibility pattern across all nodes from Braun et al. (2015), while Figure 3B shows the pattern generated by our method when applied to the same dataset (331/344 subjects of the same sample). Similar to Figure 3A, the peaks illustrate maximum flexibility of the brain during performance of both the 0- and 2-back condition. In contrast, the transitions between the two task conditions coincide with troughs when applying our method, whereas Braun et al. (2015) described additional, yet smaller peaks during these transition phases when using the generalized Louvain algorithm. On average, higher flexibility is observed during the 2-back than 0-back blocks, although the difference is relatively small (*t* = −2.9, *p* = 0.03).

**Figure 3**. Comparison of flexibility generated by the generalized Louvain-like locally greedy heuristic algorithm (Blondel et al., 2008; Jeub et al., 2022) and the template-based method during an N-back working memory task. **(A)** Flexibility plot from Braun et al. (2015) illustrating the probability that a brain region changes its modular allegiance between two consecutive windows in a sample of 344 healthy subjects. The original plot is used with permission of the publisher. **(B)** Flexibility plot generated by the template-based method. Here, the flexibility number in each time-window is the fraction of regions that change their affiliation from one time window to the next (i.e., the number of changed regions divided by the total number of nodes). The plots are generated using a subset of 331 subjects from the same cohort as used in Braun et al. (2015). Note that in both plots a time window covers 15 EPI volumes with a TR of 2 s, corresponding to a window length of 30 s. The window was shifted with one volume at a time, allowing for 14 EPI volumes overlap between consecutive windows, which yielded 114 windows in total.

In addition to calculating flexibility across all nodes, we can use the information captured in the fifth step to describe the affiliation changes of each individual node. This allows us to have a closer look at which nodes switch their affiliation over time most frequently, or at how often the a-priori constituents of each of the template networks switch their affiliation. Figure 4 illustrates how many times each node (Brainnetome regions in our analysis) switches its affiliation between two consecutive windows. Note that the number of switches was normalized to the number of switches performed by the node that switched most frequently, forcing the latter node to have a value of 1 and the other nodes to have a value between 0 and 1. Nodes within the prefrontal cortex predominantly show affiliation changes over time during execution of the N-back task. This is in agreement with the previous findings (Owen et al., 2005; Cao et al., 2014; Braunlich et al., 2015; Minamoto et al., 2015).

**Figure 4**. Brainnetome atlas brain regions switching. Number of affiliation switches between consecutive windows for regions of the Brainnetome Atlas, averaged across all subjects and normalized to the most frequently switching node to yield values between 0 and 1. The visualized regions are those with values higher than 0.7.

One level coarser at the module level, we can look at the average switching ratio of template modules. The boxplots in Figure 5 demonstrate for each of the FIND lab template modules how often their a-priori defined constituent nodes on average switch their modular affiliation over time across participants. Additional statistical analysis for modules in Figure 5 is provided in Figure 6. Constituent nodes of the default mode network (DMN), salience network (SN), left and right executive control network (L/RECN), and language network seemingly switch their affiliation most often during execution of the N-back task.

**Figure 5**. Findlab brain areas switching. **(A)** Average number of affiliation switches between consecutive windows for each FIND lab template network, averaged across all subjects. Abbreviations are listed in Table 2. **(B)** Illustration of the four template networks for which its constituent nodes demonstrated the highest flexibility [http://findlab.stanford.edu/; Shirer et al. (2012)]. See Figure 6 for more statistics.

**Figure 6**. Additional statistics for Figure 5. Independent t and p values between boxplot modules in Figure 5, shown as [t-value, p-value]. The last column called “Comp. w Rest” calculates the t-test between the specific module and the whole brain. For visualization purpose the table is cut to two parts.

Figure 7 shows the result of modular allegiance and integration analysis. We observe a general increase in integration values in 2-back compared to 0-back except for three modules. This overall increase in integration is in agreement with previous findings (Finc et al., 2020).

**Figure 7**. Modular allegiance and integration. Diagonal elements of the matrices are set to be zero. **(A)** Modular allegiance of the two conditions 2-back and 0-back; to calculate a T matrix for one condition, we used only the windows with 80% of their time-points in that condition. **(B)** Integration matrix for 0-back and 2-back. **(C)** Change in the integration values *R*_{2−back} − *R*_{0−back} (left plot) and sum of rows (from the left plot matrix) as each modules integration value (right plot).

## 4. Discussion

In this work we introduce a new method to assess flexibility in analyses of dynamic functional connectivity. In the application section we set out to compare our method against the currently most used data-driven method described in Braun et al. (2015), in which the computationally more expensive generalized Louvain algorithm was applied to derive the modular structure of the data (Blondel et al., 2008; Mucha et al., 2010; Bassett et al., 2011; Jeub et al., 2022). See Figure 8 for a schematic comparsion of steps in standard vs. template flexibility calculations. We demonstrate that our method is able to reveal a flexibility pattern during the N-back working memory task that is highly similar to the pattern found in Braun et al. (2015). The most notable difference between the results obtained with our method and the Louvain algorithm was the absence of the small increase in flexibility during the transition of the 0- and 2-back blocks. Braun et al. (2015) interpret this to reflect “dual-task” performance. We suggest an alternative explanation based on the current results: increased flexibility may be needed for switching tasks at the start of each new condition block (shown as a delayed peak in the middle of the marked blocks), while less flexibility may be needed during prolonged execution of the task in each block (shown as a delayed trough exactly in between blocks). As such, the periods of lower flexibility may show the preferred brain configuration for the execution of the task blocks. A further more theoretical analysis of a simulated BOLD signal with block induced inputs might be helpful in interpreting the dual-task vs. no-dual-task hypothesis.

**Figure 8**. Schematic steps to calculate dynamical flexibility. The time series are extracted from brain scans. Selected sliding windows are used to generate adjacency/connectivity matrices. The groups/clusters/modules are found in each matrix^{*} using a feasible clustering method. In this step, the method of choice can be a well-known method like the optimization of Newman’s modularity Q using greedy Louvain algorithm or it can be our template-based method that considers the a-priori information about brain as pre-assumption. Finally the assigned affiliations in windows are compared and the differences are found. ^{*}In some methods, different sliding window matrices are put together to make a multi-layer network and then an adjusted version of modularity optimization is employed to find module through all layers.

As has been shown abundantly in the literature, the prefrontal cortex plays an important role in the performance of working-memory tasks (Owen et al., 2005; Cao et al., 2014; Braunlich et al., 2015; Minamoto et al., 2015). Therefore, it is not surprising that we found nodes in the prefrontal cortex to show the most flexible behavior during execution of the N-back task. Moreover, at the modular level we see the highest flexibility in nodes that have an a-prori affiliation to the DMN, SN, L/RECN and language modules. The DMN is known to have an antagonistic relation with fronto-parietal networks, such as the L/RECN: when the latter is more active during cognitively demanding tasks (such as the N-back) the DMN is less active (Fox et al., 2005). Interestingly, a key role has been assigned to the SN in allocating neural resources between more internally (DMN) or externally (ECN) oriented processes (Uddin et al., 2011). Taken together, we see these results as further proof of our method’s validity.

We discussed above how our method could be used to assess flexibility. That is, both on the network (module) level and at the regional (node) level, thereby extending the inferential potential compared to the other widely-used algorithms. However, our analytical procedure also offers possibilities for more fine-grained investigations of modular affiliations. In the description of our method and application analysis we determined the modular affiliation for a particular node and window as the module with which the node demonstrated the strongest connectivity in the affiliation vector. Although this is arguably the easiest and most pragmatic choice, it would also be possible to use the weighted affiliation with each of the template modules in the affiliation vector [Method section, step 3] to assess flexibility. Such a weighted approach may ultimately prove to be even more informative in characterizing brain flexibility. Another limitation of our method appears in the limits of a-priori module sizes. If the template modules are significantly different in size, a single division to the size of each module is not enough to account for the difference in the size of modules. In theory, one can define two a-priori modules of size 1 and *N*_{reg} − 1, but such a template definition would result in a flexibility which is very sensitive to the connection weights from that one single node. In spite of this, additional analysis revealed a comparable but not easily interpretable flexibility result if the nodes are randomly assigned to another similar-size a-priori module set and if, in a simplified case, the Pearson distance between different windows is used as a measure of flexibility [see chapter 6 of Chinichian (2022) for details]. This demonstrates that, in a larger context, the connectivity changes between successive windows can be tracked even before using a template. The researcher’s choice of template provides an additional degree of freedom to find a suitable match for the research question. It allows researchers to focus on a subset of nodes that are relevant relative to the rest of the network, but it also introduces the limitation that results from different template selections may not be easily comparable. We recommend that every report on the template flexibility should include the exact template details [similar to Table 1] to allow for a fair interpretation of the results.

The current manuscript, focuses on the block-designed task fMRI which provides a fairly easy-to-interpret and comprehensible application case. A further investigating of resting-state fMRI and the changes in the flexibility during rest could provide more insight to the different aspects of this method. A study of resting-state fMRI from 95 subjects meeting criteria for Major Depressive Disorder and/or common anxiety disorders from the Netherlands Study of Depression and Anxiety (NESDA) is in preparation by a collaborator team (Dickhoff, 2022).

In conclusion, the method proposed in the current study is able to generate flexibility results that are highly comparable to the results obtained with a more sophisticated data-driven method. Besides having a much higher computational efficiency, our method also promotes replicability across different samples and studies through the use of biologically plausible template modules. We believe that our approach can be a feasible choice for researchers aiming to study dynamical reconfiguration at multiple scales of the brain, be it nodes, modules, or the brain as a whole.

## Data availability statement

The data analyzed in this study is subject to the following licenses/restrictions: Special permission is required from the project leaders. Participants’ fMRI data is to be treated as confidential. Requests to access these datasets should be directed to Henrik.Walter@charite.de.

## Ethics statement

The studies involving human participants were reviewed and approved by Life and Brain Center of the University of Bonn, the Central Institute of Mental Health Mannheim, and Charité – Universitätsmedizin Berlin Medical Ethics Committee. The patients/participants provided their written informed consent to participate in this study.

## Author contributions

NC designed the method, the computational framework, analyzed the data, and wrote the manuscript. PR extracted the average time-series from the pre-processed data. IV and HW supervised the project. IV, HW, and JK contributed to research design and discussions of the manuscript. All authors discussed the results and commented on the manuscript.

## Acknowledgments

This study was supported by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation)- SPP2041, WA 1539/9-1/SPP2031, WA 1539/11-1, ERK 724/4-1, and 337619223/RTG2386. We thank Prof. Eckehard Schöll and Tilo Schwalger from TU Berlin together with their group members for their constructive contributions to improve this method and manuscript. We acknowledge support by the German Research Foundation and the Open Access Publication Fund of TU Berlin.

## Conflict of interest

The authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

## Publisher’s note

All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.

## Footnotes

## References

Alavash, M., Hilgetag, C. C., Thiel, C. M., and Giessing, C. (2015). Persistency and flexibility of complex brain networks underlie dual-task interference. *Hum. Brain Mapp*. 36, 3542–3562. doi: 10.1002/hbm.22861

Karwowski, W., Vasheghani Farahani, F., and Lighthall, N. (2019). Application of graph theory for identifying connectivity patterns in human brain networks: a systematic review. *Front. Neurosci*. 13, 585. doi: 10.3389/fnins.2019.00585