Manuscript Offprint
arXiv:2609.31544A Flow Matching Framework for Neural Representational Dissimilarity
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Neural representational dissimilarity quantifies differences between neural response distributions, and is essential for comparing neural codes across stimuli, brain areas, tasks, and models. Commonly used distance metrics involve different assumptions and are estimated with separate methods. Here, we show that a variety of distance metrics can be unified under a flow matching framework developed in deep generative models. That is, these distances arise as Jeffreys divergences under different velocity constraints. We find that flow matching has advantages for estimating distances involving complicated distributions and continuous variables. Furthermore, this framework enables the design of new distance metrics in a principled way. Together, flow matching provides a unified approach for understanding, estimating, and designing neural representational dissimilarity metrics.
A

B
Figure 1: Overview of the proposed flow matching framework for neural representational dissimilarity. (A) Different stimuli evoke condition-specific neural responses, producing different population-response distributions whose dissimilarity is to be quantified. (B) Flow matching learns velocity fields and that transport a shared source distribution to the fitted distributions and . Here, we define representational dissimilarity as the Jeffreys divergence between and . We prove that different choices of correspond to different distance metrics.
1 Introduction
A central question in neuroscience is how the brain represents information through stochastic neural population responses. Representing information means not only “storing” it but also “structuring” it in an appropriate format to support downstream computation given the biological constraints [Kriegeskorte and Kievit, 2013, Kriegeskorte and Wei, 2021]. How can we study representational
*Code: https://github.com/AgeYY/FlowRDM.
Preprint.
structures? Representational similarity analysis (RSA) takes a geometric perspective, probing representational structure by measuring pairwise distances between neural population response distributions across conditions, such as stimuli or task states [Kriegeskorte et al., 2008a, Nili et al., 2014]. RSA has been widely used to study how neural representations support perception and task performance [Kriegeskorte et al., 2008a, Cichy et al., 2014, Diedrichsen and Kriegeskorte, 2017] and to compare representational systems across species and computational models, including deep neural network models [Kriegeskorte et al., 2008b, Kriegeskorte, 2009, Kornblith et al., 2019].
A key step in RSA is to define and estimate representational distances. Because neural responses are stochastic, this often becomes a mathematical question of how to compare distributions. No single distance metric is best for every purpose as different metrics reveal different properties of the distributions [Walther et al., 2016, Diedrichsen and Kriegeskorte, 2017, Kriegeskorte and Wei, 2021]. For example, correlation distance compares the relative pattern of mean activity across neurons. Euclidean distance measures separation between mean response vectors. Mahalanobis distance additionally accounts for response covariance. Kullback-Leibler (KL) divergence compares full response distributions. Lastly, Fisher information measures how sensitive the response distribution changes with a small change of the stimulus variable [Kullback and Leibler, 1951, Amari, 2016].
Given the diversity of these useful distance metrics, a natural question arises: can they be unified under a single mathematical framework? Such a framework, if exists, could offer several benefits. First, it would make the statistical assumptions underlying different metrics more explicit, clarifying their interpretation. Second, it would provide a principled way to design new distance metrics. Finally, it could provide a unified estimator for these metrics, so that improvements to the estimator could benefit multiple metrics rather than requiring separate efforts for each one.
Here, we provide such a framework using flow matching. Flow matching is a modern deep generative modeling method that is widely used in image, video, and language generation [Lipman et al., 2023, Esser et al., 2024, Davtyan et al., 2023, Hu et al., 2024]. It starts by generating a data sample from a simple source distribution (e.g., a Gaussian distribution) and then evolves the sample toward a target distribution through a velocity field. In our flow-matching framework for neural dissimilarity, we define the representational distance as the Jeffreys divergence between two target neural-response distributions under a given velocity constraint. We mathematically prove that this Jeffreys divergence reduces to existing distance metrics under different velocity-field constraints (Fig. 1). We show that flow matching offers advantages when estimating distances involving complex distributions and continuous variables, and allows the principled design of new distance metrics.
Fisher information estimation. Fisher information measures how rapidly changes with a continuous stimulus or behavioral variable, [Fisher, 1922, Amari, 2016, Seung and Sompolinsky, 1993, Pouget et al., 2000]. Its inverse lower-bounds the variance of unbiased estimators, making Fisher information a local measure of discriminability [Serès et al., 2009, Rao, 1945, Brunel and Nadal, 1998, Abbott and Dayan, 1999, Averbeck et al., 2006]. With repeated trials at nearby stimulus values, Fisher information can be estimated from tuning-curve derivatives and response covariance or from decoder-based estimator [Kanitscheider et al., 2015, Kohn et al., 2016]. Continuous and naturalistic experiments, however, have no exact repeats. Estimation procedures need to exploit information shared across nearby values of the condition , for example by using Gaussian processes [Rasmussen and Williams, 2006, Ye and Wessel, 2025, Nejatbakhsh et al., 2023]. However, Gaussian processes scale poorly [Bruinsma et al., 2020]. Our flow-matching framework unifies Fisher information estimation with the other distance metrics that have traditionally been treated separately.
Continuous normalizing flows and flow matching. Normalizing flows model densities through invertible transformations [Rezende and Mohamed, 2015, Papamakarios et al., 2021], while continuous normalizing flows transport samples through an ODE [Chen et al., 2018]. Roughly speaking, a sample begins at , follows the velocity field over time, and arrives at a distribution intended to approximate the observed data. In the original continuous-flow formulation, the velocity parameters are trained by maximum likelihood, which requires solving the ODE and estimating the divergence of the velocity field during optimization, which can be slow [Chen et al., 2018, Grathwohl et al., 2019]. Flow matching reformulates this training problem. Instead of maximizing likelihoods, one specifies a probability path between source samples and data samples, computes the target velocity along that path, and trains by regressing onto those velocities [Lipman et al., 2023, Albergo and Vanden-Eijnden, 2023]. Flow matching thus provides a practical way to learn a transport map from a source distribution to an empirical response distribution.
3 A flow matching framework for computing representational distance
Flow matching learns a time-dependent velocity field that transports samples from a simple source distribution to a target distribution [Lipman et al., 2023]. Consequently, different constraints on the velocity field yield different approximations to the target distribution. Let denote a neural population response vector, where is the number of neurons, and let denote the unknown target distribution under condition . Starting from a source sample , sampling follows the ODE
where the velocity field specifies the direction and speed of the sample at each flow time and denotes the chosen velocity class. Integrating Eq. (1) from to defines a transformation and the fitted distribution
so that when . The fitted distribution approximates . Here, is an artificial flow-matching coordinate, not physical time.
In general, our framework has three steps: (1) choose a source distribution and a velocity class V; (2) learn the velocity field by flow matching to approximate the target distributions; and (3) use the learned model to compute the Jeffreys divergence between the approximated distributions as the representational distance.
Notation. We use for a pair of categorical conditions being compared and for the mean response under condition . We use for a continuously varying condition, such as stimulus orientation, physical time, or behavior. For simplicity, we describe the framework below using the categorical condition ; the same framework applies to the continuous condition .
-
Choosing a source distribution and velocity class. We first choose a source distribution and a velocity class V. The source specifies the initial distribution, which is typically shared across conditions. Meanwhile, the velocity class specifies the transformations allowed from the source to each target. For example, an unconstrained velocity field, parameterized by a neural network, permits flexible nonlinear transformations, whereas a constant, state-independent velocity restricts the transformation to a translation. These choices determine which properties of the target distributions can be represented (see Fig. 2) and, consequently, which representational distance is induced. Section 4 presents the specific choices used to recover different distance metrics.
-
Flow-matching training. Given the source distribution and velocity class, flow matching learns the velocity field with a simple regression objective [Lipman et al., 2023, Albergo and Vanden-Eijnden, 2023]. During training, we draw source samples and observed responses and connect them along a predefined path
where and are prescribed interpolation schedules controlling the contributions of the source and target samples at flow time t. The boundary conditions ensure that the path begins at the source sample and ends at the recorded response. Its target instantaneous velocity is
B

C
Constant velocity
Affine velocity
D
Unconstrained velocity
Source density
Target samples
..... Ground truth
Fitted distribution
Velocity at t = 0.95
Figure 2: Velocity classes V used in flow matching determine the fitted distributions (also see Table 1). (A) A two-component Gaussian-mixture target, shown as samples and dotted density contours. (B) A constant velocity translates the Gaussian source (black region) without changing its shape. (C) An affine velocity allows an affine transformation of the source distribution, yielding a Gaussian approximation to the target. (D) An unconstrained velocity captures the two modes of the target. Arrows indicate velocity direction, not magnitude.
where the dots denote derivatives with respect to t. A neural network receives and is trained to predict this target velocity. The flow-matching objective is
where denotes a randomly sampled categorical condition. For a continuous condition, we instead sample and replace , and by , and , respectively. The population minimizer is learned by backpropagation through the velocity network.
Optionally, the learned velocity field can be fine-tuned by maximizing the log likelihood (Section B.1). We use this fine-tuning only for the new distance metric introduced in Supplementary Section C, where it is practically useful for optimization; all other results use flow-matching training alone for simplicity.
- Jeffreys-divergence computation. We define the representational distance between conditions a and b as the Jeffreys divergence between their fitted distributions [Kullback and Leibler, 1951, Amari, 2016],
where each directed KL divergence is
When the source distribution is Gaussian and the velocity class V is affine (linear in the state), the fitted distributions can be obtained by solving deterministic ODEs for their means and covariances (Supplementary Section A.3), from which the Jeffreys divergence can be computed.
In other cases, we estimate the Jeffreys divergence using Monte Carlo. We draw samples and for by integrating the sampling ODE in Eq. (1) and compute
These log densities are computed using the continuous change-of-variables identity in Eq. (111).
4 Flow matching with different velocity constraints lead to different representational metrics
We now present our main theoretical results, i.e., various commonly used representational distance metrics arise from our flow matching framework as Jeffreys divergences under different velocity classes. These correspondences are summarized in Table 1. For each velocity class, the proof follows a similar general strategy. We substitute the analytical form of the constrained velocity field into the population flow-matching loss and solve for its minimizer, which determines the induced approximate distribution. Evaluating the Jeffreys divergence between the resulting condition-specific approximations then yields the corresponding distance metric. Complete proofs for all rows of Table 1 are provided in the Supplementary Section A.4.
Table 1: Distance metrics and their corresponding velocity classes. We use for a categorical condition and for a continuous condition. All rows use the shared standard Gaussian source except the starred geometry-template distance, which uses a source distribution concentrated around a low-dimensional manifold (Supplementary Section C). The cosine and correlation rows equal times their conventional definitions. In the Mahalanobis row, is shared across conditions. In the linear-Fisher row, is shared locally across nearby conditions (see Supplementary Section A.4).
| Velocity field | Induced distance |
| Euclidean distance | |
| Cosine distance | |
| Correlation distance | |
| Mahalanobis distance | |
| Gaussian Jeffreys divergence | |
| Linear Fisher information | |
| Jeffreys divergence; full Fisher information | |
| Auxiliary -dependent distance | |
| Geometry-template Jeffreys divergence* |
*: new distance introduced in this paper; dark red: outputs from trainable neural networks
Fig. 2 illustrates this correspondence for three representative velocity classes. A velocity field that is constant in can only translate the Gaussian source. At the population optimum, this translation shifts the source mean to the target-distribution mean while leaving its covariance unchanged, so the Jeffreys divergence reduces to the squared Euclidean distance between target means. An affine-in- velocity field can both translate and linearly transform the Gaussian source. Its population optimum therefore produces the moment-matched Gaussian approximation to the target distribution, and the resulting Jeffreys divergence is the Gaussian Jeffreys divergence. Finally, in the population limit, an unconstrained velocity field recovers the target distribution itself, yielding the full Jeffreys divergence.
Beyond a unification of existing distance metrics, the flow-matching framework enables principled designs of new metrics by specifying the source distribution as a distributional “template” and choosing a velocity class that constrains how the template can be transformed. The resulting distance is the Jeffreys divergence between the two fitted target distributions. As a demonstration, we design a new distance metric using a velocity class restricted to similarity transformations, thereby preserving the geometry of the source distribution when approximating the target distributions (Supplementary Section C). This metric can be useful when the geometry of the target distributions is known a priori or when one wishes to emphasize a particular geometric property.
5 Applications
We evaluate the flow-matching framework across a number of applications. First, we use a simple synthetic categorical dataset to test whether different velocity constraints recover multiple representational distance metrics (Section 5.1). The remaining four settings involve continuous variables: Fisher information in simulations and neural recordings (Section 5.2), and time-resolved RDMs in simulations and neural recordings (Section 5.3). The later four settings highlight an important advantage of flow matching for complex distributions that depend on continuous variables.
5.1 Flow matching recovers multiple distance metrics on a synthetic categorical dataset
We first test whether practically flow matching with different velocity constraints enables the estimation of commonly used representational distance metrics, as predicted by our analytical results. We construct a five-condition Gaussian dataset in , and fit flow matching with the corresponding velocity constraint for each metric in Table 1. Accuracy, measured by the Pearson correlation between the unique off-diagonal entries of the estimated and ground-truth RDMs, improves with total sample size across all six metrics (Fig. 3A). The estimated RDMs closely resemble the corresponding ground-truth RDMs defined by the six metrics (Fig. 3B), supporting our main theoretical claim that flow matching can be used as a unified estimator for these metrics. Notably, most of these metrics depend only on first- and second-order moments, for which robust and efficient estimators such as Ledoit–Wolf shrinkage are available [Ledoit and Wolf, 2004]. Indeed, when comparing flow matching with these specialized estimators on this simple Gaussian dataset, we did not observe advantages in estimated accuracy for flow matching (Fig. S1). In later applications, we will show that for datasets involving complex distributions and continuous variables, flow matching exhibits various advantages.
A

B
Figure 3: Flow matching recovers distance metrics on a synthetic categorical dataset. (A) Pearson correlation between the unique off-diagonal entries of the estimated and ground-truth RDMs as a function of total sample size N. Curves and error bars show means and sample standard deviations over five repetitions; the inset visualizes the five-condition dataset. (B) Ground-truth RDMs (top) and the corresponding flow-matching estimates using 2,000 total samples (bottom).
5.2 Flow matching estimates Fisher information in simulations and neural data
Fisher information is a local measure of representational distance. Linear Fisher information quantifies how precisely small stimulus changes can be estimated by an optimal, locally unbiased linear readout of neural responses [Brunel and Nadal, 1998, Abbott and Dayan, 1999, Averbeck et al., 2006, Moreno-Bote et al., 2014, Kanitscheider et al., 2015, Le and Wei, 2026], whereas full Fisher information measures the sensitivity of the entire response distribution through the log-likelihood score, including information accessible only through nonlinear readouts. Estimating Fisher information can be challenging, partly because it is difficult to model how response distributions depend on continuous conditions. In contrast, our flow-matching approach can, in principle, interpolate naturally across conditions by approximating the velocity field with a deep neural network, without requiring additional data binning or modeling assumptions. Below, we evaluate the performance of this flow-matching framework in estimating both quantities.
Simulations. We first estimate linear Fisher information using a toy dataset whose conditional response distribution is Gaussian given a continuous variable . We fit a condition-dependent affine (linear-in-state) velocity field, (Table 1). As baselines, we consider several existing methods. Local linear estimator (OLE) estimates linear Fisher information by binning the data and performing linear classification on adjacent bins [Kanitscheider et al., 2015]. Gaussian-process kernel regression (GKR; see Section D.1.3) uses Gaussian-process regression to estimate the distributional mean as a function of and then uses kernel regression to estimate covariances [Ye and Wessel, 2025]. The Wishart process jointly models the mean and covariance with Gaussian processes [Nejatbakhsh et al., 2023] (Section D.1.4). On this Gaussian dataset, affine flow yields a smooth estimate that closely follows the ground-truth linear Fisher-information when varying the sample-size and number of neurons (Fig. 4B, C). GKR and the Wishart process perform fairly well on low-dimensional datasets, but their errors increase substantially with response dimension (Fig. 4C; also see Pearson correlations in Supplementary Figure S2A).
Furthermore, we evaluate full Fisher information on another Gaussian mixture dataset (Fig. 4D). GKR and the Wishart process fail in estimation because they assume Gaussian distributions, whereas unconstrained flow successfully targets the full Fisher information (Fig. 4E and F).
Neural data. Next, we apply flow matching to neural recording data. We analyze six mouse visual-cortex recording sessions from Stringer et al. [2021], each containing responses from 10,000 to 25,000 neurons across about 4,000 static-grating trials (Fig. 5A). Direct estimation of Fisher

B
C
D
E
F
Figure 4: Flow matching performs best in estimating Fisher information on toy datasets. (A) Illustration of the Gaussian conditional-response dataset. (B) Representative linear Fisher-information estimates (d = 300, N = 1000). (C) Mean relative absolute error (MRAE) versus total sample size at d = 300 (left) and versus response dimension at N = 1,000 (right). (D) Equal-weight Gaussian scale-mixture dataset. (E) Representative full Fisher-information estimates. (F) MRAE versus total sample size at d = 20 (left) and versus response dimension at N = 7,000 (right). Points and error bars in (C) and (F) show means and standard deviations over five repetitions.
A
B

C


Figure 5: Flow matching estimates Fisher information in mouse visual-cortex recordings. (A) Experimental paradigm: visual-cortex responses are recorded while mice view static gratings. (B) Session-wise mean held-out log likelihood relative to GKR. Gray lines connect estimates from the same session. Bars and error bars show the across-session mean and standard error of the mean (SEM). (C) Linear Fisher information from affine flow and full Fisher information from unconstrained flow versus grating orientation. Gray lines show six individual sessions, each from a different mouse; black curves and error bars show the across-session mean and SEM.
information in this high-dimensional response space is statistically challenging and computationally demanding. Following common dimensionality-reduction practice [Cunningham and Yu, 2014], we performed PCA separately for each session using only the training trials and apply the fixed projection to the training, validation, and test responses (200 principal components, about 70% of the variance). All models are fitted and evaluated in this dimensionality-reduced PCA space.
For a given orientation range, visualizations of the PC1–PC2 subspace show that, while the Gaussian estimators (Bin + LW, GKR, the Wishart process, and affine flow) generally fit the held-out data well, some discrepancies remain (Supplementary Fig. S3). By contrast, unconstrained flow captures a non-elliptical density contour and visually fits the data better. Quantitatively, across the six sessions, affine flow has the highest mean held-out log likelihood among the Gaussian-family estimators. Furthermore, unconstrained flow, which does not impose Gaussianity, has the highest held-out log-likelihood overall in every session (Fig. 5B). Finally, the affine-flow linear Fisher estimate and the unconstrained-flow full Fisher estimate both peak near 90° (Fig. 5C; see similar Fisher curves estimated by the other methods in Supplementary Fig. S4), suggesting greater discriminability of horizontal visual patterns. These results are different from the oblique effects reported in humans [Appelle, 1972, Furmanski and Engel, 2000] and macaques [Li et al., 2003], which show higher discriminability for both horizontal and vertical orientations, yet are consistent with a recent study in mice [Dipoppa et al., 2024].
B

C
D
E
F
Figure 6: Flow matching best estimates time-resolved distances on OU-trial toy datasets. (A) Gaussian OU dataset with two conditions. (B) Representative time-resolved Gaussian Jeffreys-divergence estimates at d = 60 and 260 trials per condition. (C) MRAE versus trials per condition at d = 60 (left) and versus response dimension at 260 trials per condition (right). (D) Gaussian-mixture OU dataset. (E) Representative full Jeffreys-divergence estimates at d = 10 and 260 trials per condition. (F) MRAE versus trials per condition at d = 10 (left) and versus response dimension at 260 trials per condition (right). Points and error bars in (C) and (F) show means and standard deviations over five repetitions.
5.3 Estimating time-resolved distances using flow matching
Neural population representations are not static, rather they evolve dynamically over time. Understanding such dynamics is important for understanding the computations performed by the brain. Time-resolved RDMs address this question by tracking how representational distances change over time. Conventional estimation typically involves dividing the data into discrete time bins. Our flow-matching framework does not require binning, as the velocity neural network learns to interpolate across time. In this section, we evaluate whether our method can estimate time-resolved RDMs.
Simulations. We construct two-condition toy datasets with temporally correlated Ornstein–Uhlenbeck (OU) trials [Uhlenbeck and Ornstein, 1930] and either Gaussian or two-scale Gaussian-mixture marginals. We measure pairwise distances using either Gaussian Jeffreys divergence or Jeffreys divergence. Gaussian Jeffreys divergence generalizes Mahalanobis distance by allowing the two conditions to have different covariance matrices, whereas Jeffreys divergence makes no Gaussian assumption and can therefore capture differences between their full distributions. We find that, on the Gaussian dataset, affine flow outperforms conventional methods in estimating Gaussian Jeffreys divergence throughout both the trial-count and response-dimension sweeps (Fig. 6A–C). On the mixture dataset, only the unconstrained flow-matching estimator captures the non-Gaussian structure and outperforms the other methods in estimating Jeffreys divergence (Fig. 6D–F).
Neural data. We next apply time-resolved distance estimation to extracellular spiking activity from the Allen Visual Coding Neuropixels dataset [Siegle et al., 2021]. Each drifting-grating presentation is analyzed over four seconds: one second before stimulus onset, two seconds of stimulus presentation, and one second after stimulus offset (Fig. 7A). We treat each combination of motion direction and temporal frequency as a condition and examine how the pairwise representational distances evolve over time. We analyze 32 recording sessions, one for per mouse. Spikes are counted in nonoverlapping 100-ms bins, transformed elementwise using a variance-stabilizing transformation as , and projected onto the top 70 principal components, which explains about 70% variance.
Quantitatively, affine flow leads to the highest mean held-out log-likelihood among the Gaussian estimators, whereas unconstrained flow has the highest mean held-out log-likelihood overall (Fig. 7B; see example data visualizations in Supplementary Figs. S6 and S9). Similar results hold when using 10 rather than 70 principal components (Supplementary Fig. S10). Across all five temporal frequencies, both flow estimates of Jeffreys divergence rise sharply after stimulus onset and fall after stimulus offset. Higher temporal frequencies show smaller overall distances, suggesting poorer discrimination.

B
C
D
Figure 7: Flow matching estimates time-resolved distances from Allen Neuropixels recordings. (A) Four-second trial structure. (B) Mean test log-likelihood relative to the GKR method. Dots denote recording sessions, gray lines connect estimates from the same session, and bars show the mean across 32 sessions; triangles indicate two outliers above the displayed range. (C) Unconstrained-flow Jeffreys divergence averaged over the 28 unique pairs among the eight directions separately at each temporal frequency within each session (top), and 4-Hz direction RDMs averaged across sessions at the bin centers nearest -0.5, 1.0, and 2.5 seconds (bottom). Colors indicate temporal frequency. Curves and shaded bands show the across-session mean and SEM, respectively. (D) Time-to-time RDM correlations. Colors show mean Pearson correlations between RDMs at pairs of time points.
between grating directions and less directional information encoded at faster temporal frequencies (Fig. 7C; also see Supplementary Figs. S7 and S8). Individual RDMs exhibit semi-periodic structures, implying that therepresentational distances between drifting gratings of the opposite directions are closer compared to gratings with orthogonal directions (Fig. 7C bottom; also see Supplementary Fig. S11 for a similar pattern from analyzing calcium imaging data from de Vries et al. [2020]).
Using the RDMs at different time points, we can also assess neural representational stability over time by computing time-to-time RDM correlations (Fig. 7D; see Supplementary Fig. S13 for the other methods). The mean correlation is higher during stimulus presentation (0–2 s; mean = 0.73) than before (−1–0 s; mean = 0.055) or after (2–3 s; mean = 0.25). This suggests that the structure of neural representational geometry are relatively stable during stimulus presentation. Together with observations in Fig. 7C, these results suggest that, while the neural manifolds expand and shrink over time, the shape of the manifolds is generally preserved.
We also find that methods such as GKR tend to oversmooth the distribution, perhaps because they use Gaussian processes and assume Gaussian response distributions, producing spuriously high correlations of RDMs even before stimulus presentation (Fig. 7D).
6 Discussion and Conclusion
We have introduced a flow-matching framework that unifies neural representational dissimilarity metrics as Jeffreys divergences under different velocity-field constraints. It provides a common estimator with empirical advantages for high-dimensional data and complex distributions conditioned on continuous variables, and enables principled design of new metrics through source distributions and velocity constraints. Our results has several limitations. Because the theoretical correspondences hold at global population optima, which neural-network training may not reach, the fitted estimates can therefore deviate from their intended metric interpretations. Also, our Validation has focused on visual-cortex recordings. Extending it to other brain systems and measurement techniques (such as fMRI and EEG), as well as deep neural network models, remains an important direction for future investigations.
AI use statement
AI-assisted tools were used for language editing and manuscript organization under author direction. The authors reviewed the scientific claims, derivations, citations, and conclusions and take responsibility for the final content.
Ethics statement
This work analyzes synthetic data and previously collected animal recordings. No new animal or human-subject experiments were conducted for this study.
Reproducibility statement
The Supplementary Material provides complete proofs, estimator specifications, dataset construction and preprocessing details, hyperparameter searches, and additional results. The real-data experiments use the visual-cortex recordings described by Stringer et al. [2021], two-photon calcium-imaging sessions from the Allen Brain Observatory Visual Coding dataset, and Allen Visual Coding Neuropixels recordings [Siegle et al., 2021]. Code is available at https://github.com/AgeYY/FlowRDM.
References
L. F. Abbott and Peter Dayan. The effect of correlated variability on the accuracy of a population code. Neural Computation, 11(1):91–101, 1999. doi: 10.1162/089976699300016827.
Michael S. Albergo and Eric Vanden-Eijnden. Building normalizing flows with stochastic interpolants. In International Conference on Learning Representations, 2023.
Shun-ichi Amari. Information Geometry and Its Applications. Springer Japan, 2016. doi: 10.1007/978-4-431-55978-8.
Stuart Appelle. Perception and discrimination as a function of stimulus orientation: the" oblique effect" in man and animals. Psychological bulletin, 78(4):266, 1972.
Bruno B. Averbeck, Peter E. Latham, and Alexandre Pouget. Neural correlations, population coding and computation. Nature Reviews Neuroscience, 7(5):358–366, 2006. doi: 10.1038/nrn1888.
Wessel Bruinsma, Eric Perim, William Tebbutt, Scott Hosking, Arno Solin, and Richard Turner. Scalable exact inference in multi-output gaussian processes. In Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pages 1190–1201, 2020.
Nicolas Brunel and Jean-Pierre Nadal. Mutual information, fisher information, and population coding. Neural Computation, 10(7):1731–1757, 1998. doi: 10.1162/089976698300017115.
Ricky T. Q. Chen, Yulia Rubanova, Jesse Bettencourt, and David K. Duvenaud. Neural ordinary differential equations. In Advances in Neural Information Processing Systems, volume 31, 2018.
Radoslaw Martin Cichy, Dimitrios Pantazis, and Aude Oliva. Resolving human object recognition in space and time. Nature Neuroscience, 17:455–462, 2014. doi: 10.1038/nn.3635.
John P. Cunningham and Byron M. Yu. Dimensionality reduction for large-scale neural recordings. Nature Neuroscience, 17(11):1500–1509, 2014. doi: 10.1038/nn.3776.
Aram Davtyan, Sepehr Sameni, and Paolo Favaro. Efficient video prediction via sparsely conditioned flow matching. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 23263–23274, 2023.
Saskia E. J. de Vries et al. A large-scale standardized physiological survey reveals functional organization of the mouse visual cortex. Nature Neuroscience, 23:138–151, 2020. doi: 10.1038/s41593-019-0550-9.
Jörn Diedrichsen and Nikolaus Kriegeskorte. Representational models: A common framework for understanding encoding, pattern-component, and representational-similarity analysis. PLOS Computational Biology, 13(4):e1005508, 2017. doi: 10.1371/journal.pcbi.1005508.
Mario Dipoppa, Ramon Nogueira, Stéphane Bugeon, Yoni Friedman, Charu B. Reddy, Kenneth D. Harris, Dario L. Ringach, Kenneth D. Miller, Matteo Carandini, and Stefano Fusi. Adaptation shapes the representational geometry in mouse V1 to efficiently encode the environment. bioRxiv, 2024. doi: 10.1101/2024.12.11.628035.
Patrick Esser, Sumith Kulal, Andreas Blattmann, Rahim Entezari, Jonas M'uller, Harry Saini, Yam Levi, Dominik Lorenz, Axel Sauer, Frederic Boesel, Dustin Podell, Tim Dockhorn, Zion English, and Robin Rombach. Scaling rectified flow transformers for high-resolution image synthesis. In Proceedings of the 41st International Conference on Machine Learning, volume 235, pages 12606–12633, 2024.
Ronald A. Fisher. On the mathematical foundations of theoretical statistics. Philosophical Transactions of the Royal Society of London. Series A, 222:309–368, 1922. doi: 10.1098/rsta.1922.0009.
Christopher S. Furmanski and Stephen A. Engel. An oblique effect in human primary visual cortex. Nature Neuroscience, 3(6):535–536, 2000. doi: 10.1038/75702.
Will Grathwohl, Ricky T. Q. Chen, Jesse Bettencourt, Ilya Sutskever, and David K. Duvenaud. FFJORD: Free-form continuous dynamics for scalable reversible generative models. In International Conference on Learning Representations, 2019.
Brian C. Hall. Lie Groups, Lie Algebras, and Representations: An Elementary Introduction. Springer, 2 edition, 2015. doi: 10.1007/978-3-319-13467-3.
Vincent Hu, Di Wu, Yuki Asano, Pascal Mettes, Basura Fernando, Bj"orn Ommer, and Cees Snoek. Flow matching for conditional text generation in a few sampling steps. In Proceedings of the 18th Conference of the European Chapter of the Association for Computational Linguistics (Volume 2: Short Papers), pages 380–392. Association for Computational Linguistics, 2024. doi: 10.18653/v1/2024.eacl-short.33.
Ingmar Kanitscheider, Ruben Coen-Cagli, Adam Kohn, and Alexandre Pouget. Measuring fisher information accurately in correlated neural populations. PLOS Computational Biology, 11(6): e1004218, 2015. doi: 10.1371/journal.pcbi.1004218.
Adam Kohn, Ruben Coen-Cagli, Ingmar Kanitscheider, and Alexandre Pouget. Correlations and neuronal population information. Annual Review of Neuroscience, 39:237–256, 2016. doi:10.1146/annurev-neuro-070815-013851.
Simon Kornblith, Mohammad Norouzi, Honglak Lee, and Geoffrey Hinton. Similarity of neural network representations revisited. In Proceedings of the 36th International Conference on Machine Learning, pages 3519–3529, 2019.
Nikolaus Kriegeskorte. Relating population-code representations between man, monkey, and computational models. Frontiers in Neuroscience, 3(3):363–373, 2009. doi: 10.3389/neuro.01.035.2009.
Nikolaus Kriegeskorte and Rogier A. Kievit. Representational geometry: Integrating cognition, computation, and the brain. Trends in Cognitive Sciences, 17(8):401–412, 2013. doi: 10.1016/j.tics.2013.06.007.
Nikolaus Kriegeskorte and Xue-Xin Wei. Neural tuning and representational geometry. Nature Reviews Neuroscience, 22(11):703–718, 2021. doi: 10.1038/s41583-021-00502-3.
Nikolaus Kriegeskorte, Marieke Mur, and Peter A. Bandettini. Representational similarity analysis: connecting the branches of systems neuroscience. Frontiers in Systems Neuroscience, 2:4, 2008a. doi: 10.3389/neuro.06.004.2008.
Nikolaus Kriegeskorte, Marieke Mur, Douglas A. Ruff, Roozbeh Kiani, Jerzy Bodurka, Hossein Esteky, Keiji Tanaka, and Peter A. Bandettini. Matching categorical object representations in inferior temporal cortex of man and monkey. Neuron, 60(6):1126–1141, 2008b. doi: 10.1016/j.neuron.2008.10.043.
Solomon Kullback and Richard A. Leibler. On information and sufficiency. The Annals of Mathematical Statistics, 22(1):79–86, 1951. doi: 10.1214/aoms/1177729694.
Dylan Le and Xue-Xin Wei. Split-trial analysis reveals the information capacity of neural population codes. eLife, 2026. doi: 10.7554/elife.111658.1.
Olivier Ledoit and Michael Wolf. A well-conditioned estimator for large-dimensional covariance matrices. Journal of Multivariate Analysis, 88(2):365–411, 2004. doi: 10.1016/S0047-259X(03)00096-4.
Baowang Li, Matthew R Peterson, and Ralph D Freeman. Oblique effect: a neural basis in the visual cortex. Journal of neurophysiology, 90(1):204–217, 2003.
Yaron Lipman, Ricky T. Q. Chen, Heli Ben-Hamu, Maximilian Nickel, and Matt Le. Flow matching for generative modeling. In International Conference on Learning Representations, 2023.
Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2019.
Rubén Moreno-Bote, Jeffrey Beck, Ingmar Kanitscheider, Xaq Pitkow, Peter Latham, and Alexandre Pouget. Information-limiting correlations. Nature Neuroscience, 17(10):1410–1417, 2014. doi:10.1038/nn.3807.
Amin Nejatbakhsh, Isabel Garon, and Alex Williams. Estimating noise correlations across continuous conditions with wishart processes. In Advances in Neural Information Processing Systems, volume 36, pages 54032–54045, 2023.
Hamed Nili, Cai Wingfield, Alexander Walther, Li Su, William Marslen-Wilson, and Nikolaus Kriegeskorte. A toolbox for representational similarity analysis. PLOS Computational Biology, 10(4):e1003553, 2014. doi: 10.1371/journal.pcbi.1003553.
George Papamakarios, Eric Nalisnick, Danilo Jimenez Rezende, Shakir Mohamed, and Balaji Lakshminarayanan. Normalizing flows for probabilistic modeling and inference. Journal of Machine Learning Research, 22(57):1–64, 2021.
Alexandre Pouget, Peter Dayan, and Richard Zemel. Information processing with population codes. Nature Reviews Neuroscience, 1(2):125–132, 2000. doi: 10.1038/35039062.
C. R. Rao. Information and accuracy attainable in the estimation of statistical parameters. Bulletin of the Calcutta Mathematical Society, 37(3):81–91, 1945.
Carl Edward Rasmussen and Christopher K. I. Williams. Gaussian Processes for Machine Learning. MIT Press, 2006. doi: 10.7551/mitpress/3206.001.0001.
Danilo Jimenez Rezende and Shakir Mohamed. Variational inference with normalizing flows. In Proceedings of the 32nd International Conference on Machine Learning, pages 1530–1538, 2015.
Benjamin Rhodes, Kai Xu, and Michael U. Gutmann. Telescoping density-ratio estimation. In Advances in Neural Information Processing Systems, volume 33, 2020.
Peggy Seriès, Alan A. Stocker, and Eero P. Simoncelli. Is the homunculus “aware” of sensory adaptation? Neural Computation, 21(12):3271–3304, 2009. doi: 10.1162/neco.2009.09-08-869.
H. S. Seung and Haim Sompolinsky. Simple models for reading neuronal population codes. Proceedings of the National Academy of Sciences, 90(22):10749–10753, 1993. doi: 10.1073/pnas.90.22.10749.
Joshua H. Siegle et al. Survey of spiking in the mouse visual system reveals functional hierarchy. Nature, 592:86–92, 2021. doi: 10.1038/s41586-020-03171-x.
Carsen Stringer, Michalis Michaelos, Dmitri Tsyboulski, Sarah E. Lindo, and Marius Pachitariu. High-precision coding in visual cortex. Cell, 184(10):2767–2778.e15, 2021. doi: 10.1016/j.cell.2021.03.042.
George E. Uhlenbeck and Leonard S. Ornstein. On the theory of the brownian motion. Physical Review, 36(5):823–841, 1930. doi: 10.1103/PhysRev.36.823.
Alexander Walther, Hamed Nili, Naveed Ejaz, Arjen Alink, Nikolaus Kriegeskorte, and Jörn Diedrichsen. Reliability of dissimilarity measures for multi-voxel pattern analysis. NeuroImage, 137: 188–200, 2016. doi: 10.1016/j.neuroimage.2015.12.012.
Zeyuan Ye and Ralf Wessel. Speed modulations in grid cell information geometry. Nature Communications, 16:7723, 2025. doi: 10.1038/s41467-025-62856-x.
Supplementary Material
Supplementary Material Contents
A Mathematical Proofs of the Metric Correspondences under flow matching 14
A.1 Assumptions and notation 15
A.2 Affine-flow solution 15
A.3 Deterministic Jeffreys evaluation for affine Gaussian flows 15
A.4 Proofs of velocity-to-distance metric correspondences 16
B Likelihood Fine-Tuning and Metric Correspondences 23
B.1 Optional negative-log-likelihood fine-tuning 23
B.2 Likelihood-based proofs 23
C A new distance metric that preserves the geometry of a template 25
C.1 Demonstration of a new distance metric that preserves the geometry of a template 26
D Experimental Details 26
D.1 Estimators 27
D.1.1 Flow matching training 27
D.1.2 Velocity network architecture 27
D.1.3 Gaussian-process with kernel regression 29
D.1.4 Wishart-process estimator 29
D.1.5 Cross-fitted optimal linear estimator (OLE) 30
D.1.6 TRE density-ratio estimation for categorical Jeffreys divergence 31
D.2 Simulation datasets 31
D.2.1 Categorical RDM dataset 31
D.2.2 Fisher datasets 32
D.2.3 Time-resolved Jeffreys datasets 33
D.3 Real neural datasets 34
D.3.1 Mouse V1 static-grating dataset 34
D.3.2 Allen Brain Observatory two-photon calcium-imaging dataset with drifting gratings 34
D.3.3 Allen Visual Coding Neuropixels dataset 35
D.4 Estimator and dataset for the geometry-template Jeffreys distance 35
E Supplementary Figures 37
A Mathematical Proofs of the Metric Correspondences under flow matching
In this section, we show that flow-matching training under different velocity constraints yields Jeffreys divergences that correspond to different existing distance metrics. Optional log-likelihood fine-tuning recovers the same distance metrics as well, as shown in Supplementary Section B.
A.1 Assumptions and notation
We use the term representational distance in the sense common in neural data analysis: it is symmetric and nonnegative but need not obey the triangle inequality.
We prove the flow-matching population statements in Table 1. Unless stated otherwise, the source is , , , and is independent of . Each modeled condition has , and each has finite second moments. Covariance matrices are invertible. The schedules are continuously differentiable and satisfy , , , and . For condition , write
For a velocity class , let , with defined in Eq. (5). Inserting into the ODE produces for each generic condition . Pairwise results compare and . The unknown response distributions need not be Gaussian.
Before proving the correspondences, we provide two formulas used repeatedly below: the affine-flow endpoint distribution obtained by setting in Eq. (12) (Subsection A.2) and the closed-form Jeffreys divergence between Gaussian endpoints in Eq. (16) (Subsection A.3).
A.2 Affine-flow solution
Lemma A.1 (Affine flows preserve Gaussianity). Let and be continuous on , and consider the affine ODE
Let solve with , and let solve with . Then
and therefore
for every .
Proof. Differentiating the right-hand side of Eq. (11) shows that it satisfies the affine ODE and the initial condition . Uniqueness of the linear ODE therefore gives Eq. (11). This is an affine transformation of the Gaussian random vector , so Eq. (12) follows.
A.3 Deterministic Jeffreys evaluation for affine Gaussian flows
Suppose the fitted velocity for condition c is affine in the state,
and the source is . By Lemma A.1, the distribution remains Gaussian along the flow. Its mean and covariance satisfy
(14)
The first equation follows by taking the expectation of . For the second, write , so that , and differentiate . Integrating Eq. (14) from to therefore gives the endpoint distribution directly:
For two conditions and , let . Their Jeffreys divergence is then available in closed form:
In practice, we solve Eq. (14) once per condition, symmetrize the numerical endpoint covariance as , and evaluate Eq. (16) using Cholesky-based linear solves rather than explicit matrix inverses. All entries of an RDM can then be formed from the stored endpoint moments. Unlike Eq. (8), this procedure of Jeffreys divergence computation requires no generated samples or sample-wise log-density evaluations and has no Monte Carlo sampling error.
A.4 Proofs of velocity-to-distance metric correspondences
Proposition A.2 (Translation-constrained flow matching recovers squared Euclidean distance). Let , let have finite mean , assume , and let be continuously differentiable with , , and . For the translation-only velocity class
Write and let denote the corresponding condition-dependent velocity field. The global minimizer of the population flow-matching loss in Eq. (5),
has condition-specific components and produces . Consequently,
Proof. Expanding the objective to the sampled condition C gives
where is the flow-matching loss conditional on . Each appears in only one summand of Eq. (20). Because , the global minimization therefore separates as
We can now solve each condition-specific problem. Substituting and gives
(22)
(23)
The final expectation in Eq. (23) does not depend on . Since and , we have and . Therefore
where . Hence . The time-one flow is the translation , so Lemma A.1 gives . Applying this result to conditions and , their Jeffreys divergence is
Note that the response distribution need not be Gaussian: the Gaussian form of follows from translating the Gaussian source.
Proposition A.3 (Fixed-norm translations give cosine distance). Let , suppose , and suppose for every condition. For the fixed-norm translation class
Then the population flow-matching optimum is unique within each condition and satisfies . It produces
and the induced distance is
which is times cosine distance between the condition means.
Proof. As in Proposition A.2, the global objective separates over conditions. Restricting Eq. (25) to makes constant, so minimizing the condition-specific loss is equivalent to
By Cauchy–Schwarz, , with equality only when points in the direction of . Hence
The endpoint ODE integrates to . By Lemma A.1,
Writing , Jeffreys divergence between the fitted distributions for and is
Thus the constraint removes mean-magnitude information and retains only direction. If , every point on the radius-r sphere is optimal, so neither the fitted direction nor cosine distance is defined uniquely.
Proposition A.4 (Centered fixed-norm translations give correlation distance). Let , let , suppose , and suppose for every condition. For the centered fixed-norm class
Then the population flow-matching optimum is unique within each condition and satisfies . It produces
and the induced distance is
which is times Pearson correlation distance between the condition means.
Proof. The matrix is the orthogonal projector onto the centered subspace : , , and . Proposition A.3 shows that, under a fixed-norm translation constraint, minimizing the flow-matching loss is equivalent to maximizing . The additional constraint in Eq. (35) restricts this maximization to the centered sphere. Every feasible satisfies , so
Therefore
with equality only when is aligned with . Thus
Applying Lemma A.1 gives
Writing , the Jeffreys divergence is
The inner product is Pearson correlation after feature-wise centering and normalization. If , the constrained optimum is nonunique and correlation distance is undefined for that condition.
Proposition A.5 (A shared centered affine flow gives Mahalanobis distance). Let and . Consider
where is condition specific and is shared across conditions. Define
Assume the pooled path covariance is invertible for every , and assume is positive definite at a population optimum. Then every population optimum has and induces
Consequently,
which is the squared Mahalanobis distance based on pooled within-condition covariance.
Proof. Write
where does not need to be Gaussian. Define the centered path variables
Then and , with both and centered. Substitution gives
Expanding the squared velocity error using Eq. (50) produces the cross term
Conditioned on and , the second factor is deterministic, whereas because both and are centered. The expected cross term therefore vanishes, and the population loss decomposes into
(52)
For fixed , the first term does not depend on . The second term is nonnegative; choosing makes it exactly zero. Thus minimizes the loss over for every fixed .
It remains to identify the shared covariance learned by . Let
and
For each fixed t, differentiating the centered least-squares objective with respect to gives the normal equation
Because is invertible, is unique.
Let denote the mean generated by the learned affine flow. Substituting and into Eq. (1) and taking the conditional expectation of both sides gives
Here we used because and are fixed for a given and condition . The function solves this ODE, so uniqueness gives . The generated covariance satisfies
But
Thus solves the same covariance ODE with the same initial condition. By the uniqueness theorem for linear ODEs, and . Lemma A.1 shows that the endpoint distribution is Gaussian; together with the mean and covariance derived above, this gives
Applying the Gaussian KL formula to conditions a and b gives
This conclusion depends only on the first two moments of each ; the true response distributions need not be Gaussian.
Proposition A.6 (Condition-specific affine flows give Gaussian Jeffreys divergence). Let be positive definite. For the condition-specific centered affine class
define
Assume is invertible for every and is positive definite at a population optimum. Then and
For , the induced distance is
Proof. Because both and are condition specific, Eq. (20) separates the global optimization into independent condition-specific problems. Write and define and as in the Mahalanobis proof. Then
The condition-specific loss decomposes into
For fixed , the first term is independent of , whereas the second term is nonnegative and vanishes at . Hence minimizes the condition-specific loss for every fixed . Positive definiteness of makes this minimizer unique at the population optimum, so .
For the centered problem, let
Differentiating the least-squares loss with respect to gives
As above, the generated mean is . Its covariance solves
Meanwhile,
Uniqueness of the covariance ODE gives , and hence . By Lemma A.1, the endpoint distribution is Gaussian, so the affine flow maps to
Therefore,
When , the trace terms cancel and the result reduces to .
Proposition A.7 (Stimulus-dependent affine flows give Gaussian Fisher information). Let be a scalar condition and suppose
Assume and are twice continuously differentiable in a neighborhood of and is positive definite there. Then, as ,
where
Proof. Applying Proposition A.6 to and , write and . Then
Taylor expansion gives
Because , the mean-difference contribution is
For the covariance contribution, define
From the definition of , we have . Hence is similar to , while is similar to . Similarity preserves trace, so the covariance trace can be evaluated using and . Since , the first-order terms cancel and
Adding the mean-difference and covariance contributions gives the stated . For a vector-valued condition, replacing h by a vector increment gives the Fisher information matrix
Proposition A.8 (Averaging local affine coefficients gives linear Fisher information). Under the setup of Proposition A.7, suppose the fitted conditional affine velocity is
and assume is jointly continuous in and continuously differentiable in on a neighborhood of times . Average the two fitted linear coefficients,
and construct two new velocities
Let and denote their endpoint distributions from the common source . Then
and therefore
which is linear Fisher information.
Proof. Applying Lemma A.1 to the two constructed velocities shows that their endpoint distributions are Gaussian. Because the velocities have the same linear coefficient and start from the same Gaussian source, their endpoint covariance is identical; denote it by . Their respective endpoint means are and , so
For Gaussians with a common covariance, Jeffreys divergence is exactly
Since , Eq. (89) has the claimed expansion provided that
because matrix inversion is smooth in a neighborhood of the positive-definite matrix . Thus, it remains only to prove Eq. (90).
Because uniformly on , we have . Let and be the covariance trajectories generated by and , respectively. Both satisfy the affine covariance ODE in Eq. (69), with the corresponding linear coefficient. Define and . Subtracting these two instances of Eq. (69) gives
The coefficients and are bounded on , while . Therefore Eq. (91) implies , and Gronwall's inequality gives . At , and , so
which proves Eq. (90). Positive definiteness of then gives . Substituting this relation and into Eq. (89) yields
Proposition A.9 (Unconstrained flows give Jeffreys divergence and full Fisher information). Consider an unconstrained flow trained by flow matching. At the population optimum, the standard flow-matching result [Lipman et al., 2023] gives
Hence the induced distance is the true Jeffreys divergence:
For a continuous parameter , further assume is positive on a common support, is three times continuously differentiable in , and differentiation can be exchanged with integration. Then, for ,
where is the full Fisher information matrix.
Proof. The population endpoint identity is the standard flow-matching result stated above and is not reproved here. Substitution into Eq. (6) gives .
For the continuous family, define the score and the Fisher information matrix
The stated regularity conditions imply and the information identity
Expand around :
Taking expectation under yields
Applying the same expansion at with increment -h gives
where the last equality uses continuity of J. Adding both directions yields
□
Proposition A.7 should not be interpreted as a special case of Proposition A.9. The former constrains the velocity to be affine and can be applied even when the target distributions are non-Gaussian. The latter instead assumes an unconstrained flow that recovers the target distributions themselves.
Proposition A.10 (Similarity-constrained velocities generate similarity transformations). Let T be the time-one map of
If the coefficients are continuous on , then
Thus the flow transforms every data point by an isotropic scaling, a rotation, and a translation, without shear or nonlinear deformation.
Proof. Rewrite the flow as , where
Let solve with . Since is skew-symmetric,
Let . Because , the matrix ODE has the solution
Define . Then
so is orthogonal. Moreover, and varies continuously with . Since an orthogonal matrix has determinant +1 or -1, continuity prevents the determinant from changing sign; hence and .
Finally, variation of constants gives the trajectory starting from z as
where is independent of . Evaluating at and writing , , and yields , as claimed.
B Likelihood Fine-Tuning and Metric Correspondences
B.1 Optional negative-log-likelihood fine-tuning
Evaluating the Jeffreys divergence requires log densities of . Flow matching optimizes a regression objective that is fast to train but does not directly maximize likelihood. Many previous works employed negative log likelihood (NLL) to improve fitting. In this manuscript, we applied fine-tuning for our defined geometric-preserved distance (Supplementary Figure S12).
Below we describe the fine-tuning procedure, and later prove that optimizing NLL also recovers the distance correspondences in Table 1 at their population optima.
The log density is evaluated using the continuous change-of-variables identity
Here, measures how the flow locally expands or contracts volume. For an observed response , we integrate backward to recover and evaluate . We fine-tune the constrained velocity field by minimizing the NLL
This stage encourages to assign higher density to the recorded responses, improving its finite-sample approximation to while keeping the velocity constrained to .
B.2 Likelihood-based proofs
This section proves the counterparts of Table 1 when is fitted by population negative log likelihood. These statements describe the global optimum of Eq. (112). By Lemma A.1, affine velocity classes transport the Gaussian source within a Gaussian family. We assume finite second moments and positive-definite covariances wherever an affine Gaussian density is used.
For the translation families below, let and define the population objective
(113)
Proposition B.1 (Likelihood-trained translations give Euclidean, cosine, and correlation distances). Let and , with and . Then the time-one map is , and Lemma A.1 gives . Assume and that each has finite second moments. Let and . Population likelihood training yields:
without an additional constraint,
(114)
The corresponding Jeffreys divergences are squared Euclidean distance, times cosine distance, and times Pearson correlation distance, respectively.
Proof. Equation (113) shows that the global likelihood objective is a positive weighted sum of condition-specific losses. Because is condition specific, its minimization separates over c. Direct evaluation of the Gaussian negative log likelihood gives
where terms independent of are absorbed into the constant. The unconstrained quadratic is uniquely minimized at , proving Eq. (114).
On the sphere , the norm term is constant, so Cauchy–Schwarz reduces the problem to maximizing and gives Eq. (115). On the centered sphere, , so ; applying Cauchy–Schwarz within this subspace gives Eq. (116).
All three fitted distributions have identity covariance, so Jeffreys divergence equals the squared distance between their means. Substitution gives
If a required mean vector is zero, the corresponding constrained optimum is nonunique, exactly matching the usual domain restriction of cosine or correlation distance. The response distributions need not be Gaussian.
Proposition B.2 (Likelihood-trained affine flows give Mahalanobis and Gaussian Jeffreys divergence). Assume and each has mean and positive-definite covariance . Let .
If the reachable Gaussian family has condition-specific means and one shared covariance,
(123) then the population likelihood optimum is , , and
If both means and covariances are condition specific, the optimum is and the induced distance is the Gaussian Jeffreys divergence in Proposition A.6.
Proof. For the shared-covariance family, direct evaluation of the Gaussian negative log likelihood and averaging over gives
For every fixed , positivity of and positive definiteness of give the unique mean optimum . The remaining covariance objective is
The Gaussian cross-entropy is uniquely minimized by matching the pooled covariance, so . Hence
where the distance follows from the common-covariance Gaussian KL formula.
If the covariance is condition specific, the global loss separates over . Minimizing the Gaussian cross-entropy conditionwise gives for every condition. Adding the two directed Gaussian KL divergences cancels the log determinants and yields the formula in Proposition A.6.
Proposition B.3 (Likelihood-trained affine flows give Gaussian and linear Fisher information). Let be scalar, and suppose likelihood optimization is pointwise-separable in and can realize at every condition. Assume and are twice continuously differentiable and is positive definite. At the population likelihood optimum, and , and
If the two nearby fitted distributions are instead constrained to share a covariance while retaining their separate means, the limit is , the linear Fisher information.
Proof. At each fixed , minimizing the Gaussian cross-entropy gives the unique pointwise optimum
Proposition A.7 then applies directly and gives
Under the shared-local-covariance constraint, Proposition A.8 gives
Dividing by and taking proves both limits. The pointwise-realizability assumption is essential: if a finite neural parameterization couples distant values of , its population optimum need not equal the separate Gaussian moment projection at every stimulus.
C A new distance metric that preserves the geometry of a template
A framework for distance metrics makes it possible to design new metrics in a principled way. A design consists of two choices: a source distribution, which specifies the basic structure used to approximate each response distribution; and a velocity class, which specifies the permitted transformations from source to target.
As a demonstration, we introduce a metric that estimates the distance between two distributional approximations constrained to preserve the geometry of a prescribed template. Such a metric can be useful when the geometry of the target distribution is known a priori, or when one wishes to emphasize a particular geometric property of the distribution.
Geometric-template source distribution. Let be a bounded parameter domain, typically with , and let be an a priori specified template embedding. Thus, indexes a location on the template; for example, and trace a circle. Define the condition-indexed source distribution by
The additive Gaussian noise makes the source full dimensional, so it has a well-defined density in , while controls the thickness of the distribution around the template. The template geometry is fixed across conditions; only its admissible transformation and its noise thickness are fitted.
Similarity-constrained velocity field. We want each fitted transformation to preserve the template's shape while allowing its position, orientation, and overall scale to vary. We therefore restrict the time-one map Eq. (2) to the orientation-preserving similarity group [Hall, 2015],
Here translates the template, rotates it, and changes its scale uniformly in every direction. These similarity transformations exclude reflection, shear, and nonlinear deformation.
To parameterize these transformations continuously, we constrain the velocity to the Lie algebra of this group:
The quantities , , , and are learnable parameters produced by a neural network. The vector is the infinitesimal generator of translation, the matrix generates rotation about , and the scalar generates isotropic expansion or contraction. Integrating these infinitesimal generators over time produces a similarity transformation of the form above, as proved in Proposition A.10.
Training and induced geometry-template dissimilarity. Training proceeds in two stages. First, we fix each noise scale at its initial value and optimize the neural-network parameters of the similarity-constrained velocity field using the flow-matching objective in Eq. (5). Second, we make the positive scale learnable and jointly fine-tune and the velocity parameters by minimizing the NLL objective in Eq. (112). This stage adapts the template noiseless to the observations. After training, we define the geometry-template dissimilarity between conditions and as their Jeffreys divergence as before.
C.1 Demonstration of a new distance metric that preserves the geometry of a template
Besides estimation, having a framework allows one to design new distance metrics. In this section, we demonstrate the geometry-preserving metric from Section C on a toy dataset. This metric fits each target by a distribution that preserves the geometry of a chosen source template.
The synthetic dataset contains two conditions, each represented by a noisy square with a different orientation. The source distribution is a unit square with a small amount of noise. We fit each condition using either a similarity-constrained velocity field, which permits only translation, rotation, and isotropic scaling of the source distribution, or an unconstrained nonlinear velocity field. The similarity-constrained model better recovers the ground truth and preserves the square geometry, whereas the unconstrained model distorts it (Figure S12). This combination of a geometry-informed source template and a similarity-constrained velocity field is therefore useful when the data geometry is known or when a particular geometric structure should be preserved.
D Experimental Details
We organize the experimental details into four groups: estimator specifications, simulation datasets, real neural datasets, and the joint estimator–dataset specification for the geometry-template Jeffreys distance.
D.1 Estimators
D.1.1 Flow matching training
For affine flow which contains a velocity with matrix, for example, , the symmetric matrix contains learned entries. This parameter growth can make high-dimensional fits unstable with finite samples, so we use the regularized loss:
We compare six regularization strengths, . We first fit an unregularized model and save its checkpoint. Starting from this shared checkpoint, we then continue fitting separately for each value of . All resulting candidate checkpoints are evaluated on the same validation set, and we select the candidate with the minimum unpenalized validation Flow Matching loss (Section D.1.2).
For unconstrained velocity, we don’t use regularization. We instead divide the fitting data into training and validation sets, apply early stopping with a patience of 1000 epochs, and retain the checkpoint with the lowest validation loss.
Additional training details. Unless otherwise specified, source samples are drawn independently from and independently of the observed responses. At each optimization step, we pair source samples with observed responses, draw the flow time uniformly as , and minimize the loss along a cosine probability path. We optimize using AdamW [Loshchilov and Hutter, 2019] and clip the gradient norm at 10. The network architecture, batch size, and learning rate are experiment-specific and summarized in Table 2.
D.1.2 Velocity network architecture
Condition embedding. Raw conditions are converted to fixed feature vectors before they enter the velocity model. A categorical condition is represented by the one-hot vector .
Throughout this subsection, denotes the number of Gaussian radial-basis centers used for both nonperiodic and periodic scalar embeddings, as detailed below.
For a nonperiodic scalar condition , let and denote the mean and root-mean-square scale of the training conditions. The standardized coordinate and the linear-plus-RBF embedding are
Here and are the extrema of the standardized training conditions. Each Gaussian feature is largest near its center and decays smoothly with distance, while retaining preserves the global linear ordering. The continuous Fisher benchmarks therefore use a nine-dimensional condition vector.
For a period- scalar, centers instead lie uniformly on a circle. With origin , the periodic embedding uses the shortest wrapped displacement :
Consequently , so nearby orientations across the periodic boundary remain nearby in feature space.
In the Stringer experiment, both affine and unconstrained flow use the eight-dimensional periodic embedding with . For a mixed condition consisting of a categorical variable and a scalar , which may be periodic or non-periodic, we concatenate the two representations as . We use this representation for the time-resolved OU experiments, where denotes category and denotes physical time. For both the Allen two-photon calcium-imaging and Neuropixels experiments, indexes the 40 joint drifting-direction–temporal-frequency conditions, while denotes physical time and is represented by .
Network architecture. Responses are standardized using statistics fitted on the fitting responses. The scalar flow time is used directly without any embeddings. Writing , where denotes the appropriate categorical, scalar, periodic, or mixed embedding of the experimental condition described above. Neural architectures are feed-forward multilayer perceptrons with SiLU activation with the width and number of hidden layers listed in Table 2. Neural networks output velocity parameters:
Translation velocity sets , and shared affine replaces by a condition-independent . The square-geometry models use the analogous parameterizations.
Table 2: Flow Matching training settings. Width depth gives the hidden width and number of hidden layers.
| Experiment | Flow family | Width depth | Batch | Learning rate |
|---|---|---|---|---|
| Categorical RDM | constrained and nonlinear | for correlation/cosine; otherwise | ||
| Independent Gaussian Fisher | affine | |||
| Independent mixture Fisher | affine and nonlinear | |||
| Gaussian OU | affine | |||
| Mixture OU | affine and nonlinear | |||
| Stringer | affine and nonlinear | |||
| Allen | affine and nonlinear | |||
| Square geometry | similarity-constrained and nonlinear | FM; NLL |
Jeffreys divergence estimation. When the velocity has the affine (linear-in-state) form , we integrate the mean and covariance ODEs in Eq. (14) and evaluate the corresponding Gaussian distance from the resulting moments; Gaussian Jeffreys divergence uses Eq. (16). For an unconstrained velocity—used to estimate Jeffreys divergence and full Fisher information—we instead generate endpoint samples by solving Eq. (1) and evaluate through the continuous change-of-variables identity in Eq. (111). Jeffreys divergence is then estimated with Eq. (8).
D.1.3 Gaussian-process with kernel regression
Our implementation follows the GKR code of Ye and Wessel [2025], available at https://github.com/AgeYY/speed_grid_cell_information.
GKR models the smooth conditional response distribution as
Here denotes the conditioning input to each fitted GKR model: for the Fisher datasets, for the synthetic OU datasets, and is grating orientation for Stringer. For the Allen two-photon calcium-imaging and Allen Neuropixels ephys datasets, we fit a separate GKR model for each joint drifting-direction-temporal-frequency condition, with within each model. We use an RBF kernel for nonperiodic inputs and a periodic kernel for grating orientation.
Let be the fitted residuals. GKR estimates the conditional covariance by normalized kernel regression of their outer products,
For the nonperiodic scalar conditions, inputs are standardized and
For an orientation with period P, the periodic covariance kernel is instead
The default configuration uses 200 inducing points; 300 mean-GP iterations at learning rate 0.05; and 30 covariance-kernel epochs at learning rate 0.1, with a validation fraction of 1/3.
D.1.4 Wishart-process estimator
Our Wishart process implementation reuses the original JAX/NumPyro model, kernels, variational inference, and posterior-mode prediction from https://github.com/neurostatslab/wishart-process, pinned to commit 5607d14.
The Wishart process models both the mean and covariance of a smoothly condition-dependent Gaussian distribution [Nejatbakhsh et al., 2023]. For a conditioning input and response ,
The latent functions model the conditional mean, while the factors model the conditional covariance; all mean coordinates and covariance factors have independent GP priors. Let collect the active covariance factors used by the upstream implementation, which defines
The Gram matrix is positive semidefinite, and adding makes it positive definite before scaling by . This Gram construction motivates the name Wishart process: at each condition, outer products of Gaussian latent factors form a covariance matrix, while the GP correlations across make that covariance vary smoothly with the condition. The shared matrix is initialized as the Cholesky factor of , where is the pooled within-bin empirical covariance. It is then optimized during SVI.
The mean and covariance-factor GPs use separate product kernels. For and condition coordinate ,
Here and separately control how smoothly the mean and covariance factors vary along condition coordinate : larger widths produce stronger sharing across nearby conditions. The Fisher datasets have one nonperiodic coordinate , whereas the Stringer recordings have one periodic orientation coordinate with period .
The authors' code interface requires an equal-trial tensor with shape . After fixing the train, validation, and test splits, our wrapper bins only the training observations, sets , and subsamples every occupied bin to responses. All validation and test observations are retained. Mean and covariance kernel widths ( and ) are selected by held-out Gaussian log likelihood.
| Benchmark | Mean-kernel widths | Covariance-kernel widths |
|---|---|---|
| Linear Fisher | ||
| Gaussian-mixture full Fisher | ||
| Stringer recordings (initial grid) | ||
| Gaussian OU | ||
| Two-scale Gaussian-mixture OU | ||
| Allen Neuropixels PCA-10 |
Table 3: Kernel-width grids used for the Wishart-process method. An infinite covariance width denotes a covariance that is constant over the continuous variable (e.g. orientation or trial time) within each condition.
To search kernel widths, we evaluate the grids in Table 3, adaptively expanding the search space when needed. We continue the expansion until the validation curve exhibits an inverted-U shape, indicating a local optimum, or until the kernel width becomes sufficiently large to produce nearly constant smoothing. For example, supplementary Figure S5 shows the resulting search profiles for the Stringer recordings.
For the PCA-70 Allen Neuropixels analysis in Figure 7, we found it practically difficult to identify optimal kernel widths because validation often favored very large values, resulting in estimates that were nearly constant over time. This behavior may reflect the high dimensionality and non-Gaussianity of the neural responses.
Therefore we instead reducing the responses to 10 principal components where the Wishart process produced more reasonable fits, as shown in Supplementary Figure S10. Affine flow matching remains best among Gaussian methods.
D.1.5 Cross-fitted optimal linear estimator (OLE)
We mainly follow Kanitscheider et al. [2015] for the locally optimal linear estimator and its finite-sample bias correction. OLE fits a linear decoder on a training set and projects held-out responses onto the resulting axis. Our reported achieved-information estimate applies the bias correction shown below and is clipped at zero.
Specifically, we estimate this quantity with five-fold cross-fitting independently for each adjacent pair on a 31-endpoint grid, where . Responses are assigned to disjoint radius- windows around the two endpoints. If either window contains fewer than eight responses, we instead use the nearest disjoint groups with eight responses per endpoint. For fold , four folds estimate the endpoint means and Ledoit-Wolf covariances. We then form
The fitted decoder is frozen and applied only to the held-out fold. Pooling the five held-out folds therefore evaluates each selected response exactly once out of fold. Let , , , , and , denote the means, sample variances, and counts of the pooled held-out projections. The reported estimate is
D.1.6 TRE density-ratio estimation for categorical Jeffreys divergence
For the full Jeffreys divergence comparison in Supplementary Figure S1, we use telescoping density-ratio estimation (TRE) [Rhodes et al., 2020] with bridges. For each unordered pair of categorical conditions and , TRE draws independent samples and and forms angular waymarks
Then we constructed adjacent-ratio classifiers share a three-hidden-layer MLP trunk with width 128 and use separate linear output heads. Each condition-pair model is trained for at most 1000 epochs with batch size 512, AdamW learning rate , zero weight decay, and gradient clipping at norm 10. We select the checkpoint with the lowest validation loss. If denotes the density of , classifier head is trained with equal class priors to distinguish from . The estimated logits then telescope to
We estimate the Jeffreys divergence for each condition pair by averaging this log ratio under the two endpoint distributions and clip negative finite-sample estimates at zero:
D.2 Simulation datasets
D.2.1 Categorical RDM dataset
Here, we describe the categorical RDM experiment shown in Figure 3.
We define the conditional response distribution as
where Y is uniformly distributed over and z is three-dimensional. We generate the parameters and once and hold them fixed across all five repetitions. Thus, the repetitions share the same category-conditional distributions and differ only in their sampled observations.
Specifically, we generate and as follows. We draw each mean coordinate as , where and . We resample the candidate means until every pair is separated by at least (half the diagonal of the unit cube), thereby keeping the components well separated. We set the conditional variances to
We then independently draw five datasets from this fixed population. When fitting the structured models—that is, all velocity families in Table 1 except the unconstrained family—we use all observations. Because the response dimension is low, we set for affine flow, corresponding to no regularization. The nonlinear Jeffreys model instead uses an 80/20 training–validation split. Figure 3A shows accuracy as a function of sample size, and Figure 3B shows the corresponding RDM estimates at 2,000 total samples.
Figure S1 compares flow matching against plug-in mean estimators for correlation, cosine, and squared Euclidean distance; pooled-covariance Mahalanobis estimators with and without Ledoit–Wolf (LW) shrinkage; a condition-specific LW covariance estimator for Gaussian Jeffreys divergence; and TRE estimators using 1, 8, or 16 bridges for full Jeffreys divergence.
We compute all six ground-truth RDMs analytically from the known population means and diagonal covariances .
We evaluate estimation performance using the mean relative absolute error (MRAE) over the unique off-diagonal category pairs. Let and . For an estimated RDM and its ground-truth RDM ,
With C = 5, the average includes M = 10 unique category pairs.
D.2.2 Fisher datasets
Here we describe the datasets used for estimating Fisher information in Figure 4A–F. We first specify the Gaussian dataset used for linear Fisher information, then the mixture dataset used for full Fisher information.
Gaussian responses and linear Fisher information. For the Gaussian dataset (Figure 4A–C), , while the response dimension follows the sweep protocol below:
The mean is a Gaussian bump with equal-spacing centers
where . and the condition-dependent diagonal covariance is
The d/300 factor preserves the relative covariance modulation across response dimensions.
The target is linear Fisher information, , estimated by affine flow (Section D.1.1 and Proposition A.7), GKR (Section D.1.3), the Wishart process (Section D.1.4), and five-fold cross-fitted OLE (Section D.1.5). The sample-size sweep fixes and uses ; the dimension sweep fixes and uses .
For the affine-flow readout, each adjacent pair , with midpoint , shares a covariance obtained by averaging its two affine matrices at every flow time:
For estimated Fisher information and ground truth at evaluation points, we report MRAE
We additionally report the Pearson correlation between the estimated and ground-truth Fisher curves.
Mixture responses and full Fisher information. For the non-Gaussian dataset (Figure 4D–F), we retain the Gaussian dataset’s and , but introduce an equally likely latent scale branch :
where . Because , the marginal mean and covariance remain exactly and ; therefore changes higher-order structure without changing either of the first two moments, keeping the linear Fisher information the same. The target for the common error panels is the exact mixture full Fisher information,
We use spacing and compare Unconstrained Flow, Affine Flow, GKR, and Wishart. The sample-size sweep fixes and uses ; the dimension sweep fixes and uses .
D.2.3 Time-resolved Jeffreys datasets
Here we describe the Gaussian and non-Gaussian OU datasets in Figure 6A–F.
Gaussian OU dataset: time-local marginals. The time-resolved dataset uses two conditions, , response dimension , and time-bin centers , , . For each tested , the coordinatewise tuning-curve amplitudes are drawn once as , and the preferred time points are evenly spaced over the stimulus interval, , . The common unsigned time-tuning curve is therefore
Let and . At any fixed time t, the marginal distribution is:
Gaussian OU dataset: temporally correlated trials. To introduce within-trial dependence without changing the time-local marginals, let . For each condition and trial , standardized residuals follow the stationary OU recursion
The observations are
Each trial is an independent time sequence. Affine Flow uses a condition-balanced, trajectory-disjoint 80/20 training/validation split, so all time points from a trial remain in the same split. Bin + LW and GKR use all available trials.
Error is summarized by
We compare Bin+LW, GKR, Affine Flow, and the Wishart process. The representative case has and trials per condition. The trial sweep fixes and uses ; the dimension sweep fixes and uses .
Non-Gaussian two-scale OU dataset. For each condition and trial , a narrow or wide covariance branch is drawn with equal probability and held fixed over the complete trajectory. Its time-local conditional distribution and base covariance are
The two conditions have opposite time modulation,
Thus, with , the complete trajectory is
Equal branch probabilities preserve the base mean and covariance, while the opposite modulations make higher-order moments condition dependent. The exact full-mixture Jeffreys reference is Monte Carlo audited.
We compare GKR, Affine Flow, the Wishart process, and Unconstrained Flow. The representative case has and trials per condition. The trial sweep fixes and uses ; the dimension sweep fixes and uses . Both sweeps use five repeats.
D.3 Real neural datasets
D.3.1 Mouse V1 static-grating dataset
The mouse V1 static-grating dataset contains six two-photon calcium-imaging sessions (GT1, GT2, GT3, TX38, TX39, and TX40) collected during full-field static-grating presentation [Stringer et al., 2021]. Each trial contributes one population-response vector and one grating orientation, treated modulo ; each session contains about 4000 trials and roughly 20000 simultaneously recorded neurons. Within each session, we form a deterministic, orientation-stratified 64/16/20% training/validation/test split using seed 7. We fit a centered, unwhitened PCA using only the training trials, retain 200 components, and apply the fixed projection to validation and test trials. We chose 200 because it is close to the across-session median of 209 components required to reach a 70% cumulative explained-variance ratio.
We compare five conditional density estimators on the same splits: binning with Ledoit–Wolf covariance (Bin+LW), GKR, the Wishart process, affine flow, and unconstrained flow. Bin+LW uses 16 equal orientation bins of width , GKR follows Section D.1.3, and the Wishart process follows Section D.1.4, using the adaptive 16-bin fitting protocol and a full-rank covariance factorization. Both flow models use eight periodic radial-basis features for orientation and a three-hidden-layer MLP of width 256; their fitting follows Section D.1.1.
We evaluate held-out log likelihood on the test split. For Bin+LW, GKR, the Wishart process, and affine flow, we use the fitted mean and covariance to compute Gaussian log likelihood; for unconstrained flow, we use the continuous change-of-variables identity in Eq. (111). This comparison measures conditional density fit rather than direct Fisher-information accuracy.
D.3.2 Allen Brain Observatory two-photon calcium-imaging dataset with drifting gratings
We use two-photon calcium-imaging responses from 11 Allen Brain Observatory visual-cortex recording sessions selected to contain more than 300 recorded neurons [de Vries et al., 2020]. Mice viewed drifting gratings spanning eight motion directions (0°, 45°, ..., 315°) and five temporal frequencies (1, 2, 4, 8, and 15 Hz), giving 40 direction–frequency conditions. Each condition has 14–15 repeated trials, corresponding to approximately 560–600 nonblank trials per session. A trial contains 120 frames sampled at 30 Hz and spans four seconds: one second before stimulus onset, two seconds of drifting-grating presentation, and one second after stimulus offset, which also forms the first prestimulus second of the next trial.
For each session, we pool all nonblank observations (conditions × trials × time points) and randomly split into 60% training, 20% validation, and 20% test sets. Trial identity is not used in this split, so frames from the same trial can occur in multiple subsets. We fit a centered, unwhitened PCA to the raw training observations only, retain 95 components, and apply this fixed map to all observations. PCA-95 retains 60.1–89.6% of the training variance across sessions (median 70.2%).
The resulting 95-dimensional observations are conditioned on a categorical index for the 40 direction-frequency combinations and on continuous time. We compare Bin + LW, GKR, the Wishart process, affine flow, and unconstrained flow. Training responses are used for fitting, validation responses for checkpoint or hyperparameter selection, and test responses only for final evaluation.
Supplementary Figure S11 summarizes the responses, held-out likelihood, and time-resolved distance estimates across the 11 two-photon sessions.
D.3.3 Allen Visual Coding Neuropixels dataset
We analyze all 32 recording sessions from the Allen Visual Coding Neuropixels release [Siegle et al., 2021]. These sessions share 40 nonblank drifting-grating conditions formed by eight motion directions and five temporal frequencies. For each session, we retain presentations whose -second analysis window does not overlap an invalid interval. We retain units whose channel lies in VISp, VISI, VISrl, VISam, or VISpm and require presence ratio , inter-spike-interval violations , and amplitude cutoff . The resulting datasets contain 92–373 units and 421–600 presentations per session, with 8–15 presentations per condition.
We count spikes in 40 nonoverlapping 100-ms bins spanning seconds relative to stimulus onset and apply the elementwise square-root transform . Within each session, we fit a centered, unwhitened PCA to all concatenated condition–presentation–time observations before splitting and retain 70 components. These components explain 62.4–95.2% of the variance across sessions (median 72.9%). This is the space we are working on for the rest of analysis. We then randomly divide observation rows into 80% training and 20% test sets; the flow models further divide the outer training rows into 80% training and 20% validation rows.
The models condition on the 40-level direction–frequency index and continuous time. We compare condition-specific Bin + LW, GKR, affine flow, and unconstrained flow. Held-out likelihood is averaged within each condition and then across the 40 conditions, with recording session as the unit of aggregation. For Supplementary Figure S7, we average the 28 unique Jeffreys divergences among the eight directions separately at each temporal frequency within each recording session. Curves and shaded bands show the mean and SEM across the 32 sessions, respectively, with recording session as the aggregation unit. The 4-Hz direction RDMs in Figure 7C are evaluated at the bin centers nearest -0.5, 1.0, and 2.5 seconds (realized centers -0.55, 0.95, and 2.45 seconds) and averaged across sessions.
D.4 Estimator and dataset for the geometry-template Jeffreys distance
Synthetic dataset. Let parameterize the boundary of a centered square with side length , where . For condition , we draw
Only and its condition angle are included in the observed dataset; the perimeter coordinate U is latent. We generate 200 observations per condition and split each condition into 128 training, 32 validation, and 40 test observations (64/16/20%).
Flow-matching fitting. Both models start from the same side-length-one square boundary convolved with isotropic Gaussian noise of initial scale 0.1; thus, the clean source geometry is identical across conditions. We compare two velocity families, each parameterized by a two-hidden-layer MLP of width 64. The similarity-constrained model outputs translation, angular velocity, isotropic scale, and center parameters, so its endpoint map can only translate, rotate, and uniformly rescale the square. The unconstrained model instead maps the response, flow time, and condition directly to a free two-dimensional velocity and may deform the template nonlinearly. We first train each model by Flow Matching along a cosine interpolation path using batch size 256, learning rate , gradient clipping at norm 10, and validation early stopping with patience 1000, while holding the source noise fixed. We then fine-tune by negative log likelihood for 1200 epochs at learning rate , allow a learnable source noise scale , and retain the checkpoint with the lowest validation NLL.
E Supplementary Figures

Figure S1: Estimator accuracy across six representational distances on the five-condition categorical benchmark. Mean relative absolute RDM error is shown against total sample size for correlation, cosine, squared Euclidean, squared Mahalanobis, Gaussian Jeffreys divergence, and full Jeffreys divergence. Specialized estimators are compared with flow matching; the full-Jeffreys panel also includes telescoping density-ratio estimation (TRE) with 1, 8, or 16 bridges [Rhodes et al., 2020]. Markers and error bars show the mean and one sample standard deviation across five repetitions.

C
B
D
Figure S2: Pearson correlation between the estimated and ground-truth curves. (A) Independent Gaussian responses and linear Fisher information. (B) Independent two-scale Gaussian-mixture responses and full Fisher information. (C) Gaussian Ornstein–Uhlenbeck trials and time-resolved Gaussian Jeffreys divergence. (D) Two-scale Gaussian-mixture Ornstein–Uhlenbeck trials and time-resolved full Jeffreys divergence. Method colors follow Figures 4 and 6; points and error bars show the mean and one sample standard deviation across five repetitions. Figure relates to Figures 4 and 6.
| Held-out | Bin + LW | GT3, local half-width 11.2°GKR | Wishart | Affine Flow | Unconstrained Flow | |
|---|---|---|---|---|---|---|
| n = 105 | ||||||
| n = 109 | ||||||
| n = 112 | ||||||
| n = 111 | ||||||
| n = 102 |
Figure S3: Local conditional density fits across orientations in the representative Stringer session GT3. Rows show held-out responses in the first two principal components within circular windows centered at the displayed orientations. Columns compare held-out data, Bin + LW, GKR, the Wishart process, affine flow, and unconstrained flow. Crosses denote held-out observations; inner and outer ellipses or contours enclose 50% and 95% probability mass, respectively.

B
Figure S4: Conditional density and Fisher-information estimates for the Stringer recordings. (A) Held-out responses and fitted conditional densities in the first two principal components for an example session, colored by grating orientation. Gaussian estimators show fitted means and probability ellipses, whereas the unconstrained-flow panel shows generated samples. (B) Fisher-information estimates across the six sessions. GKR, Bin + LW, cross-fitted OLE, the Wishart process, and affine flow estimate linear Fisher information; unconstrained flow estimates full Fisher information. Thin gray curves show individual sessions, and colored curves and error bars show the pointwise mean and session-level standard error of the mean.

Mean width
GT1: finite bracketed
Mean width
Mean width
GT3: finite bracketed
Mean width
TX39: finite bracketed
Mean width
Mean width
TX38: finite bracketed
TX40: validation surface
Mean width
Mean width
Validation log likelihood minus session maximum
TX40: finite bracketed
kernel width
Mean width
Covariance width
Constant- endpoint
Figure S5: Adaptive Wishart kernel-width searches for the Stringer recordings. For each session, the validation surface shows Gaussian log likelihood relative to the session maximum over the mean width and covariance width ; the white star marks the selected pair. The adjacent profile panel shows relative validation likelihood across mean widths (purple circles) and finite covariance widths (green triangles), with the constant-covariance endpoint shown by the orange cross.
Held-out data
Shared Bin + LW
Bin + LW



GKR
Affine Flow
Unconstrained Flow
90°, 2 Hz
180°, 2 Hz
- Held-out observation
Window start bin (-0.95 s)
Stimulus onset bin (-0.05 s)
Stimulus offset bin (1.95 s)
Window end bin (2.95 s)




Time from onset (s)
Figure S6: Time-resolved conditional density trajectories for two drifting-grating conditions in the Allen Neuropixels recordings. Held-out responses and fitted distributions are shown in the first two principal components for the (90°, 2 Hz) and (180°, 2 Hz) conditions. Columns show held-out data, shared Bin + LW, Bin + LW, GKR, affine flow, and unconstrained flow. Marker shape identifies representative time bins from the beginning to the end of the analysis window, and color lightness indicates time from stimulus onset.

Figure S7: Frequency-specific time-resolved Gaussian Jeffreys divergence from classical estimators and affine flow across 32 Allen Neuropixels sessions. At each temporal frequency, Gaussian Jeffreys divergence is averaged over the 28 unique pairs among the eight directions within each session. Colors indicate the five temporal frequencies (1, 2, 4, 8, and 15 Hz). The left panel shows Bin + LW (dashed curves) and GKR (dash-dotted curves); the right panel shows affine flow (solid curves). Curves show across-session means, shaded regions show the SEM, and solid and dashed vertical lines mark stimulus onset and offset. Bin + LW uses a 0.2-s time window.
All-condition RDMs; mean across 32 sessions



Figure S8: Time-resolved all-condition RDMs across 32 Allen Neuropixels sessions. Each matrix is the elementwise mean across sessions for all 40 direction–frequency conditions at -0.55, 0.95, or 2.45 seconds relative to stimulus onset. Columns show Gaussian Jeffreys divergence from Bin + LW, GKR, and affine flow, followed by full Jeffreys divergence from unconstrained flow. Conditions are grouped by temporal frequency, with eight motion directions within each block.

Figure S9: Conditional density fits at four example times in an example Allen Neuropixels session. Held-out responses and fitted conditional densities are shown in the first two principal components for the (90°, 2 Hz) and (180°, 2 Hz) conditions. Rows correspond to windows centered at -0.55, 0.45, 1.45, and 2.45 seconds relative to stimulus onset; the displayed counts give the held-out observations for the two conditions. Columns compare held-out data, shared Bin + LW, Bin + LW, GKR, affine flow, and unconstrained flow.

Figure S10: Held-out likelihood across five Allen Neuropixels sessions after projection onto 10 principal components. Held-out log likelihood relative to GKR is shown for Bin + LW, GKR, the Wishart process, affine flow, and unconstrained flow. Gray lines connect estimates from the same session, black dots show individual sessions, and bars and error bars show the across-session mean and standard error of the mean.


B
C
D
Figure S11: Responses, held-out likelihood, and time-resolved representational geometry in the Allen two-photon recordings. (A) Four-second trial structure and baseline-corrected response heat maps for two drifting-grating conditions in a representative session. (B) Held-out log likelihood relative to GKR across 11 imaging sessions; gray lines connect estimates from the same session, and bars and error bars show the across-session mean and standard error of the mean. (C) Affine-flow Gaussian Jeffreys divergence averaged over condition pairs and 4-Hz direction RDMs at representative pre-stimulus, stimulus, and post-stimulus times. (D) Corresponding full Jeffreys divergence and RDMs from unconstrained flow. Curves and shaded regions summarize mean and SEM of the 11 sessions.
Held-out data
Jeffreys = 0.927
Lie similarity
Jeffreys = 1.145
Unconstrained
Jeffreys = 0.349



× Held-out, c = 0 × Held-out, c = 1 — Boundary, c = 0 — Boundary, c = 1 — Source boundary
Figure S12: Similarity-constrained flow preserves a square template when estimating representational dissimilarity. Left: held-out observations from two noisy-square conditions, with solid curves showing their noiseless target boundaries. Middle and right: fits obtained using similarity-constrained and unconstrained flows, respectively, with the same side-length-one square source. In the fitted panels, the dashed black curve shows the original source boundary, and the solid colored curves show the condition-specific transported boundaries. Crosses denote held-out observations, and each panel title reports the Jeffreys divergence between the two condition distributions. The similarity-constrained fit preserves the square geometry, whereas the unconstrained fit distorts it.
Time-to-time RDM correlation · mean of 32 session-wise correlations




Figure S13: Time-to-time RDM correlations across estimators in the Allen Neuropixels recordings. Panels compare Bin+LW, GKR, affine flow, and unconstrained flow. Each matrix shows Pearson correlations between RDMs at pairs of time points, computed within each recording session and then averaged across 32 sessions. Dashed lines mark stimulus onset at 0 seconds and offset at 2 seconds.