Determining shared dynamics during threat processing. Switching linear dynamical systems (SLDS) were used to model fMRI time series data (Yt) from a set of brain regions of interest (ROIs). The framework assumes that time series data can be segmented into a set of discrete states. The model represents brain signals in terms of a set of latent variables (Xt). For each state k the temporal evolution of the system is specified via a linear dynamical system with both intrinsic and input-related components. In the diagram, the system starts in state j (white star) and transitions to state k (the colored patches in the middle represent the subspaces associated with the two states). In state k, the system evolves according to the dynamics matrix Ak and input contributions (Vk). Overall, as states switch temporally, so does the corresponding linear dynamical system governing the system’s trajectory.

Brain states, state transitions, and input stimuli. Stimuli were categorized into 20 bins based on circle distance and movement direction: A1-A10 for approach, R1-R10 for retreat (1 indicates circles are farthest and 10 indicates circle collision). (A) Table entries indicate the probability of being in a state given the input stimulus category. (B) Table entries indicate the probability of a state transition given the input stimulus category. In both tables, cells highlighted in red indicate states/transitions significantly associated with the corresponding stimulus category (p < 0.05, corrected for multiple comparisons). The color scale indicates probability.

Voxelwise state activity maps and state contrast maps. State activity maps for STATE 4 and STATE 5 and the contrast of the two states. Maps were corrected for multiple comparisons by thresholding voxels at p < 0.001 and at the cluster level at p < 0.05.

Region and network responses during state transitions. Vertical lines indicate the time of state transition. State transitions are arranged in a chained manner: STATE 1 ↦ STATE 3 ↦ STATE 5 ↦ STATE 4 ↦ STATE 3 ↦ STATE 2 ↦ STATE 1 ↦ STATE 4 ↦ STATE 5 to facilitate continuity in reading responses across state transitions. Error bars correspond to the 95% confidence interval based on the standard error of the mean across participants.

Attractor maps. State attractors projected onto the space of regions of interest (85 ROIs) visualized on a brain surface map. At each ROI, the color scale represents activity strength at the attrator’s fixed point. ROI boundaries are marked in black.

Evolution of state-specific trajectories. Trajectories were determined in the latent space and projected onto a two-dimensional vector field for illustration (coordinate axes are specific to each state). The average trajectory across participants, starting at the white star, is initially shown in green and switches to red when the majority of trajectories (across participants) switch to another state. Whereas the trajectory includes endogenous and exogenous contributions to temporal evolution, the vector field represents the endogenous contribution only. The gray arrows indicate the effect of the state’s endogenous dynamics matrix, showing the direction and magnitude of evolution after a single time step. The blue cross indicates the state’s fixed point attractor; star indicates the start of the trajectory. PC: principal component.

Effect of external inputs on steering state trajectories and driving state transitions. (A) Left: Trajectory at t − 1 in state i. Inputs (colored arrows) could perturb the trajectory (translucent paths of the same color) by steering the evolution towards the state’s centroid (green) or away from it (pink). When the input directed it away from the state’s centroid, the input could push the system to switch into state j (red). Right: The input effect was measured via the cosine of the angle ϕ between the input vector and the line joining Xt−1 and state centroids. (B and C) Input effects with rows and columns representing states/state-transitions and input categories, respectively. Only states with significant association with inputs and only significant state transitions are shown (see Fig. 2). Cells with significant effects are highlighted in blue (p < 0.05, corrected for multiple comparisons).

Testing generalizability of the SLDS model. (A) Experimental design of the “escape” (ESC) paradigm (data from a separate group of participants). Each trial started with a chase period (pink), where the participant controlled the rabbit icon to move towards the safety area (to their right) while being actively pursued by a threat icon. If the player entered the safety area without getting caught by threat, the safety gate closed, starting a safety period (green). Brain states were analyzed during windows centered around the time of entering the safe region (indicated by the vertical dashed line). (B) Table entries indicate the probability of being in a state given the time step relative to the window. Time steps marked in red and green indicate chase and safety periods respectively. (C) Table entries indicate the probability of a state transition given the time step. In both tables, cells highlighted in red indicate states/state transitions significantly associated with the window’s time step (p < 0.05, corrected for multiple comparisons). The color scale indicates probability values. No hemodynamic shift was applied to the tables in B and C. (D) Average fMRI response in the left Bed nucleus of the Stria Terminalis (BST). Error bars correspond to the 95% confidence interval based on the standard error of the mean across participants.

Supplemental figure: Model fit ELBO criterion as a function of the number of latent dimensions determined for multiple values of the number of states (K). Error bars indicate the 95% confidence interval based on standard error across leave-one-out samples.

Supplemental figure: Consistency of state sequences across left-out participants as a function of the number of states (K). Error bars indicate the 95% confidence interval based on standard error across leave-one-out samples.

Supplemental figure: Average state transition matrix across bootstrap samples. State transitions highlighted in red have occurred more frequently than expected by chance (p < 0.05, corrected for multiple comparisons).

Supplemental figure: Voxelwise state activity maps for all states. Activity maps indicate signal intensity at a voxel when the state was “on”. Maps were corrected for multiple comparisons by thresholding voxels at p < 0.001 and cluster level at p < 0.05.

Supplemental figure: Stability of states. Distribution of the norms of the largest eigenvalue of the dynamics matrix (A) across bootstrap samples. A state was considered an attractor if 95% of the norms were smaller than 1.

Supplement to Fig. 2: Brain states, state transitions, and input stimuli. (Top) Version with 10 stimulus categories. (Bottom) Version with 30 stimulus categories. Stimuli were categorized into bins based on circle distance and movement direction indicated with A for approach and R for retreat (1 indicates circles are farthest and 5 or 15 indicates circle collision). (A) Table entries indicate the probability of being in a state given the input stimulus category. (B) Table entries indicate the probability of a state transition given the input stimulus category. In both tables, cells highlighted in red indicate states/transitions significantly associated with the corresponding stimulus category (p < 0.05, corrected for multiple comparisons). The color scale indicates probability.

Supplement to Fig. 7: Effect of external inputs on steering state trajectories and driving state transitions. (Top) Version with 10 stimulus categories. (Bottom) Version with 30 stimulus categories. (A and B) Input effects with rows and columns representing states/state-transitions and input categories, respectively. Only states with significant association with inputs and only significant state transitions are shown. Cells with significant effects are highlighted in blue (p < 0.05, corrected for multiple comparisons).