Skip to main content

This is a preprint.

It has not yet been peer reviewed by a journal.

The National Library of Medicine is running a pilot to include preprints that result from research funded by NIH in PMC and PubMed.

bioRxiv logoLink to bioRxiv
[Preprint]. 2026 Aug 21:2026.08.07.742341. Originally published 2026 Aug 7. [Version 2] doi: 10.64898/2026.08.07.742341

Geometric constraints and cognitive inputs jointly shape emergent brain dynamics and topology

Ahmad Beyh 1, Jason Z Kim 2, Waheed U Bajwa 3, Linden Parkes 1,4
PMCID: PMC13484749  PMID: 42620430

Abstract

How the brain’s physical geometry gives rise to its flexible functional repertoire remains a central question in neuroscience. Here, we trained three classes of recurrent neural networks (RNNs) on a working-memory task, forming a graded hierarchy of spatial constraints: Vanilla RNNs (no spatial constraints), Masked RNNs (projection constraints limiting where information enters and leaves the network), and biophysical RNNs (bioRNNs; projection constraints and spatial embedding of the networks’ connectivity using the brain’s inter-regional Euclidean geometry). We assessed how well each RNN class predicted empirical fMRI activity without exposing them to it during training. Our results showed that bioRNNs were the only networks to successfully predict empirical brain activity and to organize their dynamics into a spatial pattern that recapitulated the brain’s principal hierarchy (the sensorimotor–association axis). Additionally, bioRNNs’ ability to predict empirical brain activity emerged along a trajectory in which geometry was laid down first, then partly traded back as the task was mastered. Importantly, brain-like topological features emerged in bioRNNs as they increased their task proficiency while maintaining their ability to predict brain activity. Taken together, our results indicate that physical geometry and cognitive inputs play distinct, complementary roles: while geometry constrains the space of possible brain dynamics, cognitive inputs determine which dynamics are expressed. They also situate topology as the scaffold through which the physically embedded brain reconciles wiring costs and computational demands.

Keywords: brain connectivity, brain geometry, structure–function coupling, neuroAI, recurrent neural networks

INTRODUCTION

The brain is a physically embedded system1. A central goal of neuroscience is to understand how this physical geometry constrains the brain’s complex web of inter-regional connectivity and emergent neural dynamics2, as well as how these entwined relationships enable the computational processes that underlie cognition and behavior3. Decades of neuroscience research have shown that brain geometry, connectivity, and function are tightly, though imperfectly, coupled4–10. While geometry plays a key role in determining the layout of anatomical connections, which in turn shapes the repertoire of dynamics the brain can express2, brain function is not a trivial product of either its physical embedding or its connectivity alone9,11. Instead, to flexibly respond to complex stimuli, the brain has evolved to selectively uncouple its function from its underlying geometry and connectivity, enabling humans to successfully navigate their ever-changing environment12. How this flexible brain function emerges from fixed geometry and connectivity is the focus of this work.

Previous work has shown that the physical embedding of brain regions predicts both their anatomical and functional connectivity, with regions located closer together in space being both more likely to share an anatomical pathway and to exhibit similar dynamics8,13. This organization is thought to reflect the brain’s need to produce a cost-efficient solution for its wiring; short-range connections are both metabolically and materially lower in cost than long-range ones14. However, long-range connections are well documented in the brain and are thought to enable the efficient communication between distributed systems, which is a prerequisite for behavior15,16. Similarly, certain regions, known as hubs, exhibit patterns of strong and diverse structural connectivity that exceed what would be predicted by spatial proximity to their neighbors17. These topological properties, among others, are thought to play an important role in explaining how and where brain function diverges from its structure. Thus, while geometry accounts for a substantial fraction of variance in both structural and functional connectivity6,18, it is only part of the story5.

A flexible mapping between the brain’s geometry, connectivity, and its function is therefore critical to enabling complex human cognition, as it allows the same anatomical substrate to support different activity patterns depending on context, behavioral state, and the presence of sensory information5,19. Prior modeling work has sought to characterize this relationship. For example, generative network models that probabilistically add connections over time, absent any task-related learning outcome, have shown that a combination of inter-regional physical distance and topological wiring rules can produce brain-like connectivity, illustrating a relationship between geometry and connectivity20–22. Eigenmode decomposition of the cortical sheet has been shown to capture the topography of brain activity maps, illustrating a relationship between geometry and brain function1. Or, for example, connectome-based reservoir models, in which empirical structural connectivity is implemented directly as the recurrent weight matrix, can generate neural dynamics and support computation, further linking connectivity to function23. In a complementary computational account, large-scale circuit models with hierarchically organized intrinsic timescales have shown how the cortex’s anatomical connectivity can give rise to a functional hierarchy of dynamics, directly linking structure to function within a mechanistic model24. However, many such applications (for review, see Suárez et al.9) have only captured select components of this relationship piecemeal, e.g., by addressing structure or function separately, and in the absence of behavioral inputs accompanied by corresponding learning goals. Here, we seek to examine the relationship between brain regions’ spatial embedding (brain geometry), connectivity, and function within a single end-to-end model during task learning.

To achieve this goal, we leverage recurrent neural networks (RNNs). RNNs are artificial dynamical systems that can be trained via backpropagation through time to perform a wide range of behavioral and cognitive tasks, and they readily support the integration of geometric constraints into their design25. Because their connectivity, task inputs, and dynamics are all fully observable and editable, RNNs can uncover precise details of how and when computational dynamics emerge from connectivity, making them a powerful tool for the causal study of neural computation in silico26–30. Crucially, recent work has shown that imposing biological constraints, such as spatial embedding and a cost on long-range connections, drives RNNs to converge on structural and functional motifs observed in the cortex27. Here, we leverage these insights to develop novel biophysical RNNs (bioRNNs) that incorporate biological constraints to study the relationship between brain geometry, connectivity, and function.

In this study, we used bioRNNs to investigate how the human brain’s physical geometry constrains the emergence of brain-like neural dynamics and connectivity in these synthetic networks. We do so by constraining the spatial embedding of our RNNs’ hidden-layer nodes while allowing their dynamics and connectivity topology to emerge through task training. By systematically layering spatial constraints onto RNNs and comparing their internal dynamics against empirical human fMRI data, we ask three linked questions: (i) whether spatial embedding allows networks to better reproduce real brain activity; (ii) how spatial embedding and cognitive inputs contribute differentially to emergent brain activity; and (iii) whether brain-like topology supports the acquisition of function and observed dynamics. Our results suggest that physical geometry and structured cognitive inputs are both required to support the emergence of a brain-like topology in bioRNNs that captures empirically observed brain activity unseen by the models, and that this capacity to predict activity arises only when bioRNNs break away from the fixed geometric scaffold that constrains them.

RESULTS

Spatial embedding offers a learning advantage

To assess the impact of geometry on brain structure and function, we developed and trained three classes of RNNs on a delayed match-to-sample with distractors (DMS-D) task31,32: Vanilla RNNs (Fig. 1a), Masked RNNs (Fig. 1b), and spatially embedded bioRNNs (Fig. 1c). For each of these RNN classes, we trained 100 randomly initialized RNNs (runs) that each consisted of 100 nodes representing the brain regions of the left hemisphere33. Vanilla RNNs are standard RNNs whose inputs and internal organization are not shaped by any spatial prior that encodes brain geometry. These represent our baseline RNN. Masked RNNs include projection constraints, a fundamental neurobiological feature that governs how the brain receives environmental inputs and produces behavioral outputs34,35. Here, inputs enter the network exclusively through a subset of nodes representing the visual cortex (Fig. 1b,c; read-in nodes), while outputs are read exclusively from a different subset representing the association cortex (Fig. 1b,c; read-out nodes). Finally, bioRNNs additionally employ a spatial embedding that shapes the network’s inter-node connectivity (i.e., the hidden weights). Throughout training, these weights are shaped by inter-regional Euclidean distances derived from empirical brain data, thereby prioritizing a connectivity pattern that mirrors the brain’s geometry. Thus, our RNNs form a graded hierarchy of increasing geometric constraints, spanning from no constraints (Vanilla RNNs) to simple brain-like constraints on inputs and outputs (Masked RNNs), to ones that also encode how the brain’s geometry influences its connectivity (bioRNNs). See RNN overview section in Materials and Methods for more details.

Figure 1. Spatial embedding offers bioRNNs a learning advantage.

Figure 1.

(a) Vanilla RNN: a fully recurrent network that receives the task inputs at all hidden units and reads the task decision from all units, with no spatial priors. (b) Masked RNN: identical to the vanilla network except that inputs enter only through a fixed subset of read-in nodes (here, visual cortex) and outputs are read only from a separate subset of read-out nodes (here, association cortex), imposing projection constraints as the only spatial prior. (c) In bioRNNs, a spatial embedding is added to the masked architecture, in which the hidden-to-hidden weights are shaped throughout training by a neurobiological prior. Here, we use the brain’s inter-regional Euclidean distance matrix to constrain the relative spatial patterning of connectivity during RNN training. Thus, bioRNNs impose two interrelated spatial priors, one based on task inputs and outputs and another based on brain geometry. (d) We trained RNNs on a delayed match-to-sample with distractors (DMS-D) task31,32,38. A trial began with a fixation cue and a sample stimulus, after which three test stimuli were presented in sequence, separated by delays; the network was to respond only to the test that exactly matched the sample. (e) Test accuracy across training (mean ± 95% confidence interval over 100 networks (runs) per RNN class). All classes successfully learned to perform the task far above the 33% accuracy chance level, but they did so at different rates. The dashed vertical lines captured when each RNN reached the training criterion, i.e., when 95% of the runs reached their accuracy asymptote. (f) Violin plots of the number of training epochs to the criterion for each class. bioRNNs reached the performance criterion faster than Masked RNNs despite having more stringent training demands. Statistical significance is based on Wilcoxon signed-rank test.

The DMS-D is a complex working-memory task that engages temporal integration, perceptual decision-making, and inhibitory control, all key facets of higher-order cognition36,37 in humans, making it well-suited to probing the neural dynamics that underlie complex behavior. We trained our RNNs on task data simulated using NeuroGym38. Each DMS-D task trial began with a brief fixation signal indicating the start of a new trial, followed by the presentation of a unique target stimulus consisting of 32 simultaneous inputs (Fig. 1d). Three additional test stimuli were then presented in sequence, separated by delays, and the RNN was required to respond only when it encountered a test stimulus that was an exact match to the initial target stimulus. As such, the RNN’s decision relied on maintaining a representation of the target stimulus in working memory throughout the trial and inhibiting its response until an exact match was encountered.

We found that all RNN classes successfully learned the task (Fig. 1e). Specifically, given that the DMS-D task required correctly identifying one of the three test stimuli as the correct match, chance performance was set at 33% accuracy. All models exceeded this chance baseline. While Vanilla RNNs reached the highest final accuracy (92.00 ± 1.52%), Masked RNNs and bioRNNs achieved similar but lower levels (74.26 ± 6.25% and 75.92 ± 10.23%, respectively). This result suggests that minimally constrained Vanilla RNNs, which were only optimized to solve the task, remained the best performers. There were also clear differences in learning speed between the RNNs. We fit each RNN’s learning curve with a logistic function (Fig. S1) and assessed when task performance stabilized (i.e., reached 95% of its asymptote). Although we trained the RNNs up to 60,000 epochs, we observed that all RNN classes reached stable task performance within 40,000 epochs. Therefore, we used this marker as the anchor for all subsequent analyses. Here, we observed that Vanilla RNNs were the fastest to learn the task (4,019 ± 615 epochs; matched-pairs rank-biserial correlation rrb = −1.0, Wilcoxon signed-rank p < 0.001 against both other RNN classes), consistent again with the idea that a minimally constrained RNN optimized for performance rather than biological relevance is best positioned to learn most rapidly (Fig. 1f). Critically, however, bioRNNs learned significantly faster (11,729 ± 4,834 epochs) than Masked RNNs (21,150 ± 8,348 epochs; rrb = −0.85, p < 0.001). This was the case despite the fact that the spatial penalty imposed on bioRNNs during training posed the largest burden among the three RNN classes (see spatial loss and task loss evolution in Fig. S2). Therefore, in the presence of projection constraints, a fundamental property of how visual inputs project to the brain, spatial embedding afforded the networks a significant learning advantage. This observation is consistent with prior reports showing that biologically grounded physical constraints can serve as inductive biases that enhance task learning, rather than just as additional costs27.

bioRNN dynamics capture empirical brain dynamics and the cortical hierarchy

Having established that the brain’s spatial embedding confers a learning advantage in the presence of biologically-informed projection constraints, with a minimal impact on task performance, we next assessed how well our RNNs captured real, empirical brain activity observed in vivo in humans using functional MRI (fMRI) data obtained from 100 healthy young adults (Human Connectome Project; HCP-YA)39. First, in order to isolate the dominant, behaviorally relevant modes of high-dimensional activity40, we applied principal component analysis (PCA) to the time series of the fully trained RNNs to capture their hidden-state trajectories in a low-dimensional subspace (Fig. 2a). The first five resulting PCs captured 72.7% ± 1.2% of hidden-activity variance in Vanilla RNNs, 77.2% ± 2.2% of hidden-activity variance in Masked RNNs, and 76.2% ± 3.5% of hidden-activity variance in bioRNNs (see Fig. S3 for more details on PC selection). Importantly, projecting the weights of the PCs onto the brain surface did not yield spatially smooth PCs for either Vanilla RNNs (Moran’s I = −0.01 ± 0.01) or Masked RNNs (Moran’s I = −0.01 ± 0.01), but a spatially smooth organization emerged for bioRNNs (Moran’s I = 0.18 ± 0.06), indicating that the spatial embedding of the hidden layer pushed the bioRNNs to organize their activity in a brain-like pattern (Fig. 2b). In other words, once the recurrent layer is encouraged to respect cortical geometry, its dominant activity modes recapitulate smooth spatial gradients like those observed in large-scale cortical fMRI patterns41,42.

Figure 2. bioRNN dynamics capture empirical fMRI dynamics and the cortical hierarchy.

Figure 2.

(a) Each trained RNN’s hidden-state time series was summarized by principal component analysis (PCA). (b) Weights of the first five principal components (PCs) projected onto the cortical surface. Vanilla RNNs and Masked RNNs showed no discernible spatial structure, whereas bioRNNs displayed smooth, spatially organized PC maps. (c) Variance in the N-back task fMRI dynamics explained by the first five PCs of each RNN class, expressed as a z-score relative to a random-subspace baseline (zsub; grey band, chance). Only bioRNNs exceeded chance. (d) bioRNNs were retrained with the spatial embedding permuted to preserve its spatial autocorrelation while breaking its correspondence to the cortex (grey histogram; blue, bootstrap density obtained through linear mixed-effects models). The veridical embedding (red) exceeded the entire null distribution (zgeom = 3.67, p < 0.001; 95% CI [2.76, 5.21]), indicating that alignment with empirical dynamics depends on the true anatomical arrangement of nodes rather than on spatial smoothness alone. (e) Variance in the cortical sensorimotor–association (S–A) axis explained by each RNN class and by empirical task fMRI PCs (dashed line: chance). Only bioRNNs recovered the S-A axis (adj. R2 = 0.49) and do so to a moderately close degree as task fMRI itself (adj. R2 = 0.68).

Next, we used the first five RNN PCs as predictors of empirical fMRI activity derived from the N-back working-memory task43. Because even a randomly chosen five-dimensional subspace captures a non-trivial fraction of variance in high-dimensional fMRI data, raw explained variance cannot be interpreted on its own44,45. We therefore benchmarked each RNN against a null of 1,000 random five-dimensional subspaces and expressed its fMRI explained variance as a z-score relative to this random-subspace baseline (zsub; see fMRI variance explained and the random subspace in the Methods). We observed that bioRNNs were the only ones that exceeded chance in predicting variance in fMRI data (zsub = 5.54 ± 1.87, p < 0.001; Fig. 2c). Meanwhile, Vanilla RNNs and Masked RNNs yielded zsub values around zero, indicating that their ability to predict empirical brain activity was no better than chance. This result indicates that neither unconstrained RNNs (Vanilla) nor those with segregated inputs and outputs (Masked) were sufficient to generate cortex-like neural dynamics. Rather, our results indicate that what matters is the specific spatial arrangement of the recurrent connectivity engendered by brain geometry. Notably, our bioRNNs were trained on a synthetic DMS-D task in silico yet successfully predicted N-back fMRI time series acquired independently in humans in vivo. This is a striking form of transfer, in which in silico networks trained only on a synthetic task predicted the low-dimensional representation of the moment-to-moment dynamics of living human brains performing a conceptually similar but distinct working-memory task without ever encountering that data during training. Finally, we observed this correspondence at the individual-subject level as well: bioRNNs whose hidden weights more closely resembled a subject’s inter-regional Euclidean geometry better predicted that subject’s fMRI activity (rS = 0.25 ± 0.09, p < 0.001; Fig. S4).

An important question emerged from our previous results: can bioRNNs’ prediction of empirical fMRI dynamics be attributed solely to the spatial autocorrelation introduced by the Euclidean embedding, rather than to the veridical arrangement of nodes in anatomical space? To address this, we constructed a geometry null in which the embedding was permuted to preserve its spatial autocorrelation while breaking its correspondence to cortex13,46, holding the task and projection constraints fixed, and fully retrained 200 such RNNs up to 40,000 epochs (the training criterion established previously). Spatial autocorrelation accounted for part of the effect: the 200 null RNNs predicted fMRI dynamics above the random subspace baseline (mean zsub = 3.42 ± 0.91; Fig. 2d). Critically, however, no permuted geometry matched the predictive performance of the veridical bioRNN, which significantly exceeded the null distribution (zgeom = 3.67, p < 0.001; 95% CI: zgeom = [2.76, 5.21], p = [<0.001, 0.003]; Fig. 2d). Thus, the bioRNNs’ alignment with empirical brain activity depends on the veridical spatial embedding and its congruence with the cortical locations the nodes represent, beyond what spatial autocorrelation alone can produce. In other words, in addition to spatial smoothness, the particular pattern in which the cortex is laid out in space endows these networks with brain-like dynamics, demonstrating that the anatomical positions of regions relative to one another, and how these positions interact with the projection constraints, carry functionally relevant information.

Given the ability of bioRNN dynamics to predict unobserved functional brain activity, we next asked how well these dynamics aligned with the brain’s known hierarchical organization, which we summarized using the sensorimotor–association (S–A) axis47. Specifically, we ran regression analyses in which the RNN PC weights acted as predictors and the S–A axis as a target variable. We found that bioRNNs were the only ones whose simulated dynamics captured the cortical hierarchy (adj. R2 = 0.49; Fig. 2e). Here as well, this ability was not the simple product of the spatial autocorrelation present in both the bioRNNs and the S–A axis, which we confirmed with the same null-testing approach we used in the dynamics prediction analysis (p = 0.002). Meanwhile, Vanilla RNNs and Masked RNNs captured nearly none of the hierarchy (adj. R2 = 0.04 for both). For comparison, we ran an additional regression analysis that used PC weights derived directly from N-back task fMRI activity as predictors and found that task fMRI activity mapped onto the S–A axis moderately better than bioRNNs did (adj. R2 = 0.68; Fig. 2e), and this was also not solely attributable to spatial autocorrelation (p = 0.001). Thus, bioRNN dynamics explain the dominant hierarchical brain axis to a level approaching the ceiling imposed by fMRI, indicating that they successfully capture a large-scale organizing principle of the cortex. Strikingly, they recover this cardinal axis of cortical organization without ever being directly exposed to it, whereas fMRI is one of the features used to construct the S–A axis, thereby constituting a theoretical ceiling for the prediction. This implies that a spatial geometry prior, once shaped by task demands into connectivity, is able to reconstruct the brain’s principal functional hierarchy.

Working memory training reorganizes bioRNN dynamics toward human cortical activity

Having established that bioRNNs spatially embedded with the brain’s Euclidean distance structure were the only RNNs that predicted empirical brain activity, we next asked how the similarity between bioRNNs’ hidden weights matrix and the brain’s Euclidean distance matrix evolved over training. Motivated by the possibility that a network must first acquire brain-like structure before it can express brain-like function48, we further asked how the evolution of this similarity relates to bioRNNs’ task accuracy and their ability to predict empirical brain activity. To this end, we plotted fMRI explained variance (zsub) as a function of the alignment (cosine similarity) of the bioRNN hidden weights matrix with the brain’s empirical Euclidean geometry, color-coding the resulting trajectory by task accuracy (Fig. 3a). Rather than a monotonic increase in both quantities, the trajectory traced a pronounced hysteresis loop with three features that were consistent across networks, and that unfolded in a stage-like manner. In the first stage (Fig. 3a, i), structure preceded function: bioRNN–brain structural similarity rose steeply early in training, while fMRI prediction remained near chance, and accuracy remained at 0%. In the second stage (Fig. 3a, ii), fMRI alignment rose sharply and largely preceded the gain in behavioral accuracy. In the third and final stage (Fig. 3a, iii), bioRNN–brain similarity reversed course and reduced, such that the training end-state occupied an intermediate spatial similarity regime that maintained a relatively high fMRI prediction alongside high task accuracy. Consequently, a given bioRNN–brain structural similarity value maps onto markedly different levels of fMRI prediction, depending on the training phase. For example, the gray band in Fig. 3a highlights two points along the training trajectory where bioRNNs shared the same moderate level of structural alignment to the embedding (cosine ≈ 0.25), but showed markedly different fMRI predictions. That is, bioRNNs early in training did not exceed chance in predicting fMRI activity (zsub ≈ 1.5), but the same bioRNNs later in training achieved predictions that far exceeded chance (zsub ≈ 6.3). Brain-like dynamics in bioRNNs were therefore not a fixed function of how Euclidean-like the network geometry was, but were acquired along a trajectory in which geometry was laid down first and partly traded back as the task was mastered. Together, these findings support a view of the brain in which brain geometry is necessary but not sufficient for task learning, and in which eventual mastery of cognitive processing requires a flexible departure of brain function from the underlying geometry. We also replicated this effect using a Spearman similarity metric to confirm that it is not simply a product of metric choice (Fig. S5).

Figure 3. Task learning shapes emergent dynamics.

Figure 3.

(a) Training trajectory of bioRNNs as a function of fMRI explained variance (y-axis; zsub) versus weight–kernel similarity (x-axis; cosine similarity between the hidden-weight matrix and the brain’s Euclidean distance kernel), with points colored by task accuracy (log scale). The trajectory formed a hysteresis loop with three stages: (i) structural similarity rose (rightward shift along the x-axis) while functional alignment remained near chance; (ii) functional alignment rose steeply (upward shift along the y-axis), still at high structural similarity, largely preceding the gain in accuracy (dark purple coloring); and (iii) structural similarity dropped to an intermediate value while functional alignment remained high and task accuracy increased (yellow coloring). The oval-shaped disks at each point along the trajectory represent the 95% CI along both axes. The gray band highlights two positions along the trajectory that share the same weight–kernel similarity (cosine ≈ 0.25) but with markedly different fMRI predictions (zsub ≈ 1.5 vs. zsub ≈ 6.3). (b) Variance decomposition analysis based on fully-trained bioRNNs tested with structured task inputs and with random noise inputs. The unique-task and shared (task and noise together) components predicted fMRI activity above chance, whereas the unique-noise component did not. Interestingly, the shared basis was the strongest predictor.

To further isolate the specific role that structured task inputs play in shaping emergent dynamics, we also tested bioRNNs with unstructured noise inputs (Fig. 3b). We then performed a variance decomposition to assess the unique and shared contributions of each regime (bioRNNtask and bioRNNnoise) to the prediction of empirical fMRI activity (see Variance decomposition of task-evoked and intrinsic dynamics in Materials and Methods). Using singular-value decomposition, we constructed a basis of pooled predictors from the sets of PCs derived from bioRNNtask and bioRNNnoise. We then asked how much unique fMRI variance each regime explained compared to a shared basis that captured the variance common to both the task-driven and noise-driven regimes. The results revealed that the task-driven bioRNN dynamics contained unique information predictive of fMRI activity that the shared basis did not contain (mean zsub = 1.97 ± 0.47, p = 0.002 based on a Wilcoxon signed-rank test against the subspace chance upper bound), but noise-driven dynamics were not uniquely predictive (zsub = 0.52 ± 0.14, p = 1.00). Interestingly, the shared basis was the strongest predictor of fMRI activity (zsub = 3.79 ± 1.20, p < 0.001). This result suggests that most of the bioRNNs’ prediction of empirical brain activity is carried by the shared component, i.e., the dynamics common to the task- and noise-driven regimes. Because this signal emerges whether the network is driven by structured input or by unstructured noise, it is most plausibly generated by the intrinsic dynamics of the network’s spatial embedding rather than by the input itself. However, on top of this shared, architecture-driven baseline, task input contributed additional, uniquely predictive dynamics, whereas unstructured noise did not. Together, these results indicate that the embedded geometry establishes a baseline correspondence with cortical activity, while structured task input is required to capture the aspects of empirical dynamics that geometry alone cannot produce.

In silico evidence for topology’s functional relevance

The third phase of the above hysteresis trajectory (Fig. 3a) suggested that continued refinement of hidden-layer connectivity within bioRNNs supported task learning and enabled them to maintain explanatory power of empirical brain dynamics despite departing from a simple Euclidean embedding. In this final section, we sought to explain this departure.

The topology of the human connectome is not random: it interleaves locally clustered, segregated communities with a small set of highly connected hubs that integrate information across the brain, an organizational signature of mammalian brains thought to underpin efficient neural communication and flexible cognition11,17. Critically, this complex topology is not predicted solely from brain geometry, as a network designed to minimize wiring cost alone would tend toward a regular, lattice-like organization, whereas the empirical connectome interleaves short-range clustering with a minority of costly long-range links that support global integration7,49. We therefore reasoned that the departure of our bioRNNs from geometry with task learning may reflect the emergence of brain-like topology in their underlying connectivity.

To investigate this possibility, we assessed the topology of the intermediate hidden-layer nodes (i.e., nodes not labeled as read-in or read-out) during the final phase of learning. We chose these nodes to examine topology because they fall outside the direct influence of the projection constraints on the overall network structure, which necessarily induces a tripartite structure within the hidden layer (Fig. S6). Assessing the functional connectivity within the bioRNN intermediate subnetwork, we observed patterns suggesting the presence of modules and showing a visual resemblance to empirical functional connectivity (Fig. S7).

Two neurobiological topology features clearly emerged in the intermediate hidden-layer nodes during the third phase of training. First, the mean degree of the top 20% of nodes (Fig. 4a) and the normalized rich-club coefficient (Fig. 4b) showed that bioRNNs developed hub nodes that were preferentially interconnected. Second, the clustering coefficient (Fig. 4c) and participation coefficient (Fig. 4d) revealed that bioRNNs simultaneously increased their local clustering and their cross-module communication over training. In other words, the networks became both more segregated, forming locally dense and specialized neighborhoods, and more integrated, distributing their connections across communities to enable cross-talk. This increased integration was supported by the development of long-range connections within the networks (Fig. 4e). Importantly, these long-range connections emerged despite the high costs imposed by geometry. In bioRNNs, the spatial embedding does not penalize long-range connections per se, but constrains the relative spatial patterning of connectivity, and is minimized when recurrent weights decrease with interregional distance. Thus, the emergence of long-range connectivity prior to task learning supports their critical functional role. Finally, the largest changes across all metrics occurred early in the third training phase and gradually stabilized as task accuracy increased (Fig. 4f). This result indicates that the network’s topological architecture was largely established early, before the task was mastered, but required fine-tuning to support task learning. Topological reorganization, therefore, preceded behavior rather than following it, mirroring the structure-before-function ordering seen in the hysteresis trajectory. This result suggests that acquiring a brain-like topology may play a role in task learning, rather than simply resulting from it48. Importantly, while some features of brain topology also emerged in the Masked RNNs (Fig. S8), including clustering and the participation coefficient, they were not accompanied by the same selective development of long-range connections in tandem with task performance. Furthermore, of the topological features that emerged early in training in Masked RNNs, their presence diminished substantially once high task performance was acquired (Fig. S8), whereas they remained relatively stable in bioRNNs. Critically, this pronounced reduction in topology in Masked RNNs also coincided with a reduction in the relatively small amount of fMRI activity they could explain early in training (Fig. S9). Taken together, these results suggest that only bioRNNs gave rise to sustained brain-like topology that enabled the highest levels of fMRI activity prediction.

Figure 4. Connectome-like topology emerges during training and tracks task learning.

Figure 4.

Graph-theoretic properties of the intermediate (non-projection) nodes of bioRNNs across training, with task accuracy (black) overlaid on each panel. (a) The mean degree of the top 20% of nodes rose and then plateaued, indicating the growth of strongly connected nodes (hubs). (b) The normalized rich-club coefficient rose early, precipitating task learning, before stabilizing, indicating the formation of a densely interconnected hub core. (c) The mean clustering coefficient increased monotonically, reflecting the emergence of local, segregated processing units that continued to refine throughout training. (d) The participation coefficient initially dropped and then rose, reflecting increasingly diverse cross-module connectivity (integration). (e) The mean connection length of the top 20% of edges (by length) rose sharply immediately before the RNNs learned the task, indicating that the departure from simple brain geometry was driven by changes favoring the selective development of long-range connections. (f) Rate of change of each metric as a function of training, showing that topological reorganization was concentrated in the early part of training phase III (i.e., departure from simple Euclidean embedding) and stabilized as accuracy approached its limit. Shaded bands denote 95% CIs over 100 runs per RNN class. Where present, the dashed vertical line indicates the start of the window from which we derive the displayed statistics. This was done to avoid the undesired effects of the initial large fluctuations. See Fig. S8 for a comparison with the topology trajectories of Vanilla RNNs.

DISCUSSION

How the brain’s physical geometry gives rise to its flexible functional repertoire is a central question in neuroscience. To address this question, we built spatially embedded RNNs that learn a cognitive task under neurobiological constraints and asked how geometry, connectivity, and function interrelate during learning. Our results show that an interaction between the brain’s spatial embedding and its functional inputs is critical for the emergence of brain-like task-based dynamics. By layering spatial constraints onto RNNs and allowing their topology and dynamics to emerge during training, we showed that bioRNNs could accurately predict empirically observed brain activity out-of-sample, and that this predictive ability was preceded by the acquisition of stable connectome-like topology. Four specific findings emerged. First, brain geometry conferred a learning advantage over circumscribed projections of task inputs and outputs to canonical brain systems. Second, only spatially embedded networks predicted empirical fMRI activity and recovered the principal axis of cortical organization, and this depended on the veridical arrangement of regions rather than solely on the spatial autocorrelation inherent to the underlying RNN architecture. Third, the correspondence with brain activity was acquired along a path-dependent trajectory in which geometry was laid down first and partly traded back as the task was learned. Fourth, without explicit optimization, the networks developed a connectome-like topology prior to mastering the task that was sustained thereafter.

Spatial embedding was necessary for any correspondence with empirical dynamics. Only bioRNNs exceeded the random-subspace baseline in predicting variance in fMRI activity, while Vanilla and Masked RNNs performed at chance levels. Critically, this advantage was not the simple product of the spatial autocorrelation that our distance-based learning kernel necessarily imposes on the hidden layer. When we tested bioRNNs against a geometry null in which the embedding was permuted to preserve spatial autocorrelation while breaking the correspondence with cortical locations, the null RNNs retained part of the effect, but no null geometry matched the performance of the veridical embedding. The correspondence, therefore, depended on the specific arrangement of nodes in anatomical space, not on spatial smoothness alone, consistent with the proposal that wiring-cost constraints are a fundamental organizing principle of neural systems2,7,14. More broadly, these results support previous work showing that the spatial layout of the cortex plays a critical role in shaping the large-scale activity patterns that the brain can express1.

Spatial embedding also organized the networks’ dynamics along the brain’s principal functional hierarchy. The leading principal components of bioRNN activity, but not those of Vanilla or Masked RNNs, recovered the S–A axis, and did so to a degree approaching that of empirical task fMRI. This is notable because the S–A axis was never supplied to the RNNs; it emerged from the interaction between a purely distance-based connectivity prior and task training. Critically, our results show that geometry alone did not produce this hierarchy. Early in training, when bioRNN connectivity most closely resembled the Euclidean kernel, the networks predicted empirical dynamics no better than chance; the S–A axis emerged only once task learning had shaped that geometric scaffold into functional connectivity. Cortical geometry, therefore, appears to confer the capacity for hierarchical organization, which experience then realizes, a coupling we return to below. We additionally observed a subject-specific effect: the more a bioRNN’s internal structure resembled a particular brain, the better it predicted that brain’s dynamics. This indicates that the structure–function mapping recovered by these RNNs is not solely a group-average phenomenon. A natural next question is how this experience-dependent hierarchy relates to the molecular, laminar, and transcriptomic gradients to which the S–A axis is more usually attributed, gradients that are themselves laid down under tight spatial and metabolic constraints during development41,47,50. Thus, rather than competing explanations, geometry and molecular patterning may represent coupled expressions of a shared developmental cost structure, a hypothesis that future bioRNNs seeded with empirical gradient maps could test directly.

The relationship between bioRNN constraints, task learning, and empirical brain activity revealed a multi-stage process of task mastery. The training trajectory traced a pronounced hysteresis loop in which structure was laid down before function: bioRNN–brain structural similarity rose steeply early in training, while fMRI prediction remained near chance. Prediction of empirical activity then rose sharply and largely preceded the gain in behavioral accuracy, after which structural similarity reduced to an intermediate level that both preserved high explained variance of fMRI data and allowed for task learning. Brain-like dynamics were therefore not just a fixed function of how brain-like the network geometry was: the same structural similarity value mapped onto markedly different functional predictions depending on the phase of training. This indicates that geometry sets the stage for brain-like dynamics but, by itself, does not produce them, suggesting that geometry defines the space of possible dynamics while experience selects which of those dynamics are realized.

Our variance decomposition analysis made the contribution of task input explicit. Task-evoked bioRNN dynamics carried unique predictive information about empirical fMRI activity that the shared basis did not contain, whereas noise-driven dynamics carried no unique predictive information. The shared basis was nonetheless the strongest single predictor, indicating that much of the predictive signal is common to both regimes and is attributable to the embedded architecture itself. Intrinsic, structurally determined dynamics thus supply a substantial baseline correspondence with cortical activity, but the additional component that distinguishes empirical task dynamics appears only when the network is driven by task input; unstructured noise passing through the same architecture does not recover it. This echoes the role of input-driven recurrent dynamics in shaping context- and task-dependent neural activity29,32. This result also posits cortical dynamics as a two-tiered phenomenon: in the first instance, they are predominantly shaped by geometry, which constrains the space of possible emergent dynamics; however, interactions with the environment (e.g., via task inputs) are a necessary complement and form a second tier that captures unique aspects of those dynamics.

Beyond simple cortical geometry, the topology that emerged over training tracked each network’s task learning. Throughout training, bioRNNs developed a preferentially connected hub core, evident as rising node degree and a rising normalized rich-club coefficient, together with increasing clustering and participation, and a selective development of long-range connections. In other words, the bioRNNs acquired both local segregation and cross-module integration, a defining feature of small-world cortical organization17,51,52. Crucially, these features emerged most rapidly during the earliest phase of learning and then stabilized, indicating that a cortex-like topology was laid down before task mastery rather than arising as its consequence. This ordering mirrors cortical development, in which hub regions and rich-club connections are established early and subsequently refined53,54. Our results, therefore, suggest that the brain’s hub-and-rich-club scaffold can be laid down before, and in the service of, the functions it is later refined to support. Importantly, our spatially constrained networks recovered these canonical cortical wiring motifs without explicit optimization for them, further bolstering the idea that geometric wiring constraints strongly shape the connectivity patterns that can emerge in the brain2,7,27. Notably, although some topological features also arose in Masked RNNs, only in bioRNNs did they emerge together with the selective lengthening of connections, in step with task learning, to predict empirical brain activity, indicating that brain geometry and projection constraints interact to drive the specific pattern of cortical organization during learning.

More broadly, our results point to the necessity of importing brain structure into computational modeling tools. They also make a strong case for the potential of bioRNNs as in silico testbeds for counterfactual experiments, for asking “what if” questions about brain structure and function that cannot be posed in the living brain. For example, one could silence a specific projection, rescale the wiring-cost penalty, or substitute one individual’s geometry for another’s and read out the causal consequences for dynamics and topology. These experiments would extend connectome-based reservoir and constrained-RNN approaches23,27 from fixed to manipulable architectures. By independently manipulating spatial embedding, input structure, and connectivity, bioRNNs offer future studies a tractable platform for causally probing how anatomy and experience jointly give rise to neural dynamics.

Several limitations bound these conclusions. First, our RNNs were evaluated against BOLD fMRI data, an indirect and temporally coarse proxy for neural activity; the correspondence we report is between low-dimensional summaries of RNN hidden states and of BOLD dynamics, not between RNN units and spiking activity. Nevertheless, the low-dimensional summaries we compare are precisely the level at which large-scale fMRI organization is expressed, so this coarse-graining is well matched to the question we ask here, and in future studies. Second, we constrained connectivity using a single Euclidean distance kernel. This simplification omits white-matter connectivity, myelination, and cytoarchitectonic gradients, each of which also shapes cortical dynamics. How each of these constraints alters the correspondence between simulated and empirical dynamics is an open question. But, simple geometry is an established and reproducible predictor of cortical connectivity2,18, making it a principled and parsimonious starting point onto which richer constraints can later be layered. Third, although the DMS-D task engages working memory, temporal integration, perceptual decision making, and inhibitory control, it does not span the full range of cognitive demands; whether the same training trajectory holds across task families remains untested. Yet, it is notable that our in silico bioRNNs trained on one working-memory task predicted fMRI activity from a different working-memory task in humans, in vivo, suggesting that the correspondence may be anchored in shared cognitive demands rather than in superficial task features. It also suggests that future work that trains bioRNNs on multimodal tasks (e.g., ones with simultaneous visual and auditory inputs) could further increase their biological relevance.

CONCLUSION

Together, our findings demonstrate that physical geometry and cognitive inputs play distinct and complementary roles in the emergence of brain organization. While geometry constrains the space of possible dynamics, cognitive inputs determine which of those dynamics are expressed. Our findings further situate topology as the intermediate level of organization through which a geometrically constrained system reconciles the competing demands of wiring cost and computation, thereby enabling brain-like dynamics and cognitive performance to be realized simultaneously. By making the interactions among these three features observable and manipulable, bioRNNs turn long-standing questions about structure and function into direct, manipulable investigations and offer a versatile in silico complement to human neuroimaging for investigating how the brain’s structure shapes its function. They additionally offer a potential avenue for performing individualized in silico counterfactual experiments that observational studies alone cannot achieve.

METHODS

For the analyses described herein, we used coding assistance from a large language model (Claude Opus v4.6 and v4.8, Anthropic). We manually reviewed and modified all the code used in the analyses and assume full responsibility for the results.

RNN overview

We compared three classes of recurrent neural network (RNN) that together form a graded hierarchy of biological constraint: Vanilla RNNs, Masked RNNs, and spatially embedded biophysical RNNs (bioRNNs). All three were instances of the same single-layer recurrent architecture and differed only in two configuration choices: whether their inputs and outputs were restricted to anatomically defined subsets of units (projection constraints), and whether their recurrent connectivity was shaped by a neurobiological spatial prior (brain geometry). Vanilla RNNs had neither constraint, Masked RNNs had projection constraints only, and bioRNNs had both projection constraints and a geometry-based prior on their recurrent weights. For each class, we trained 100 randomly initialized networks (runs). Because the classes were identical in every other respect, this design isolated the contribution of each constraint: the difference between Vanilla and Masked networks reflected the effect of projection constraints, whereas the difference between Masked and bioRNNs reflected the effect of the geometry prior alone.

Network architecture

Each network consisted of 100 recurrently connected hidden units and was modeled as a discretized continuous-time (leaky) RNN. At each timestep, the hidden state, h, evolved as

ht+1=(1-α)ht+αfWhhht+Wihut+b+ξt, (1)

where Wih and Whh are the input-to-hidden and hidden-to-hidden weight matrices, ut is the task input, b is a bias term, f is the hyperbolic-tangent nonlinearity, and α is the temporal integration factor. We set α=0.1, resulting in a single-unit time constant τ=Δtα=500ms at an integration step of Δt=50ms. The term ξt is independent Gaussian recurrent noise added to the pre-activation hidden state during training only, with an effective standard deviation scaled as

σeff=σrec2α, (2)

with σrec=0.05. We initialized the recurrent weights from a uniform distribution over the interval (−0.01, 0.01), and the remaining parameters used the default initialization. A linear readout mapped the hidden state to the task output at every timestep.

We placed the 100 hidden units in one-to-one correspondence with the 100 left-hemisphere parcels of the Schaefer 200-region, 7-network cortical atlas33. This mapping defined the spatial priors described below and was used to project network activity onto the cortical surface for comparison with empirical data.

Projection constraints

In Masked RNN and bioRNN networks, task inputs entered the network only through a fixed subset of read-in nodes, and the decision was read out only from a separate subset of read-out nodes. Read-in nodes corresponded to the visual network (14 nodes), and read-out nodes corresponded to the default-mode network (27 nodes), following the Schaefer atlas network assignments. We enforced these constraints using binary masks: the input mask set the input weights of all non-visual nodes to zero, and the output mask set the readout weights of all non-default-mode nodes to zero. We reapplied the masks at every forward pass to prevent gradient updates from reintroducing masked connections. We left the recurrent weight matrix Whh fully connected and did not subject it to these masks; projection constraints therefore restricted only which units received the stimulus and which drove the response, not the internal connectivity. Vanilla RNNs received inputs and produced outputs from all units, so they had no projection constraints.

Spatial embedding and regularization

Left unconstrained, recurrent weights in RNNs can grow without bound and/or overfit. Thus, as is standard for RNN training, we regularized the hidden-to-hidden connectivity with a global L2 penalty added to the task loss. We used a variant of this penalty to constrain the network geometry27. The three RNN classes were subject to the same L2 penalty on the recurrent weights and only differed in whether that penalty incorporated cortical geometry. In all cases, a regularization term was added to the task loss and scaled by a fixed weight λ=0.002.

For Vanilla and Masked networks, the recurrent weights penalty was a node-scaled L2 term,

LW=λWhh2n, (3)

with n the number of nodes. This term applies a uniform weight penalty that contains no spatial information.

For bioRNNs, the penalty additionally aligned the recurrent connectivity with cortical geometry. We first computed the pairwise Euclidean distance matrix between the 100 left-hemisphere parcel centroids and normalized it by its mean off-diagonal value to obtain a distance kernel, K. We then defined a spatial proximity matrix, S=1-K. Thus, the bioRNN penalty combined a geometry term with the same scaled L2 decay according to

LW=λ1-rWhh,S+Whh2n, (4)

where rWhh,S is the Pearson correlation between the off-diagonal entries of the recurrent weight matrix and those of the similarity matrix. Minimizing this term drove the recurrent weights to co-vary with cortical proximity, so that nearby parcels in Euclidean space tended toward stronger coupling and more distant parcels toward weaker coupling. Because the scaled L2 term was identical across classes, the geometry term was the sole factor distinguishing bioRNNs from Masked networks.

Task structure and training

We trained all networks on a delayed match-to-sample with distractors (DMS-D) task31 implemented in the NeuroGym toolbox38 and modeled after Yang et al.32. On each trial, the network first received a fixation input, followed by a sample stimulus, and then three test stimuli were presented in sequence, separated by delay periods (see example trial schematic in Fig. 1d). Stimuli were encoded across 32 input channels representing a one-dimensional circular feature, together with a fixation channel, giving a 33-dimensional observation. The sample and each test stimulus were presented for 500 ms, with 1,000 ms delays, at an integration step of Δt=50ms. The network was required to produce a match response only when a test stimulus exactly matched the sample and to withhold responding otherwise. Successful performance, therefore, required maintaining the sample in working memory across the delays, comparing each test stimulus to it when presented, and inhibiting responses to non-matching (distractor) tests, thereby engaging working memory, temporal integration, perceptual decision-making, and inhibitory control.

RNN training and learning-speed quantification

We trained the RNNs using gradient descent and the Adam optimizer55 with a learning rate of 0.001. We implemented all the RNNs in Python and trained them using PyTorch’s automatic differentiation. The task training objective (loss) was the cross-entropy between the per-timestep readout and the target action sequence. Thus, the loss that the RNNs were trained to minimize combined the task loss and recurrent weight regularization (spatial penalty) terms into a single overall loss,

L=LW+Ltask. (5)

At each epoch, we produced a batch containing 32 sequences, which we split evenly into 16 training and 16 held-out validation sequences. Each sequence contained five consecutive task trials drawn from a per-run trial stream with a run-specific random seed. Initialization, trial stream, and recurrent-noise draws were determined by the run index, so that a given run index reproduced the same training conditions across classes and geometry permutations (see section on null testing), allowing us to isolate the observed effects to the spatial constraints. We trained the RNNs for 60,000 epochs and periodically checkpointed and evaluated their task accuracy on a fixed, independently seeded battery of 100 trials. A trial was scored as correct only when the network elicited the correct action within the permitted response window (i.e., during the presentation of the matching test stimulus) and withheld responses otherwise. Training, validation, and test trials were drawn from disjoint random-seed ranges to prevent overlap.

We quantified RNN learning speed by fitting a logistic function to each run’s accuracy trajectory (Fig. S1), and defining the convergence epoch as the point at which the fitted curve reached 95% of that run’s asymptote. We then defined a per-RNN class training criterion as the 95th percentile of these per-run convergence epochs. We compared the three RNN classes using Wilcoxon signed-rank test with Holm-Bonferroni correction and report effect sizes using the matched-pairs rank-biserial correlation. We additionally established a global evaluation epoch to perform all subsequent analyses, defined as the epoch at which all RNNs across all classes had reached stable performance (asymptote). This resulted in epoch 40,000 being the global learning convergence point and was therefore the epoch at which we performed all analyses (except those that assessed the RNNs across epochs).

Empirical fMRI data

We compared RNN dynamics against task functional MRI (fMRI) obtained from 100 typical young adults (50% male; 28.25 ± 3.67 years) from the Human Connectome Project39. Minimally pre-processed task fMRI time series were drawn from the working-memory N-back paradigm43. Time series were parcellated into the 100 left-hemisphere regions of the Schaefer-200, 7-network atlas to match the network nodes, and global signal regression was applied to attenuate widespread, non-neural fluctuations before the parcel-wise time series were extracted for comparison with the RNN dynamics. As a result, each subject’s task fMRI data was converted into a [time × parcels] matrix for subsequent analysis.

Dimensionality reduction of network dynamics

To capture the dominant, behaviorally relevant modes of each network’s high-dimensional activity, we summarized hidden-state dynamics using principal component analysis (PCA)40. First, we tested each fully trained network on 100 task trials and concatenated the resulting hidden-state time series into a single [time × nodes] matrix. We ran PCA on this matrix using Scikit-learn’s56 PCA function with the exact solver, retaining the first five PCs, thereby extracting the low-dimensional, dominant modes of activity across nodes.

We considered two cognitive input regimes: a task regime (RNNtask), in which the trained network was driven by the DMS-D task inputs, and a noise regime (RNNnoise), in which it was driven by unstructured Gaussian noise (mean 0.5, standard deviation 0.3, with the fixation channel held fixed) in the absence of any task structure. The five-component PCA subspace obtained in each regime was used for the variance-explained analyses below.

fMRI variance explained and the random-subspace baseline

We quantified how well each network’s PC subspace captured empirical brain dynamics as the fraction of a subjecťs fMRI temporal variance that lies within that subspace. We centered each subject’s parcellated fMRI time series on its own temporal mean (per parcel), projected it onto the five-PC RNN subspace, and computed the fraction of temporal variance explained (VE). We did so for each combination of RNN class (n = 3), training run (n = 100), and subject (n = 100). Averaging this fraction across subjects gave the network’s VE for a single RNN run.

However, raw VE values cannot be interpreted directly because any five-dimensional subspace captures a non-trivial fraction of variance purely by virtue of its dimensionality44. To calibrate against this chance level, we established a random-subspace baseline. We drew 1,000 independent, uniformly random, five-dimensional orthonormal subspaces of a matched 100-dimensional space, each obtained as the orthonormal factor Q of the QR decomposition of a 100 × 5 matrix of i.i.d. standard-Gaussian entries. For every random subspace, we recomputed the identical subject-averaged VE metric, producing a null distribution of VE values expected in the absence of any genuine network–brain correspondence. We then expressed the network’s VE as a z-score relative to this null,

zsub=VE-μnullσnull, (6)

with μnull and σnull the mean and standard deviation of the 1,000 null VE values. Therefore, zsub reported, in standard-deviation units, how far a network’s PC subspace exceeded what an arbitrary subspace of matched dimensionality achieved: zsub≈0 is chance-level correspondence, whereas a large positive zsub indicates that the specific directions spanned by the network’s dynamics, not simply their number, align with the structure of empirical fMRI. We applied the same approach when tracking zsub across the bioRNN training trajectory (hysteresis plot, Fig. 3a), and in the variance-decomposition analysis (Fig. 3b).

Correspondence with the cortical hierarchy

We assessed whether the RNNs’ dynamics recapitulated the brain’s principal functional hierarchy, summarized by the sensorimotor–association (S–A) axis47. For each RNN class, we regressed the S–A axis values of the 100 left-hemisphere parcels onto the weights (spatial loadings) of the first five RNN PCs (averaged across RNN runs) and recorded the explained variance (adj. R2). For comparison, we performed the same regression using the PCs derived directly from the empirical N-back task fMRI data (averaged across subjects), providing an empirical benchmark for the extent to which low-dimensional dynamics align with the S–A axis.

Geometry null testing

To test whether the bioRNNs’ correspondence with empirical dynamics depended on the veridical anatomical arrangement of nodes rather than on the spatial autocorrelation that any distance-based kernel necessarily imposes, we constructed a geometry null. We generated spin permutations of the 100 left-hemisphere parcels by applying a uniformly random, three-dimensional rotation to their coordinates on the FreeSurfer spherical surface, and reassigning each rotated parcel to a distinct original parcel by optimal (Hungarian) bijective matching13,46,57. This procedure preserved the spatial autocorrelation of the embedding while breaking its correspondence to the exact cortical layout. We applied each resulting permutation as a distance kernel to fully retrain a bioRNN under the permuted geometry, while keeping the same task and projection constraints.

We trained 200 such permuted-geometry ensembles up to 40,000 epochs, the point at which networks had reliably reached the training criterion, and that served as the timepoint for all previous analyses. For every geometry (permutation), we used the same five run indices, and we chose those indices so that, in the veridical RNN, their VE values spanned the full range of the 100-run distribution. Because initialization, trial stream, and recurrent noise are all fixed by the run index (see RNN training), a given run index reproduces the identical training environment across every geometry, so that any difference between geometries is attributable to geometry alone. Therefore, we fully retrained 1,000 RNNs spanning 200 permuted geometries with five runs each.

In this design, VE could change for two reasons: the geometry itself and the run-to-run variability of training. Because our design was hierarchical, with multiple training runs nested within each permuted geometry, the per-run VE values were not independent, and pooling them would have conflated geometry effects with training variability, risking pseudo-replication58. Variance-components (linear mixed-effects) models are the standard approach for such nested data, partitioning variance into between-group (geometry) and within-group (training noise) components. Because the same five run indices recurred across all geometries, runs and geometries were crossed factors59; and because those indices were a small, deliberately chosen set rather than a random sample of runs, we modeled run as a fixed effect. We therefore fit a mixed-effects model using statsmodels60,

VE~run+(1|permutation), (7)

which estimated and removed the average effect of each run index (shared across geometries) before partitioning the remaining variance into a between-geometry component (σgeom) and a within-geometry residual (σtrain). Removing this deliberate run spread ensured that σgeom reflected only true geometry-to-geometry differences and σtrain only residual training noise. We then asked whether the veridical geometry was an outlier relative to the distribution of permuted geometries, expressing its mean VE as a z-score against the between-geometry spread,

z=VEreal-μnullσgeom. (8)

We converted this z-score into a one-sided p-value under the normal distribution; this parametric tail was justified because the distribution of permuted-geometry means did not deviate significantly from normality (Shapiro-Wilk p = 0.109). A cluster bootstrap (2,000 resamples over geometries and over the veridical RNN’s runs) then provided a 95% confidence interval on z (and, by association, on p). As an assumption-free check, the veridical geometry’s VE exceeded the Ves of the 200 permuted geometries (run-averaged).

Training trajectory (hysteresis) analysis

To characterize how structure and function co-evolved during training, we tracked each bioRNN across 100 evenly spaced training checkpoints, in addition to the initial state (epoch zero). At each checkpoint, we computed two quantities: (i) structural similarity to the embedding, and (ii) fMRI variance explained. Structural similarity was calculated as the cosine similarity between the off-diagonal entries of Whh and the corresponding entries of the spatial proximity matrix, S, computed over all 100 nodes. fMRI prediction was the fMRI variance-explained z-score (zsub) defined above, computed against a null of 1,000 random subspaces at each checkpoint. We also recorded task accuracy from the fixed test battery. We averaged these trajectories across the 100 runs and visualized fMRI prediction against structural similarity, coloring the trajectory by (log) task accuracy. Then, visually, we partitioned the trajectory into three phases: (i) the first phase spanned the RNNs’ initial rapid shift toward a high structural similarity value while its zsub remained below chance; (ii) the second phase was defined by the RNNs’ rapid shift toward a high zsub while its structural similarity to the embedding remained high; (iii) the final phase was defined as the one during which structural similarity began dropping and zsub remained high.

Variance decomposition of task-evoked and intrinsic dynamics

To isolate the contribution of structured task input to the bioRNN predictive dynamics, we compared fully trained bioRNNs driven by task inputs against the same networks driven by unstructured noise (the task and noise regimes above). We applied a commonality analysis, a variance decomposition method that separates the variance explained uniquely by each predictor set from the variance they explain jointly61,62. For each regime, we obtained a five-dimensional PC loading matrix (as we did in the initial fMRI prediction analysis) and formed a pooled basis by performing a singular value decomposition of the concatenated task and noise loadings (resulting in a basis of up to 10 dimensions). The task-only and noise-only subspaces each define the directions in fMRI space that one input regime can explain, whereas the pooled basis represents everything either regime can explain; therefore, contrasting the pooled fit against each regime-specific fit isolates the variance that is unique to task input, unique to noise input, or shared between them. For each subject and each RNN run, we computed the fraction of variance in that subject’s fMRI time series captured by the task-only subspace (VEtask), the noise-only subspace (VEnoise), and the pooled subspace (VEpooled). We then partitioned these into a unique-task component (VEtask_only), a unique-noise component (VEnoise_only), and a shared component (VEshared):

VEtask_only=VEpooled-VEnoise, (9)
VEnoise_only=VEpooled-VEtask, (10)
VEshared=VEtask+VEnoise-VEpooled. (11)

Again, significance was assessed against a null of 1,000 random orthonormal subspaces.

Emergent network topology

We characterized the graph-theoretic organization of the intermediate nodes, i.e., those designated as neither read-in nor read-out, and therefore outside the direct influence of the projection constraints. From the recurrent weight submatrix among these units, we built a graph by taking the absolute value of each connection, zeroing the diagonal, and retaining only the strongest 20% of edges. Because the recurrent weights are directed, the resulting graph is also weighted and directed; we therefore performed the analyses with directed, weighted graph metrics computed using the Python implementation of the Brain Connectivity Toolbox (bctpy)63.

We quantified five aspects of network organization. To index the emergence of hubs, we computed each node’s total (in-plus-out) degree (bctpy: degrees_dir) and took the mean degree of the top 20% highest-degree nodes (Fig. 4a). To test whether those hubs formed an interconnected core, we computed the weighted directed rich-club coefficient (bctpy: rich_club_wd) and normalized it against an ensemble of 1,000 degree-preserving randomized graphs (bctpy: randmio_dir), following the normalized rich-club approach of van den Heuvel & Sporns17 (Fig. 4b). To measure local segregation, we computed the mean weighted directed clustering coefficient (bctpy: clustering_coef_wd)64 (Fig. 4c). To measure cross-module integration, we first partitioned the graph into communities by directed modularity maximization (bctpy: modularity_dir)65, then computed the mean participation coefficient across nodes with respect to that partition (bctpy: participation_coef)66 (Fig. 4d). The fifth metric captured the physical cost of connectivity; we computed the mean connection length of the retained (top 20%) edges, defined as the mean Euclidean distance between the parcel centroids that each edge connects, using the same inter-regional distance matrix that defined the spatial embedding (Fig. 4e).

We evaluated all five metrics at each training checkpoint spanning the third phase of the hysteresis trajectory (see Training trajectory analysis). To summarize the timing of topological change, we rescaled each metric by min-max normalizing its values across training to the unit interval, so that metrics with different ranges could be compared on a common scale, and then calculated their temporal derivative with respect to training epoch (Fig. 4f).

Statistical analysis and reproducibility

Plots are generally generated using mean values for group summaries and 95% confidence intervals, computed as 1.96 times the standard error of the mean, as shaded bands. For values reported in the text, unless otherwise stated, we report the mean ± SD.

ACKNOWLEDGEMENTS

LP was supported by the National Institute Of Mental Health of the National Institutes of Health under Award Number R00MH127296. Research reported in this publication was also supported by Rutgers University through the Rutgers Health BMIHAI PAIR Postdoctoral Fellowship. WUB received partial support from a seed project funded by the Office of the Vice Provost for Research at Rutgers University. The content is solely the responsibility of the authors and does not necessarily represent the official views of the institution. Data were provided in part by the Human Connectome Project, WU-Minn Consortium (Principal Investigators: David Van Essen and Kamil Ugurbil; 1U54MH091657) funded by the 16 NIH Institutes and Centers that support the NIH Blueprint for Neuroscience Research; and by the McDonnell Center for Systems Neuroscience at Washington University.

DATA AND CODE AVAILABILITY

All RNNs were implemented in Python (v3.12.11) using PyTorch (v2.7.1)67. The RNNs were implemented as a custom module based on the PyTorch RNN class and optimized using PyTorch’s automatic differentiation engine (see RNN training). The DMS-D task was simulated using NeuroGym (v2.1.0)38. Training was run on a Mac Studio with the M3 Ultra chip. The code used in this paper for RNN training and all reported analyses is available in the neuro_rnn GitHub repository (https://github.com/LindenParkesLab/neuro_rnn). The human fMRI data is part of the publicly available Human Connectome Project.

REFERENCES

  • 1.Pang J. C. et al. Geometric constraints on human brain function. Nature 618, 566–574 (2023). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 2.Stiso J. & Bassett D. S. Spatial embedding imposes constraints on neuronal network architectures. Trends in Cognitive Sciences 22, 1127–1142 (2018). [DOI] [PubMed] [Google Scholar]
  • 3.Bassett D. S. & Sporns O. Network neuroscience. Nature Neuroscience 20, 353–364 (2017). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 4.Betzel R. F. et al. Structural, geometric and genetic factors predict interregional brain connectivity patterns probed by electrocorticography. Nat Biomed Eng 3, 902–916 (2019). [DOI] [PubMed] [Google Scholar]
  • 5.Fotiadis P. et al. Structure–function coupling in macroscale human brain networks. Nat. Rev. Neurosci. 25, 688–704 (2024). [DOI] [PubMed] [Google Scholar]
  • 6.Honey C. J. et al. Predicting human resting-state functional connectivity from structural connectivity. Proceedings of the National Academy of Sciences 106, 2035–2040 (2009). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 7.Kaiser M. & Hilgetag C. C. Nonoptimal component placement, but short processing paths, due to long-distance projections in neural systems. PLOS Computational Biology 2, e95 (2006). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 8.Mišić B. et al. Network-level structure-function relationships in human neocortex. Cereb Cortex 26, 3285–3296 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 9.Suárez L. E., Markello R. D., Betzel R. F. & Misic B. Linking structure and function in macroscale brain networks. Trends in Cognitive Sciences 24, 302–315 (2020). [DOI] [PubMed] [Google Scholar]
  • 10.Young M. P. Objective analysis of the topological organization of the primate cortical visual system. Nature 358, 152–155 (1992). [DOI] [PubMed] [Google Scholar]
  • 11.Bullmore E. & Sporns O. Complex brain networks: graph theoretical analysis of structural and functional systems. Nat Rev Neurosci 10, 186–198 (2009). [DOI] [PubMed] [Google Scholar]
  • 12.Uddin L. Q. Cognitive and behavioural flexibility: neural mechanisms and clinical considerations. Nat Rev Neurosci 22, 167–179 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 13.Vázquez-Rodríguez B. et al. Gradients of structure–function tethering across neocortex. Proceedings of the National Academy of Sciences 116, 21219–21227 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 14.Bullmore E. & Sporns O. The economy of brain network organization. Nat Rev Neurosci 13, 336–349 (2012). [DOI] [PubMed] [Google Scholar]
  • 15.Catani M. & Thiebaut de Schotten M. Atlas of Human Brain Connections. (OUP Oxford, 2012). doi: 10.1093/med/9780199541164.001.0001. [DOI] [Google Scholar]
  • 16.Schmahmann J. D. & Pandya D. N. Fiber Pathways of the Brain. (Oxford University Press, Oxford, 2006). [Google Scholar]
  • 17.van den Heuvel M. P. & Sporns O. Rich-club organization of the human connectome. J. Neurosci. 31, 15775–15786 (2011). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 18.Roberts J. A. et al. The contribution of geometry to the human connectome. NeuroImage 124, 379–393 (2016). [DOI] [PubMed] [Google Scholar]
  • 19.Preti M. G. & Van De Ville D. Decoupling of brain function from structure reveals regional behavioral specialization in humans. Nat Commun 10, 4747 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 20.Betzel R. F. et al. Generative models of the human connectome. NeuroImage 124, 1054–1064 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 21.Oldham S. et al. Modeling spatial, developmental, physiological, and topological constraints on human brain connectivity. Science Advances 8, eabm6127 (2022). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 22.Vértes P. E. et al. Simple models of human brain functional networks. Proceedings of the National Academy of Sciences 109, 5868–5873 (2012). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 23.Suárez L. E., Richards B. A., Lajoie G. & Misic B. Learning function from structure in neuromorphic networks. Nature Machine Intelligence 3, 771–786 (2021). [Google Scholar]
  • 24.Chaudhuri R., Knoblauch K., Gariel M.-A., Kennedy H. & Wang X.-J. A large-scale circuit mechanism for hierarchical dynamical processing in the primate cortex. Neuron 88, 419–431 (2015). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 25.Yang G. R. & Wang X.-J. Artificial neural networks for neuroscientists: A primer. Neuron 107, 1048–1070 (2020). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 26.Abulikemu S., Radmard P., Mamalakis M. & Suckling J. Association-sensory spatiotemporal hierarchy and functional gradient-regularised recurrent neural network with implications for schizophrenia. npj Syst Biol Appl 12, 100 (2026). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 27.Achterberg J., Akarca D., Strouse D. J., Duncan J. & Astle D. E. Spatially embedded recurrent neural networks reveal widespread links between structural and functional neuroscience findings. Nat Mach Intell 5, 1369–1381 (2023). [Google Scholar]
  • 28.Kim J. Z., Larsen B. & Parkes L. Shaping dynamical neural computations using spatiotemporal constraints. Biochemical and Biophysical Research Communications 728, 150302 (2024). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 29.Mante V., Sussillo D., Shenoy K. V. & Newsome W. T. Context-dependent computation by recurrent dynamics in prefrontal cortex. Nature 503, 78–84 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 30.Wang P. Y., Sun Y., Axel R., Abbott L. F. & Yang G. R. Evolving the olfactory system with machine learning. Neuron 109, 3879–3892.e5 (2021). [DOI] [PubMed] [Google Scholar]
  • 31.Miller E. K., Erickson C. A. & Desimone R. Neural mechanisms of visual working memory in prefrontal cortex of the macaque. J. Neurosci. 16, 5154–5167 (1996). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 32.Yang G. R., Joglekar M. R., Song H. F., Newsome W. T. & Wang X.-J. Task representations in neural networks trained to perform many cognitive tasks. Nature Neuroscience 22, 297–306 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 33.Schaefer A. et al. Local-global parcellation of the human cerebral cortex from intrinsic functional connectivity MRI. Cerebral Cortex 28, 3095–3114 (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 34.Felleman D. J. & Van Essen D. C. Distributed hierarchical processing in the primate cerebral cortex. Cerebral Cortex 1, 1–47 (1991). [DOI] [PubMed] [Google Scholar]
  • 35.Mesulam M. M. From sensation to cognition. Brain 121, 1013–1052 (1998). [DOI] [PubMed] [Google Scholar]
  • 36.Diamond A. Executive functions. Annual Review of Psychology 64, 135–168 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 37.Gold J. I. & Shadlen M. N. The neural basis of decision making. Annual Review of Neuroscience 30, 535–574 (2007). [DOI] [PubMed] [Google Scholar]
  • 38.Molano-Mazón M. et al. NeuroGym: An open resource for developing and sharing neuroscience tasks. Preprint at 10.31234/osf.io/aqc9n (2022). [DOI] [Google Scholar]
  • 39.Van Essen D. C. et al. The WU-Minn Human Connectome Project: an overview. NeuroImage 80, 62–79 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 40.Cunningham J. P. & Yu B. M. Dimensionality reduction for large-scale neural recordings. Nat Neurosci 17, 1500–1509 (2014). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 41.Huntenburg J. M., Bazin P.-L. & Margulies D. S. Large-scale gradients in human cortical organization. Trends in Cognitive Sciences 22, 21–31 (2018). [DOI] [PubMed] [Google Scholar]
  • 42.Margulies D. S. et al. Situating the default-mode network along a principal gradient of macroscale cortical organization. Proc. Natl. Acad. Sci. U.S.A. 113, 12574–12579 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 43.Barch D. M. et al. Function in the human connectome: Task-fMRI and individual differences in behavior. NeuroImage 80, 169–189 (2013). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 44.Elsayed G. F., Lara A. H., Kaufman M. T., Churchland M. M. & Cunningham J. P. Reorganization between preparatory and movement population responses in motor cortex. Nat Commun 7, 13239 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 45.Elsayed G. F. & Cunningham J. P. Structure in neural population recordings: an expected byproduct of simpler phenomena? Nat Neurosci 20, 1310–1318 (2017). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 46.Alexander-Bloch A. F. et al. On testing for spatial correspondence between maps of human brain structure and function. NeuroImage 178, 540–551 (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 47.Sydnor V. J. et al. Neurodevelopment of the association cortices: Patterns, mechanisms, and implications for psychopathology. Neuron 109, 2820–2846 (2021). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 48.Zador A. M. A critique of pure learning and what artificial neural networks can learn from animal brains. Nat Commun 10, 3770 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 49.Watts D. J. & Strogatz S. H. Collective dynamics of ‘small-world’ networks. Nature 393, 440–442 (1998). [DOI] [PubMed] [Google Scholar]
  • 50.Burt J. B. et al. Hierarchy of transcriptomic specialization across human cortex captured by structural neuroimaging topography. Nat Neurosci 21, 1251–1259 (2018). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 51.Bertolero M. A., Yeo B. T. T. & D’Esposito M. The modular and integrative functional architecture of the human brain. Proceedings of the National Academy of Sciences 112, E6798–E6807 (2015). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 52.Sporns O. & Betzel R. F. Modular brain networks. Annual Review of Psychology 67, 613–640 (2016). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 53.Grayson D. S. & Fair D. A. Development of large-scale functional networks from birth to adulthood: A guide to the neuroimaging literature. NeuroImage 160, 15–31 (2017). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 54.Oldham S. & Fornito A. The development of brain network hubs. Developmental Cognitive Neuroscience 36, 100607 (2019). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 55.Kingma D. P. & Ba J. Adam: a method for stochastic optimization. Preprint at 10.48550/arXiv.1412.6980 (2015). [DOI] [Google Scholar]
  • 56.Pedregosa F. et al. Scikit-learn: machine learning in Python. Journal of Machine Learning Research 12, 2825–2830 (2011). [Google Scholar]
  • 57.Kuhn H. W. The Hungarian method for the assignment problem. Naval Research Logistics 2, 83–97 (1955). [Google Scholar]
  • 58.Aarts E., Verhage M., Veenvliet J. V., Dolan C. V. & van der Sluis S. A solution to dependency: using multilevel analysis to accommodate nested data. Nat Neurosci 17, 491–496 (2014). [DOI] [PubMed] [Google Scholar]
  • 59.Baayen R. H., Davidson D. J. & Bates D. M. Mixed-effects modeling with crossed random effects for subjects and items. Journal of Memory and Language 59, 390–412 (2008). [Google Scholar]
  • 60.Seabold S. & Perktold J. Statsmodels: econometric and statistical modeling with Python. in 92–96 (Austin, Texas, 2010). doi: 10.25080/Majora-92bf1922-011. [DOI] [Google Scholar]
  • 61.Nimon K. F. & Oswald F. L. Understanding the results of multiple linear regression: beyond standardized regression coefficients. Organizational Research Methods 16, 650–674 (2013). [Google Scholar]
  • 62.Ray-Mukherjee J. et al. Using commonality analysis in multiple regressions: a tool to decompose regression effects in the face of multicollinearity. Methods Ecol Evol 5, 320–328 (2014). [Google Scholar]
  • 63.Rubinov M. & Sporns O. Complex network measures of brain connectivity: uses and interpretations. NeuroImage 52, 1059–1069 (2010). [DOI] [PubMed] [Google Scholar]
  • 64.Fagiolo G. Clustering in complex directed networks. Phys. Rev. E 76, 026107 (2007). [DOI] [PubMed] [Google Scholar]
  • 65.Leicht E. A. & Newman M. E. J. Community structure in directed networks. Phys. Rev. Lett. 100, 118703 (2008). [DOI] [PubMed] [Google Scholar]
  • 66.Guimerà R. & Nunes Amaral L. A. Functional cartography of complex metabolic networks. Nature 433, 895–900 (2005). [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 67.Paszke A. et al. PyTorch: an imperative style, high-performance deep learning library. Preprint at 10.48550/arXiv.1912.01703 (2019). [DOI] [Google Scholar]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Data Availability Statement

All RNNs were implemented in Python (v3.12.11) using PyTorch (v2.7.1)67. The RNNs were implemented as a custom module based on the PyTorch RNN class and optimized using PyTorch’s automatic differentiation engine (see RNN training). The DMS-D task was simulated using NeuroGym (v2.1.0)38. Training was run on a Mac Studio with the M3 Ultra chip. The code used in this paper for RNN training and all reported analyses is available in the neuro_rnn GitHub repository (https://github.com/LindenParkesLab/neuro_rnn). The human fMRI data is part of the publicly available Human Connectome Project.


Articles from bioRxiv are provided here courtesy of Cold Spring Harbor Laboratory Preprints

RESOURCES