Navigating through space and time: A methodological approach to quantify spatiotemporal connectivity using stream flow data as a case study

The growing interest in combining spatial and temporal patterns in nature has been fostered by the current availability of high‐frequency measurements. However, we still lack a methodological framework to process and interpret spatiotemporal datasets into meaningful values, adaptable to different time windows and/or responding to different spatial structures. Here, we developed and tested a framework to evaluate spatiotemporal connectivity using two new measures: the spatiotemporal connectivity (STcon) and the spatiotemporal connectivity matrix (STconmat). To obtain these measures, we consider a set of spatially connected sites within a temporally dynamic network. These measures are calculated from a spatiotemporal matrix where spatial and temporal connections across sites are captured. These connections respond to a determined network structure, assign different values to these connections and generate different scenarios from which we obtain the spatiotemporal connectivity. We developed these measures by using a dataset of stream flow state spanning a 513‐day period obtained from data loggers installed in seven temporary streams. These measures allowed us to characterise connectivity among stream reaches and relate spatiotemporal patterns with macroinvertebrate community structure and composition. Spatiotemporal connectivity differed within and among streams, with STcon and STconmat capturing different hydrological patterns. Macroinvertebrate richness and diversity were higher in more spatiotemporally connected sites. Community dissimilarity was related to STconmat showing that more spatiotemporally connected sites had similar communities for active and passive dispersers. Interestingly, both groups were related to spatiotemporal connectivity patterns for some of the analysed scenarios, highlighting the relevance of spatiotemporal connectivity in dynamic systems. As we exemplified, the proposed framework can help to disentangle and quantify spatiotemporal dynamics or be applied in the conservation of dynamic systems such as temporary streams. However, the current framework is not limited to the temporal and spatial features of temporary streams. It can be extended to other ecosystems by including different time windows and/or consider different network structures to assess spatiotemporal patterns. Such spatiotemporal measures are especially relevant in a context of global change, with the spatiotemporal dynamics of ecosystems being heavily disrupted by human activities.

Metapopulations, metacommunities and meta-ecosystems have been generally assessed using a snapshot approach that assumes temporal stability (Holyoak et al., 2020;Uroy et al., 2021). In the specific case of metacommunities, most studies have considered spatial or temporal connectivity individually while communities experience both temporal and spatial variation in connectivity affecting populations (Kurihara, 2007), communities Dong et al., 2017) and ecological processes (Ding et al., 2013;Sadchatheeswaran et al., 2021). Whereas spatial connectivity refers to how communities are connected within a landscape (Moritz et al., 2013), temporal connectivity refers to how communities are connected in time, for example, across multiple years (Holyoak et al., 2020). Within this context, considering only one facet of connectivity can lead to misleading conclusions about the importance of landscape connectivity for the exchange of species between local communities (Castillo-Escrivà et al., 2020;Huang et al., 2020;Rasmussen et al., 2013). To date, few studies have assessed how connectivity changes simultaneously in space and time, defined here as spatiotemporal connectivity, and how these can affect natural systems (Fullerton et al., 2010;Uroy et al., 2021).
Some studies have used long-term datasets to assess the temporal variation of spatial processes through consecutive snapshot analyses Leppänen et al., 2019;Rouissi et al., 2014), but in these studies, the interaction between different time steps is not considered. In contrast, other studies (Huang et al., 2020;Martensen et al., 2017;Thompson et al., 2017) simultaneously consider the interaction between spatial and temporal dimensions by including the effect of connectivity through more Community dissimilarity was related to STconmat showing that more spatiotemporally connected sites had similar communities for active and passive dispersers.
Interestingly, both groups were related to spatiotemporal connectivity patterns for some of the analysed scenarios, highlighting the relevance of spatiotemporal connectivity in dynamic systems.
4. As we exemplified, the proposed framework can help to disentangle and quantify spatiotemporal dynamics or be applied in the conservation of dynamic systems such as temporary streams. However, the current framework is not limited to the temporal and spatial features of temporary streams. It can be extended to other ecosystems by including different time windows and/or consider different network structures to assess spatiotemporal patterns. Such spatiotemporal measures are especially relevant in a context of global change, with the spatiotemporal dynamics of ecosystems being heavily disrupted by human activities.

K E Y W O R D S
ephemeral streams, intermittent rivers, network structure, spatial connectivity, spatiotemporal graphs, temporal connectivity than one time step (e.g. the connectivity of a given time point has an effect on the next time points and this effect propagates in time).
However, few examples exist where spatial and temporal variation are simultaneously considered to estimate spatiotemporal connectivity (Uroy et al., 2021). The lack of a clear framework from which to calculate spatiotemporal connectivity values or assess different time windows (i.e. number of time steps considered to impact connectivity) is limiting the development of such approximations. Even though technologies to capture spatiotemporal connectivity changes are nowadays available, we still need a methodological framework for obtaining connectivity measures that integrate spatial and temporal patterns (Uroy et al., 2021).
Temporary river networks are suitable systems to analyse and develop a framework to assess spatiotemporal connectivity due to their high hydrological variability in space and time (Datry et al., 2014).
Spatially, fluvial systems are driven by an up-to downstream unidirectional flow following a dendritic structure which affects the distribution and presence of species (Altermatt, 2013;Altermatt et al., 2020;Borthagaray et al., 2020;Schmera et al., 2018). Temporally, they are subjected to a strong seasonal and/or interannual variation, with recurrent drying and flowing periods determining habitat availability Datry et al., 2016;Valente-Neto et al., 2020).
Finally, species inhabiting these systems have two different strategies to withstand drying and thus coping with spatiotemporal variability: resisting in situ as dormant stage (temporal dispersal) or recolonising from nearby refuges after flow resumption (spatial dispersal ;He et al., 2020;Heino, 2013;Sarremejane et al., 2020). These different ways of interacting with the landscape can be related to different network structures or dispersal abilities, thereby informing about changes in network connectivity Pineda-Morante et al., 2022;. Consequently, in temporary streams, spatiotemporal connectivity among communities is promoted by unidirectional or by multidirectional dispersal (Borthagaray et al., 2015;Seymour et al., 2015;. A unidirectional or directed network would be related to species that are aquatic obligates and that follow the stream dendritic structure to move from one site to another, hereafter passive dispersers. A multidirectional or undirected network would be related to species that can fly in all directions, with no need to follow the stream course, hereafter aerial dispersers. So far, flow data obtained using high-frequency temperature data loggers have been used to characterise the local hydrological conditions of temporary streams (e.g. drying duration, number of consecutive dry days, days with disconnected pools, days after flow return) and its effects on aquatic communities (Arias-Real et al., 2021;B-Béres et al., 2019;Beesley & Prince, 2010;Crabot et al., 2020). However, this information has not yet been used to develop spatiotemporal connectivity measures.
In this study, we developed a methodological framework to assess spatiotemporal connectivity focusing on Mediterranean streams as a case study. Using high-frequency data on water presence/absence from a set of temporary streams, we propose two measures of connectivity ( Figure 1): spatiotemporal connectivity (STcon) and spatiotemporal connectivity matrix (STconmat). STcon measures average site connectivity for each individual site and thus can be used as a predictor of community structural and functional metrics such as local species richness or Shannon-Wiener diversity. STconmat represents F I G U R E 1 Conceptual graphical representation of how the STcon and STconmat are calculated using the example of Vall d'Horta stream (VH). (a) The data loggers are deployed in the field and monitor the presence (i.e. wet) or absence (i.e. dry) of water. (b) These values are then presented in a flow state database where rows represent each time unit (i.e. 6 days, from T1 to T6) and columns every monitored site (from 1 to 9). Each cell of the flow state database is filled with a value of '1' if the monitored site was 'wet' that day (e.g. all sites in day 1, T2, were defined as 1) or with a value of '0' if the monitored site was 'dry' that day (e.g. in day 2, T3, monitored site 2, 6, 7 and 8 were defined as 0). (c) Using the flow state database, the spatiotemporal matrix is built based on a defined scenario, in this case, we used a directed network structure and a binary quantification of links and no-links (DirBin scenario). For each row of the flow state matrix (e.g. T2), a pairwise matrix is constructed where all the possible spatial links, based on which monitored sites are 'wet' and which are 'dry', are assessed. This defines the spatial connections for a specific time (green part of the matrix). Temporal connections are filled based on the same connections of that time (T2) but introduced in the spatiotemporal matrix in the following time step (T3). (d) STcon is calculated for each site individually (e.g. Site 1) and is the average of how often a site has been connected to all its potential neighbours (e.g. Site 1 has eight potential neighbours) during the studied time (6 units of time). (d) STconmat corresponds to the sum of all the spatiotemporal matrices into one unique matrix later divided by the studied time (6 units of time).
these connectivity values by pairs of sites so as a spatiotemporal connectivity matrix and allows to assess changes in community composition (e.g. Jaccard dissimilarity, Bray-Curtis dissimilarity). Here, we used these two measures to explain changes in the structure of macroinvertebrate communities at the local and regional scales to illustrate their relevance for capturing ecological processes.

| Study sites and sampling
The dataset used for developing and testing the current framework

| Flow state monitoring and database building
A total of 69 temperature data loggers (HOBO Pendant® Temperature/Light logger, hereafter loggers) were used to assess flow state in the seven selected streams (Figure 1a), with between 10 and 15 loggers per stream ( Figure S1; Pineda-Morante et al., 2022). These data loggers were installed in July 2018 and kept in the streams until December 2019. At each study site, a logger was submersed into the water to record water temperature (°C) and, for each stream, a logger was placed outside the water (e.g. hanging from a tree) to record air temperature (°C). The loggers recorded temperature at hourly intervals for 513 days. We calculated the daily mean temperature and compared the diurnal temperature variation of the installed loggers to assess if each site had enough water to cover the data logger (hereafter wet) or no surface water (hereafter dry) comparing air and instream temperaturesfollowing Gungle (2006). Those estimations were validated using field observations and time-lapse images taken for some streams. Finally, we used a logistic regression model including stream characteristics to correct the missing values generated due to loggers malfunctioning or loss due to climatic events (e.g. temperatures below 0°C, floods). Specific details about the model and the process of predicting missing data can be found in Pineda-Morante et al. (2022). The final dataset resulted in a table with the daily wet/dry values (rows) for each logger (columns) for each one of the monitored streams. In this table, a wet day with the presence of surface water flowing or as disconnected pools is represented by '1' and a dry day by '0'. This dataset constitutes the basic information from which we later calculated all the spatiotemporal indices. In this work, we used the entire 513-day period to calculate all the spatiotemporal indices. Using the same flow state database obtained with the data loggers, we also calculated several local hydrological metrics commonly used to characterise surface flow state in temporary streams (Arias-Real et al., 2021;Crabot et al., 2020;Pineda-Morante et al., 2022), such as the total number of dry days (TotDur), the number of changes from wet to dry days (TotNum) and the average number of dry days for each drying event (TotLeng).

| Building spatiotemporal matrices based on logger data
Spatiotemporal connectivity was obtained after building a spatiotemporal matrix, hereafter ST matrix, for each stream. Each row and column of the ST matrix corresponded to a monitored site with a data logger deployed at a specific time ( Figure 1b). Therefore, the matrix was as big as many sites and times were monitored. Then, the ST matrix was filled with information regarding the two levels of connectivity that we assessed: spatial and temporal.

| Spatial connection
Spatial connections were built based on a defined stream network structure ( Figure 1c). A directed structure follows an upstreamdownstream direction ( Figure S2) and an undirected structure implies that all nodes can be reached from everywhere ( Figure S2). This structure was related to the dispersal modes of the organisms that we wanted to study. We assumed that passive dispersers would disperse mostly downstream by drift so they would mainly respond to a directed network. Contrarily, active dispersers that disperse by flight would mostly respond to an undirected network. In the two networks used to create the ST matrix, each node represented a monitored site and each link an effective connection between sites. If the node's flow state was considered as wet, the connection with other nodes was possible. Following the paths defined by the network, the number of reachable nodes from each monitored site was assessed (Figure 1c; Spatial). In the case that a monitored site was dry for that day, the connection with this dry site or throughout it was not possible.

| Temporal connections
Temporal connections were built in the same way as spatial links ( Figure 1c; Temporal). All the possible connections within the network for a specific time were assessed based on the same network structure of the spatial ones. However, the temporal links were entered in the ST matrix on the following time step. In other words, we considered that the connection between the nodes on a given day would influence their connectivity on the following day (Figure 1c; T2 Temporal connections).

| Link and no-link values
For each node, all the spatial and temporal connections with its neighbours were filled with the values corresponding to what we defined as the link or no-link value ( Figure 1c). The link value is the value that we give when dispersal can occur between two nodes.
In this study, this occurs when the flow state is 1 in a pair of nodes and the path to reach them. Contrarily, the no-link value is the value given when dispersal is not possible or in our case, there is at least one 0 in the path between a given pair of nodes.

| Binary and weighted scenarios
In this study, we designed four different scenarios from which we calculated STcon and STconmat to exemplify different possibilities of the current framework. Each scenario combined a different network structure, directed or undirected, and a different way of quantifying the links and no-links (binary and weighted). For the two binary scenarios, the directed binary (hereafter DirBin) and the undirected binary (hereafter UndBin), the link value was defined as 1 and the nolink value as 0. Therefore, STcon and STconmat were quantifying the number of times that each site was connected to its neighbours. For these scenarios, high values meant that a site was highly connected to its potential neighbours during the considered time.
For the other two weighted scenarios, the directed weighted (DirWei) and the undirected weighted (UndWei), we added an additional variable: the Euclidean distance between sites. Here, the link value was 0.1 and the no-link value was 1, and these values were multiplied by the distance between the two nodes. Thus, for the weighted scenarios, we assumed that the presence of water between two sites was facilitating dispersal. Consequently, when connection was possible, the Euclidean distance between two sites was reduced by 90% and when connection was not possible, the Euclidean distance between these two sites was preserved. Therefore, STcon and STconmat calculated for the DirWei and UndWei scenarios were assessing dispersal resistance. For these scenarios, high and low resistance values indicate that the connectivity between two sites is low and high respectively.

| Spatiotemporal connectivity measures
Once the ST matrix was filled with the corresponding link and nolink values, STcon and STconmat were calculated. Depending on the desired output, connectivity can be either calculated for each site individually resulting on the STcon measure, or as a pairwise matrix that incorporates the relation of each site with all the other pairs within the network, resulting in the STconmat.
The STcon corresponds to the average of all the spatial and temporal links for each individual node (Figure 1d). To calculate it, we summed all the times that a node had been connected to its neighbours both spatially and temporally, and later, we divided that value by the amount of time considered and the total potential neighbours that the individual node can have: Where ∑ Tx is the sum of values through all considered times, Si and Ti are the spatial and temporal connections of a specific node i with its neighbours, Nneigh corresponds to all the potential neighbours that node i has and TTU is the total time units considered.
Therefore, STcon represents an average value of how often an individual node has been connected to all their potential neighbours

| Testing the spatiotemporal connectivity measures
For each one of the four scenarios, DirBin, DirWei, UndBin and UndWei, we calculated STcon and STconmat for the entire monitored period of 513 days. We conducted a principal components analysis, PCA, including the STcon values for each scenario and the three local hydrological variables (TotNum, TotDur and TotLeng) to analyse how they were correlated based on the Euclidean distances between them, using prcomp function from stats package (R-Core Team, 2019). We used the adonis function from vegan (Oksanen et al., 2010) to test if upstream-downstream position or stream ID were presenting similar values in this multivariate space using a permutational analysis of variance (PERMANOVA) and expecting that the high hydrological variability in the sampled streams would result in significant differences among them. In addition, we used Spearman correlations for the same set of variables to test their correlation and quantify the strength of their relationship.
As STcon and STconmat differ in their structure, the approach to characterise each stream was also different. First, we related STcon to the relative position of each monitored site within each stream network in an up-to downstream direction. Second, we analysed the differences in STconmat for each stream in a multivariate space through a non-metric multidimensional scaling (NMDS). As STconmat is a pairwise matrix, the values are equivalent to spatiotemporal distances between sites and can be represented in a bidimensional space.
Finally, to test STcon and STconmat against macroinvertebrate community's metrics, we used the period of 480 days between the start of the monitoring (26/07/2018) until the biological sampling campaign (18-21/11/2019) to build the spatiotemporal connectivity metrics. We considered this period for the four different scenarios (DirBin, DirWei, UndBin and UndWei). As the two network structures were related to different dispersal abilities (i.e. directed for aquatic passive and undirected for aerial active), we split the community matrix in these two dispersal groups based on available biological trait data (Pineda-Morante et al., 2022;Sarremejane et al., 2020;Tachet et al., 2010). We did not account for aquatic active and aerial passive dispersers because of their low abundance representing both around 12% of sample's total abundance. For both aquatic passive and aerial active dispersers, we calculated taxonomic richness, Shannon-Wiener diversity, relative dispersal traits abundance and compared them against STcon. We also calculated two beta diversity proxies: Jaccard, based on presence-absence, and Bray-Curtis, based on abundance data and compared them against STconmat.
These metrics were calculated using the vegan package (Oksanen et al., 2010). Finally, linear mixed models were used to analyse the relationship between STcon and the calculated community metrics (taxonomic richness, Shannon-Wiener diversity, relative dispersal traits abundance) using the package lme4 (Wood & Scheipl, 2013) and considering stream identity as a random factor to control for variability between the different streams. We analysed all pairwise distance matrices with Mantel tests relating STconmat to the two community dissimilarity metrics (Bray-Curtis and Jaccard indices) using the vegan package (Oksanen et al., 2010).

| Spatiotemporal connectivity and network structure
The selected streams showed strong differences in their spatiotemporal patterns in relation to network structure. In the binary scenarios DirBin and UndBin, where direct connectivity is quantified, both STcon ( Figure 2a) and STconmat (Figure 2b) captured wet/dry patterns for each monitored site. For example, sites that dry more often and for longer durations had lower values of STcon for the DirBin and UndBin scenarios (Figure 2; site highlighted in red). When the network structure was directed (DirBin), the sites that were dry more often were impacting other sites located above them by reducing their STcon and STconmat values as these sites cannot connect to their downstream neighbours when an intermediate site is dry (Figure 2; DirBin, sites above the one highlighted in red). On the contrary, this effect was not observed for the undirected network structure (Figure 2; UndBin). In the weighted scenarios DirWei and UndWei (Figure 2), where STcon and STconmat quantified dispersal resistance, the highest values were found at upstream sites when there was a directed structure, DirWei, whereas the drier sites had the greatest values of STcon and STconmat in the undirected network UndWei (Figure 2; site highlighted in red). In weighted scenarios, STcon and STconmat captured the interaction between distance and drying so when a site contained water the distance between two sites decreased concomitantly with STcon and STconmat values. Contrarily, when a site was dry, the distance corresponded to the Euclidean distance between the sites leading to an increase of

STcon and STconmat values. The complete dataset with STcon and
STconmat values for the four scenarios and for all the monitored streams can be seen in Figure S3 and Table S1. Spearman correlation analysis highlighted these negative correlations ( Figure S4). Finally, for the PERMANOVA analysis, we found significant differences across sites position in the PCA between streams and between site position within streams (i.e. upstream-downstream), and a significant interaction of both factors as expected (Figure 3).

| Testing spatiotemporal connectivity against macroinvertebrates communities
The linear mixed models showed several significant relationships be- Jaccard dissimilarity for passive dispersers was positively related to STconmat in the DirBin and UndBin scenarios. Contrastingly, Jaccard dissimilarity for active dispersers was negatively related to STconmat in the DirBin scenario. Finally, Jaccard dissimilarity for active dispersers was positively related to STconmat in the undirected weighted scenario (UndWei). All community metrics and model effect sizes can be found in Figure S6 and Table S2.

| DISCUSS ION
We present a new methodological framework from which spatiotemporal connectivity can be calculated combining both spatial F I G U R E 2 (a) STcon and (b) STconmat values for the Vall d'Horta stream (VH). Colour viridis gradient and size correspond to STcon and STconmat values. For DirBin and UndBin scenarios, purple/ blue and bigger sized arrows indicate higher connectivity while yellow and smaller arrows indicate isolation. For DirWei and UndWei, grey/red and bigger sized arrows indicate higher dispersal resistance while orange/yellow and smaller arrows indicate less resistance. We highlighted in red the monitored site 3 just to ease its location in the network. All the data are calculated based on the whole monitored time window (513 days). See the other studied streams in Figure S3. and temporal dimensions in one unique value. Our spatiotemporal connectivity measures use data obtained at a continuous time interval (e.g. minutes, days, months, years) and consider a particular spatial structure (i.e. dendritic network or undirected network in our case). We developed this approach using a high-frequency database of flow state where daily wet/dry values of seven streams were recorded for 513 days (Pineda-Morante et al., 2022). Past studies used daily monitoring to assess the spatial variation (i.e. wet or dry reaches) and/or to characterise temporal variation (e.g. seasonal changes) of river networks following a snapshot approach Pineda-Morante et al., 2022). Our framework allows merging spatial and temporal dynamics within the same connectivity value, while being adaptable to different temporal windows, monitoring studies and systems (e.g. months or years with datasets like Mouton et al., 2022;Perera et al., 2020;Ridl et al., 2018). In addition, the framework can incorporate non-binary connections based on, for example, distances, resistance (e.g. non-transitable areas), barriers (e.g. dams, forests) or dispersal pathways (e.g. wind or flow). Therefore, the proposed framework can be extended to any system presenting a spatial structure that has been monitored through time and with enough detail to build a network structure that captures fluxes of individuals, species, energy or matter. when assessing temporary stream biological quality, one could assign relevance to the terrestrial and/or the aquatic biota according to stream spatiotemporal connectivity patterns (Steward et al., 2022).
Furthermore, these spatiotemporal measures can be useful to understand how network connectivity determines the fluxes of energy, matter and organisms within the river (Cid et al., 2022;Gounand et al., 2018;Martensen et al., 2017;Uroy et al., 2021).
Although we used high time frequency data loggers to obtain flow state data, the current framework could be applied to data coming from gauging stations (Monk et al., 2008;Stocks et al., 2021;Walker et al., 2016) or from hydrological models (Costigan et al., 2017;Döll & Schmied, 2012;Yu et al., 2020), which could be used to define the values assigned to the 'links' and 'no links' to assess connectivity.
In this sense, instead of binary values of connectivity, we could incorporate flow, wind velocity or even permeability values between sites as far as these data would be available at the same temporal resolution. In terms of drying patterns, we found that STcon values showed negative correlations with TotNum, TotDur and TotLeng in binary scenarios. These correlations were already expected because both STcon and hydrological metrics are quantifying intermittence similarly. For example, high values of STcon for the scenario DirBin were negatively correlated with the duration of dry events (TotDur), meaning that highly spatiotemporally connected sites are also the ones which generally have shorter dry events. Nevertheless, these results also suggest that by only using the STcon, we would be already capturing drying patterns and the usage of local hydrological metrics such as TotNum, TotDur and TotLeng would not be necessary.
Overall, STcon and STconmat present a great potential to characterise spatiotemporal patterns in streams, representing a powerful tool to guide conservation and restoration actions given the importance of spatiotemporal connectivity for population/community dynamics and ecosystem functioning Cid et al., 2020).
Macroinvertebrate communities significantly responded to STcon, with different responses for active aerial and passive dispersers, thereby suggesting that our indices captured their dispersal dynamics. Species richness and Shannon diversity increased with greater spatiotemporal connectivity in the UndBin scenario, which seems to quantify the impacts of drying on aquatic communities Pineda-Morante et al., 2022). Furthermore, passive dispersers responded negatively to the DirWei scenario, with the communities experiencing higher resistance to dispersal showing lower richness. Thus, drier and more distant sites had fewer taxa, as seen in other studies (Brooks et al., 2018;Elliott, 2002;Fonseca, 1999;Kappes & Haase, 2012;O'Hop & Wallace, 1983). The differences between active and passive dispersers regarding dispersal resistance highlighted the relevance of overland pathways for active dispersers (Bogan & Boersma, 2012;Cañedo-Argüelles et al., 2015;Phillipsen & Lytle, 2013). Passive dispersers abundance responded positively to STcon in the UndBin scenario, indicating that perennial sites would tend to accumulate higher abundances of this dispersal group (Hershkovitz & Gasith, 2013). Interestingly, the fact that passive dispersers appear related to undirected scenarios could be linked to the small distances between sites, which could be overcome during F I G U R E 3 PCA plot for STcon indices for each one of the four scenarios: directed binary (DirBin), directed weighted (DirWei), undirected binary (UndBin), undirected weighted (UndWei) and the hydrological variables: the total duration of drying events (TotDur), the frequency of drying events (TotNum) and the average length of each drying event (TotLeng). All the data are calculated based on the whole monitored time window (513 days).
Regarding STconmat, both weighted scenarios (DirWei and UndWei) had positive relationships with dissimilarity indices suggesting that dryer and more distant sites harboured more unique communities. Such pattern was probably linked to a combination of dispersal limitation and harsher environmental conditions imposed by drying events leading to higher dispersal resistance and the development of distinct communities Steward et al., 2022;Valente-Neto et al., 2020). On the contrary, the binary scenarios (DriBin and UndBin) resulted in contrasting patterns depending on the dispersal group for presence-absence data. In this scenario, passive and active dispersers were positively and negatively (respectively) related to spatiotemporal connectivity. This suggests that more connected sites tend to have passive dispersers' communities with different species composition while active dispersers' communities tend to be more similar. Thus, when sites are hydrologically connected for longer periods of time the communities of passive dispersers tend to diverge in their composition.

F I G U R E 4 (a) Monitored streams
STcon values (y-axis) ordered along their relative position from upstream to downstream (x-axis). (b) NMDS with STconmat values of each monitored stream. More compact clouds of points mean a greater similarity between sites in terms of spatiotemporal connectivity (i.e. all sites dry similarly). More dispersed clouds indicate a greater variability within the stream in terms of drying. Circle size indicates upstream (smaller) or downstream (bigger) site position. Each plot row corresponds to one of the four scenarios: directed binary (DirBin), directed weighted (DirWei), undirected binary (UndBin), undirected weighted (UndWei). All the data are calculated based on the whole monitored time window (513 days). Individual stream STcon plots can be found in Figure S5.
Overall, although the study sites were close to each other (mean distance between sites within a stream was around 1 km and all the streams were located within an approximate range of 100 km 2 ), the macroinvertebrate communities showed significant responses to spatiotemporal connectivity. This highlights the importance of quantifying spatiotemporal connectivity in highly dynamic systems such as temporary streams Datry et al., 2016). Finally, STconmat proved useful to incorporate pairwise metrics (e.g. beta diversity calculated with Jaccard or Bray-Curtis indices) within spatiotemporal analysis of temporary systems (Khattar et al., 2021;Legendre & De Cáceres, 2013), which is key to better capture assembly processes or improve management of spatiotemporally variable ecosystems (Bo et al., 2020;Boyé et al., 2019;Lamy et al., 2015;Ruhí et al., 2017;Sobek et al., 2009).
In dendritic networks such as fluvial systems, connectivity has been acknowledged for a long time as a key driver of diversity and functioning at population, community and/or ecosystem levels (Fullerton et al., 2010;Vannote et al., 1980). Indeed, several indices have been developed to assess the degree of fragmentation generated by dams (Baldan et al., 2022;Cote et al., 2009) or connectivity indices accounting for longitudinal and lateral connectivity (Rivers-Moore et al., 2016). However, the inclusion of both spatial and temporal connectivity facets has been poorly explored so far (Fullerton et al., 2010;Uroy et al., 2021). We believe that the proposed framework represents a first step towards a better inclusion F I G U R E 5 Significant linear mixed models between STcon (a-c) and STconamt (d, e) and biological metrics calculated for passive aquatic and active aerial dispersers. (a) Richness, (b) Shannon, (c) Trait abundance, (d) Pairwise metrics (i.e. Jaccard and Bray-Curtis indices). Note that STcon values for DirBin and UndBin scenarios (green x axes) quantify how much a site has been connected, whereas values for UndWei and DirWei scenarios (red x axes) quantify the dispersal resistance of each site. All the data are calculated based on the time window between the beginning and the sampling date (480 days). See all other results for all the metrics and scenarios in Figure S6. of spatiotemporal connectivity in general ecology, extending beyond our study case and being potentially applied to any ecosystem.
For example, our measures could be useful to incorporate network connectivity into biodiversity conservation using systematic planning approaches (Hermoso et al., 2012). Also, STcon and STconmat can serve to assess the effectiveness of restoration measures as the community response to habitat restoration will depend on spatiotemporal connectivity to some extent (Cid et al., 2022). At the same time, it complements other methods like remote sensing (Bishop-Taylor et al., 2017) by specifically quantifying spatiotemporal dynamics and incorporating multiple time windows.
Overall, the proposed framework has a strong potential to be used at several temporal scales (e.g. days, months, years) and across different levels of biological organisation (e.g. populations, communities, ecosystems). Besides flow state, other metrics that vary spatiotemporally and define connectivity such as land use could be used (Firmiano et al., 2021). Furthermore, the current function could be extended to include other network structures by defining the number of neighbours at which dispersal is considered effective, either setting distance thresholds or dispersal decay with distance (Borthagaray et al., 2015;Muneepeerakul et al., 2008;Radinger & Wolter, 2014). In addition, another aspect that could be further developed within this framework is related to antecedent spatiotemporal connectivity (i.e. the temporal scale considered by STcon and STconmat). In the approach presented here, the ST matrix considers the spatial structure from the previous day, thereby considering two time steps (i.e. what happened on day 1 has an impact on day 2 but not on day 3; Uroy et al., 2021). Both the defined network structure and the time span are case-specific and could be adjusted to the characteristics of the studied system and the focal organism (e.g. organism life span, a pollution event). So far, the main limitation of this framework is still the lack of databases that include high spatial and temporal resolutions at relevant scales. Furthermore, the adaptation of the framework to different ecosystems and network structures should be made with caution. For example, the parameters used to calculate STcon and STconmat need to be defined for each system, because the results can be considerably different depending on the designed scenario. Nonetheless, the adaptability of our framework suggests that it can still be expanded to incorporate more facets of the interaction between spatial and temporal processes. In this regard, we provide the R code (see Supporting Information, Cunillera-Montcusí, 2023) to facilitate and promote future studies.
The quantification of spatiotemporal connectivity is key for any ecosystems subjected to high seasonal and/or interannual variability, or affected by natural (e.g. wildfires, hurricanes, floods, droughts) or human-driven disturbances (e.g. invasive species, point source pollution). Moreover, environmental conditions are becoming globally harsher and more variable, with an expected increase in the frequency, duration and variability of natural and human-driven disturbances (IPCC, 2022). Consequently, we need to further explore and develop frameworks that can capture such variability in space and time (Uroy et al., 2021). To guide future conservation and management actions Cid et al., 2020;Schiesari et al., 2019). We encourage the inclusion of spatiotemporal connectivity in future studies in the field of meta-system ecology, restoration ecology and biodiversity conservation to test and challenge our method so we can gain insights into spatiotemporal processes.

AUTH O R CO NTR I B UTI O N S
David Cunillera-Montcusí conceptualised the framework and leaded the paper in the analysis, writing, interpretation and edition. Miguel Cañedo-Argüelles and Núria Bonada conceptualised the study, collected the data, interpreted the results, wrote and edited the manuscript. Núria Cid collected the data, interpreted the results, wrote and edited the manuscript.
José María Fernández-Calero, Sebastian Pölster, Roger Argelich and Pau Fortuño collected the data and edited the manuscript. (DRYvER project: www.dryver.eu). We want to also thank the two reviewers whose comments helped the current manuscript to greatly improve.

CO N FLI C T O F I NTE R E S T S TATE M E NT
The authors declare none.

DATA AVA I L A B I L I T Y S TAT E M E N T
All data used in this work as well as the corresponding code and the function to calculate STcon and STconmat values are available at Cunillera-Montcusí (2023) and a tutorial to illustrate the usage of the function spat_temp_index is available at https://cunil lera-montc usi.github.io/Q uant ifyin ig-SpaTe m-conne ctivi ty/.

S U PP O RTI N G I N FO R M ATI O N
Additional supporting information can be found online in the Supporting Information section at the end of this article.      Wiener-diversity, (c) Trait abundance, (d) Jaccard dissimilarity, and (d) Bray Curtis dissimilarity. In each box, the first row of plots correspond to active dispersers (group of trait f4) and the second row of plots to passive dispersers (group of trait f1). Note the X axes of plots must be read carefully for each scenario: for DirBin and UndBin higher STcon values mean higher spatiotemporal connectivity whereas for DirWei and UndWei higher STcon values mean greater spatiotemporal resistance to dispersal.