Embedding interpretable ℓ 1 \ell_{1} -regression into neural networks for uncovering temporal structure in cell imaging Fabian Kabus, Maren Hackenberg, Julia Hindel, Thibault Cholvin, Antje Kilias, Thomas Brox, Abhinav Valada, Marlene Bartos, Harald Binder Abstract While artificial neural networks excel in unsupervised learning of non-sparse structure, classical statistical regression techniques offer better interpretability, in particular when sparseness is enforced by ℓ 1 \ell_{1} regularization, enabling identification of which factors drive observed dynamics. We investigate how these two types of approaches can be optimally combined, exemplarily considering two-photon calcium imaging data where sparse autoregressive dynamics are to be extracted. We propose embedding a vector autoregressive (VAR) model as an interpretable regression technique into a convolutional autoencoder, which provides dimension reduction for tractable temporal modeling. A skip connection separately addresses non-sparse static spatial information, selectively channeling sparse structure into the ℓ 1 \ell_{1} -regularized VAR. ℓ 1 \ell_{1} -estimation of regression parameters is enabled by differentiating through the piecewise linear solution path. This is contrasted with approaches where the autoencoder does not adapt to the VAR model. Having an embedded statistical model also enables a testing approach for comparing temporal sequences from the same observational unit. Additionally, contribution maps visualize which spatial regions drive the learned dynamics. ReLU rectified linear unit SGD stochastic gradient descent LARS least angle regression VAR vector autoregressive model ROI region of interest Keywords deep learning \cdot interpretability \cdot lasso regression \cdot time series \cdot two-photon imaging 1 Introduction Integrating neural networks with interpretable statistical models is a promising approach that combines the strengths of both paradigms ( 36 ) . Neural networks excel in capturing complex non-sparse patterns in high-dimensional data, making them well suited for tasks such as visual feature extraction and dimensionality reduction, e.g. using convolutional networks and autoencoders. In contrast, classical statistical models typically provide interpretability through their theoretical guarantees. For instance, autoregressive time series models provide interpretable parameter estimates besides predictions ( 29 ) . The most important factors can be obtained by fitting parameters under \ell_{1} -regularization, as popularized by the Lasso approach ( 38 ) , which can provide a small set of non-zero parameter estimates. This approach has established itself for a broad class of regression settings and, in particular, enables the identification of sparse patterns in time series models ( 12 ) . Therefore, a combination of a neural network with \ell_{1} -regression could address non-sparse complex structure with the former and sparse, interpretable structure with the latter. However, this raises the question of how to best direct each approach at the types of structure in a dataset it can excel at. In addition, joint training is nontrivial, due to different parameter estimation techniques for both types of approaches. Neural network training typically relies on SGD ( SGD ) or its variants, e.g. ( 24 ) , taking a heuristic approach for finding a local optimum. In contrast, parameter estimation for classical statistical models often relies on closed-form solutions or small-scale convex optimization, which typically guarantees to find a global optimum under certain assumptions ( 11 ; 8 ) . To leverage the advantages of both types of models, we propose a hybrid estimation approach, illustrated on a combination of a convolutional autoencoder neural network with an \ell_{1} regularized VAR ( VAR ) model, trained end-to-end. As an exemplary application setting, we consider extracting sparse temporal patterns from biomedical neural cell imaging videos. There, we also demonstrate how embedding a statistical model into a neural network architecture enables statistical inference. Specifically, we apply our convolutional encoder to each frame of video to reduce the dimensionality and map time-varying signals into latent space. Subsequently, an \ell_{1} -regularized VAR provides sparse parameter estimates and describes the latent temporal dynamics. We propose that this approach is valuable in domains requiring both feature extraction and interpretable temporal modeling. Similar approaches have already been investigated, e.g., in biomedical applications, where longitudinal data often benefit from dimension reduction combined with interpretable temporal models. For example, ordinary differential equations ( 33 ; 1 ; 25 ) , Gaussian processes ( 10 ; 19 ; 32 ) , mixed-effects models ( 16 ; 34 ) have been integrated into variational autoencoder frameworks to capture temporal dynamics in a low-dimensional latent space. Moreover, general linear state-space models have been combined with deep generative models, including probabilistic approaches like deep Kalman filters ( 26 ) and control-oriented frameworks such as 39 that assume locally linear dynamics. However, these approaches typically do not emphasize sparse structure obtained via \ell_{1} -regularization, nor do they leverage classical statistical estimation techniques with established convergence guarantees. For instance, a naive approach for obtaining parameter estimates for both, the neural networks and the VAR model, would be to train the components sequentially, i.e. first the autoencoder, followed by fitting the VAR model on the resulting latent space. However, disjoint training is prone to sub-optimal results. Due to the non-convex nature of deep neural networks, the optimization may converge to one of many distinct local minima ( 15 ; 27 ) . While these minima may perform equally well for reconstruction, they generate vastly different latent representations. Without feedback from the temporal model, the autoencoder is likely to settle into a minimum where the latent dynamics are not easily captured by a VAR process. Multi-task learning, as an alternative paradigm, would suggest adding the VAR loss and \ell_{1} -penalty to the reconstruction loss of the autoencoder. However, simply combining loss terms in a weighted sum can be problematic. First, gradients of different objectives might conflict ( 35 ) . Second, the relative scales of those objectives may require extensive hyperparameter tuning ( 14 ) . Moreover, this approach would not make use of well-established estimation approaches for \ell_{1} -regularized regression with known convergence properties, such as coordinate descent ( 42 ) and LARS ( LARS ) ( 18 ) . In our proposed hybrid approach, these properties can be maintained by unrolling the fitting procedure of the regression model to allow for the use of automatic differentiation techniques ( 2 ) that can provide end-to-end gradients. Similar ideas have been explored in domains such as Alternating Direction Method of Multipliers (ADMM) unrolling ( 44 ) and differentiable ODE solvers ( 13 ) . For specific regression models, several solvers exist that can implement \ell_{1} -regularization, including coordinate descent ( 42 ) , Fast Iterative Shrinkage-Thresholding Algorithms (FISTA) ( 3 ) , ADMM ( 9 ) and LARS ( 18 ) . We illustrate how to adapt the LARS approach, motivated by its stability in the face of correlated features ( 18 ) and its efficiency in tracing the regularization path, which helps to mitigate vanishing gradients in unrolled architectures ( 4 ) . By formulating an end-to-end differentiable procedure, where gradients from the statistical model fitting process flow back into the encoder network of the autoencoder, the encoder is enabled to learn representations specifically tailored to facilitate sparse interpretable temporal VAR modeling. To ensure that each component receives the representation it can process effectively, we propose an architectural design that separates static spatial patterns from dynamic temporal structure, routing the former directly to the reconstruction while channeling the latter through the encoder and VAR model. In Section 2 we detail our proposed hybrid architecture, including a skip connection design for channeling time-varying patterns towards the VAR model, and the proposed end-to-end training approach via a differentiable LARS algorithm. In addition, we propose a statistical testing procedure based on the VAR model, as well as contribution maps that localize the learned dynamics in the original image space. Inspired by concept activation vectors ( 23 ) , which project learned representations back to human-interpretable concepts, our contribution maps project the sparse VAR coefficients back to the input image space, revealing which spatial locations drive the learned temporal dynamics. Section 3 evaluates the proposed approach in an application to two-photon imaging data ( 37 ) , a biomedical video scenario where high spatial complexity and temporal patterns of neuronal firing demand an interpretable statistical model. There, we particularly highlight the gained interpretability provided by the proposed approach. In Section 4 , we discuss how the approach might be transferred to other settings where a combination of \ell_{1} -regularized regression and neural networks might be useful. 2 Methods 2.1 Channeling temporal structure into a VAR model We consider a dataset of N independent time series, where the i -th time series is a sequence of high-dimensional frames \{\bm{x}_{t}^{(i)}\}_{t=1}^{T_{i}} , with \bm{x}_{t}^{(i)}\in\mathbb{R}^{H\times W} . The focus in modeling such data is on the dynamic structure, but there might also be significant static content obscuring the temporal information. Therefore, we suggest separating the static information from temporal patterns, as illustrated in Figure 1 . We train model parameters via a reconstruction task that is constrained by a VAR model that connects frames of the time series. The original data \bm{x}_{t}^{(i)} is reconstructed as \hat{\bm{x}}_{t}^{(i)}=\left(f_{\text{dec}}\left(f_{\text{VAR}}\left(f_{\text{enc}}(\bm{x}_{t-1}^{(i)}-\bar{\bm{x}}),\ldots,f_{\text{enc}}(\bm{x}_{t-p}^{(i)}-\bar{\bm{x}})\right)\right)+\bm{1}\right)\odot\bar{\bm{x}}\,\,\,\,\,\,\,\,\,t=p+1,\ldots,T, where \bm{1} is a tensor of ones and \odot denotes the Hadamard product, directly connecting the static component \bar{\bm{x}} to the reconstruction, thus implementing a skip connection, where information can bypass the encoder neural network f_{\text{enc}}:\mathbb{R}^{H\times W}\to\mathbb{R}^{H^{\prime}\times W^{\prime}} , the VAR model f_{\text{VAR}}:\mathbb{R}^{p\times H^{\prime}\times W^{\prime}}\to\mathbb{R}^{H^{\prime}\times W^{\prime}} , and the decoder f_{\text{dec}}:\mathbb{R}^{H^{\prime}\times W^{\prime}}\to\mathbb{R}^{H\times W} . The static component is defined as \bar{\bm{x}}=\frac{1}{N}\sum_{i=1}^{N}\frac{1}{T_{i}}\sum_{t=1}^{T_{i}}\bm{x}_{t}^{(i)}, i.e. the mean over all frames in the dataset. This mean frame captures the non-sparse, time-invariant structure common to all time series and is subtracted from each input frame \bm{x}_{t}^{(i)} before passing it to the encoder f_{\text{enc}} for obtaining a latent representation \bm{z}_{t}^{(i)}=f_{\text{enc}}(\bm{x}_{t}^{(i)}-\bar{\bm{x}})\,\,\,\,\,\,\,\,\,t=1,\ldots,T. This optimizes the latent space exclusively for modeling the time-varying aspects of the data. The latent values of the current frame are predicted based on the previous p frames. We interpret the latent representation as a multivariate time series and apply a VAR model of order p with parameters \bm{A}_{k}^{(i)}\in\mathbb{R}^{K\times K},k=1,\ldots,p , to capture its dynamics f_{\text{VAR}}(\bm{z}_{t-1}^{(i)},\ldots,\bm{z}_{t-p}^{(i)})=\operatorname{unvec}\left(\sigma_{\bm{z}}\cdot\sum_{k=1}^{p}\bm{A}_{k}^{(i)}\operatorname{vec}(\bm{z}_{t-k}^{(i)}/\sigma_{\bm{z}})\right), where the function \operatorname{vec}:\mathbb{R}^{H^{\prime}\times W^{\prime}}\to\mathbb{R}^{K},K=H^{\prime}\cdot W^{\prime} flattens the latent representation into a vector and the function \operatorname{unvec}:\mathbb{R}^{K}\to\mathbb{R}^{H^{\prime}\times W^{\prime}} reshapes the autoregressive output back into a matrix corresponding to the latent representation. To ensure that the VAR model operates on data with a consistent scale, the input from the latent representation is normalized by the standard deviation \sigma_{\bm{z}} , computed across all latent vectors in the time series i . From the prediction of the VAR model, the decoder f_{\text{dec}} reconstructs the dynamic component of the frame, which is then combined with the static component provided by the skip connection. The decoder outputs a residual map that modulates the static component to restore the original frame. By feeding the VAR forecast, rather than the original latent state, to the decoder, reconstruction performance depends on the ability of the VAR model to accurately predict the latent dynamics. Figure 1: High-level overview of the sparse spatiotemporal dimension reduction in the end-to-end model. The frames \bm{x}_{t}^{(i)} for all time series are first aggregated over time to form a mean frame \bar{\bm{x}} , which captures the static structure. The dynamic component, \bm{x}_{t}^{(i)}-\bar{\bm{x}} , is encoded into a latent representation \bm{z}_{t}^{(i)} . The latent representation \operatorname{vec}(\bm{z}_{t}^{(i)}) is modeled using a sparse vector autoregressive (VAR) model of order p , which forecasts \hat{\bm{z}}_{t}^{(i)} . The coefficient matrices \bm{A}_{1}^{(i)},\ldots,\bm{A}_{p}^{(i)} are fit using \ell_{1} -regression from scratch in each forward pass and they contain the learned spatiotemporal relationships. Finally, the decoder reconstructs the frame \hat{\bm{x}}_{t}^{(i)} from \hat{\bm{z}}_{t}^{(i)} and the static mean frame \bar{\bm{x}} , which is reintroduced via a skip connection. We use an encoder that comprises three sequential convolutional blocks to downsample the spatial resolution. Each block consists of a 3\times 3 convolutional layer (32 channels), a leaky ReLU ( ReLU ) activation, batch normalization, and a 2\times 2 max-pooling layer. After the final pooling stage, a 1\times 1 convolution collapses the feature channels to produce the latent representation \bm{z}_{t}^{(i)} . The decoder mirrors the encoder’s architecture. It begins with a 1\times 1 convolution to expand the channel dimension, followed by three sequential upsampling blocks. Each decoder block uses max-unpooling with kernel size 2 , leveraging indices from the corresponding encoder max-pooling layer to preserve spatial details. This operation is followed by a 3\times 3 convolution, batch normalization, and a leaky ReLU normalization. For obtaining the parameters of the encoder and decoder, we use stochastic gradient descent (SGD) across all N time series. A single encoder and decoder are shared across all time series, making them comparable at the level of the latent representation. In contrast, we allow for an individual set of parameters in the VAR model for each time series i . During training, each time series is divided into non-overlapping subsequences of a fixed length, and these subsequences serve as mini-batches for the optimizer. This approach allows the model to learn from temporal context within each subsequence while permitting efficient batched computation. The encoder and decoder are trained to minimize the reconstruction loss \mathcal{L}_{\text{rec}}=\frac{1}{N}\sum_{i=1}^{N}\frac{1}{T_{i}HW}\sum_{t=1}^{T_{i}}\|\bm{x}_{t}^{(i)}-\hat{\bm{x}}_{t}^{(i)}\|^{2}. 2.2 Differentiating through least angle regression for the VAR model For estimating the parameters of the VAR model, we consider the \ell_{1} -regularized loss \|\bm{z}_{t}^{(i)}-f_{\text{VAR}}(\bm{z}_{t-1}^{(i)},\ldots,\bm{z}_{t-p}^{(i)})\|+\lambda\cdot\sum_{k=1}^{p}\sum_{j=1}^{K}\sum_{l=1}^{K}|a_{jl}^{(i,k)}|, where a_{jl}^{(i,k)} denotes the elements of A_{k}^{(i)} , and \lambda is a tuning parameter that regulates the regularization strength and thus the number of non-zero parameter estimates. Materializing the complete design matrix for the vectorized VAR model would be computationally prohibitive for high-dimensional latent spaces. To overcome this computational bottleneck, our implementation exploits the sparsity-inducing nature of the LARS algorithm. Instead of constructing the full design matrix, we compute matrix-vector products on-the-fly only for the small subset of active coefficients at each step of the algorithm. This makes the fitting process tractable. For estimating the parameters of f_{\text{VAR}} , we aim for end-to-end trainability together with f_{\text{enc}} and f_{\text{dec}} , which requires that gradients from the final reconstruction loss propagate back through the entire architecture, including the VAR parameter fitting process. To achieve this, we fit the VAR parameters from scratch using \ell_{1} -regression within each forward pass of the network. This learning procedure optimizes the encoder to produce a latent representation whose dynamics are well described by a sparse linear model. Differentiating through \ell_{1} solvers is, however, nontrivial. First, the \ell_{1} penalty is not differentiable at zero, and iterative solvers typically involve branching logic (thresholding, sign checks) that obstructs smooth backpropagation ( 22 ; 7 ; 5 ) . In practice, such non-differentiable operators do not necessarily preclude gradient descent, e.g. the ReLU activation function and frequently used \min functions are similar in this respect, and modern AD frameworks can propagate subgradients, but they can still create instability when embedded in larger optimization loops ( 6 ) . A more serious issue arises when iterative algorithms are unrolled into a computational graph: each solver iteration corresponds to another layer in the graph, which can easily run into vanishing or exploding gradient problems when backpropagating through many steps ( 4 ; 5 ) . To address these issues, we use the least angle regression ( LARS ) algorithm ( 18 ) , which traces the \ell_{1} solution by a piecewise-linear homotopy in the regularization tuning parameter \lambda . Even if it requires many steps, each step is a simple geometry event (one variable entering or leaving the active set) with closed-form coefficient updates. This yields a more direct computation for differentiation: gradients follow linear segments with kinks only at discrete active-set events. By contrast, pathwise coordinate - descent solvers such as implemented in glmnet ( 20 ) perform many sequential updates across variables and along a grid of \lambda values. In practice, we observe numerical instability during backpropagation through the LARS step that selects the move size \hat{\gamma} . Instability arises when candidate step computations become nearly singular. To prevent this, we add a small sign-aware constant \epsilon_{\gamma}>0 to the relevant terms before selecting the step. This simple regularization avoids near-division-by-zero and stabilizes gradients without otherwise affecting the path. 2.3 Statistical testing of group differences in VAR coefficients To quantitatively assess whether the dynamics learned by the model differ between groups of time series, we employ a statistical test based on swapping the fitted VAR coefficients. For a latent time series \bm{z}^{(s)} with VAR coefficients \{\bm{A}_{k}^{(s)}\}_{k=1}^{p} , we define the prediction error with swapped coefficients \{\bm{A}_{k}^{(r)}\}_{k=1}^{p} and the corresponding error differential as \mathcal{E}_{sr}=\frac{1}{(T_{s}-p)K}\sum_{t=p+1}^{T_{s}}\left\|\bm{z}_{t}^{(s)}-f_{\text{VAR}}^{(r)}(\bm{z}_{t-1}^{(s)},\ldots,\bm{z}_{t-p}^{(s)})\right\|^{2},\quad\Delta_{sr}=\mathcal{E}_{sr}-\mathcal{E}_{ss}, where f_{\text{VAR}}^{(r)} denotes the VAR function with coefficients \{\bm{A}_{k}^{(r)}\}_{k=1}^{p} . The central idea is to test whether swapping coefficients between groups leads to a significantly larger drop in prediction accuracy than swapping them within the same group. Consider two disjoint groups of time series with index sets G,H\subseteq\{1,\ldots,N\} . We compute these differentials for all intra-group swaps (pairs within G or within H ) and inter-group swaps (pairs across G and H ), yielding distributions \{\Delta_{sr}\}_{\text{intra}} and \{\Delta_{sr}\}_{\text{inter}} . Under the null hypothesis of identical group dynamics, these distributions should coincide. We suggest to test whether \{\Delta_{sr}\}_{\text{inter}} is stochastically greater than \{\Delta_{sr}\}_{\text{intra}} using a one-sided Wilcoxon rank-sum test ( 41 ) . 2.4 Localizing dynamical differences via contribution maps While the coefficient-swapping test detects global differences, it does not reveal their spatial origin. As a post-hoc analysis to identify where these differences manifest, we project the learned VAR structure back into image space. We define an influence vector \bm{c}^{(i)}\in\mathbb{R}^{K} and map it to a visual contribution map via \bm{\Omega}^{(i)}=\left(f_{\text{dec}}(\gamma_{\text{viz}}\cdot\operatorname{unvec}(\bm{c}^{(i)}))+\bm{1}\right)\odot\bar{\bm{x}}, where \gamma_{\text{viz}} is a visualization gain factor. The influence vector for each time series i captures the total outflow of each latent variable across all lags by aggregating the fitted VAR coefficients as \bm{c}^{(i)}_{j}=\sum_{k=1}^{p}\sum_{l=1,l\neq j}^{K}\left|a_{jl}^{(i,k)}\right| , excluding autocorrelation, with absolute values ensuring that both excitatory and inhibitory influences contribute positively to the influence score. To confirm that this aggregation retains the discriminative information captured by the full VAR coefficient matrices, we apply a test analogous to the global coefficient-swapping approach: We compute pairwise squared Euclidean distances d_{sr}=\|\bm{c}^{(s)}-\bm{c}^{(r)}\|^{2} between influence vectors and test whether inter-group distances exceed intra-group distances using a one-sided Wilcoxon rank-sum test. A significant result provides an additional indication that the contribution maps reflect meaningful dynamical distinctions rather than noise. 3 Results 3.1 Dataset and preparation To demonstrate our method’s applicability, we used it to analyze a real-world dataset. The data consists of two-photon calcium imaging recordings of a mouse brain, originally acquired by 37 . The goal is to model neural dynamics, which is an exemplary application for the general problem of modeling sparse, localized dynamics in video data with significant background noise and sensor artifacts. The recordings exhibit challenges typical of in vivo two-photon imaging, as comprehensively described in reviews and computational frameworks ( 21 ; 30 ; 31 ) . The signal mostly consists of a structured background originated from tissue autofluorescence, neuropil fluorescence, and systematic illumination or scan-pattern artifacts, which is predominantly static over time. Superimposed on this background is shot noise from photon statistics, producing unstructured high-frequency fluctuations that can obscure weak events and set fundamental sensitivity trade-offs. In addition, the planar recording inevitably captures some contribution from out-of-focus structures, leading to a quasi-static haze that further complicates interpretation. Finally, signals from individual neurons are often contaminated by source overlap and local mixture with surrounding neuropil, causing genuine transients to be blended with background activity. Distinguishing true, localized transients from this combination of static structure and stochastic noise is therefore non-trivial. Our architecture reflects this decomposition: the skip path routes static or quasi-static content around the encoder, while end-to-end training of the latent dynamics encourages the model to explain structured, time-localized changes in the latent space and attributes unstructured noise to the reconstruction loss, thereby improving the separability of transients from noise. The dataset comprises 40 video runs, captured during an experiment where a mouse navigates one of two virtual environments, denoted F (familiar) and N (novel). These conditions were used to investigate differences in the temporal dynamics of neurons during spatial navigation. The runs were acquired in a repeating pattern of five from condition F followed by five from condition N, resulting in 20 F runs and 20 N runs. Each run is a time-series of frames, with lengths ranging from 306 to 1206 frames (mean 434.8\pm 160.9 ). We preprocess the dataset before feeding the frames into the encoder. Each video sequence is divided into non-overlapping subsequences of window size 64 . Further, we center crop the 2D frames to a resolution of 768\times 512 and downscaled them with nearest neighbor interpolation to 192\times 128 . Finally, the pixel values were normalized to the range [0,1] . We use the Adam optimizer with a learning rate \alpha=0.001 for 2 epochs, the VAR model with lag p=5 frames, and \ell_{1} penalties \lambda\in\{0.005,0.01,0.02\} . 3.2 The skip connection improves signal-to-noise ratio in the latent space Figure 2: Effect of the skip connection on the latent representation and reconstruction from one run at t=263 : Top row (a–c) : model without skip connection. Bottom row (d–f) : model with skip connection. (a, d) Latent representation \bm{z}_{t}^{(i)} . (b, e) Decoder output f_{\text{dec}}(\bm{z}_{t}^{(i)}) , brightness enhanced for visual clarity. (c) Ground truth input \bm{x}_{t}^{(i)} , contrast enhanced. (f) Reconstruction \bm{\hat{x}}_{t}^{(i)} with skip connection, contrast enhanced. We introduce the skip connection to bypass static information directly to the decoder, preventing it from entering the latent space where it does not contribute temporal information conducive to VAR modeling. Figure 2 illustrates its effect on the latent representation. The skip connection improves the signal-to-noise ratio of the latent space with respect to transient activations. Comparing panels (a) and (d) in Figure 2 , the latent representation \bm{z}_{t}^{(i)} without skip reflects both dynamic transients and static background structure. While large activations remain visible, smaller transients are difficult to distinguish from the pervasive background. With the skip connection, static content is routed through the aggregate frame to the decoder, causing it to vanish from the latent space. This leaves \bm{z}_{t}^{(i)} to represent primarily transient activations, where both strong and subtle temporal features now stand out clearly. The effect is further illustrated by the decoder output f_{\text{dec}}(\bm{z}_{t}^{(i)}) in Panels (b) and (e). Without skip connection (Panel b), the latent space contains both dynamic and static content, and the decoder must reconstruct the full image from \bm{z}_{t}^{(i)} alone. With the skip connection (Panel e), the decoder renders localized ’blobs’ corresponding to neural activity, while the static background is handled separately by the skip path. As a secondary benefit, reconstruction error \mathcal{L}_{\text{rec}} decreases from (9.20\pm 2.52)\cdot 10^{-5} to (8.08\pm 2.80)\cdot 10^{-5} with the skip connection. 3.3 Coefficients distinguish experimental conditions G H p-value F_{1} to F_{10} F_{11} to F_{20} 0. 1781 N_{1} to N_{10} N_{11} to N_{20} 0. 5136 F_{1} to F_{10} N_{1} to N_{10} 0 . 0002 F_{11} to F_{20} N_{11} to N_{20} 0 . 0021 F_{1} to F_{10} N_{11} to N_{20} 0 . 0001 F_{11} to F_{20} N_{1} to N_{10} 0 . 0002 Table 1: Group comparisons using VAR coefficients ( \lambda=0.005 ), between runs F with familiar condition, between runs N with novel condition, and between runs F and N of different type. The similarity between sets of experimental runs based on their estimated dynamics is assessed by p-values. Significant p-values (after Bonferroni correction) are indicated by boldface. To assess whether the VAR coefficients \bm{A}_{1},...,\bm{A}_{p} can uncover systematic differences in dynamic patterns between runs, we use the proposed testing procedure on the familiar (F) and novel (N) experimental conditions. We performed pairwise similarity tests between these groups using the coefficients obtained from models trained with a Lasso penalty \lambda=0.005 . The results are presented in Table 1 . When comparing subsets from the same experimental condition (e.g., early F runs vs. late F runs), the p-values were not statistically significant, after accounting for multiple comparisons. Using a significance level of \alpha=0.05 and applying Bonferroni correction for the 6 tests performed, the observed within-condition p-values exceed the adjusted significance threshold. This suggests that there are no strong differences between runs of the same condition, i.e. the estimated coefficients generalize across the runs. In contrast, all comparisons between F and N conditions yielded significant p-values (all p<0.003 ). This indicates that the estimated VAR coefficients capture the differences in neural dynamics between the conditions. Thus, the sparse VAR coefficients derived by our end-to-end model seem to be meaningful descriptors of the underlying neural dynamics, capturing the differences between experimental conditions, while showing limited intra-condition variability. 3.4 Interpreting the sparse coefficients Figure 3: Assessing the effect end-to-end learning via automatic differentiation (AD) with visual contribution maps, \bm{\Omega} , which illustrate the spatial origins of estimated dynamics, averaged across all runs of an exemplary mouse: (a) Familiar condition without end-to-end training. (b) Familiar condition with end-to-end training. (c) Difference map ( \bm{\Omega}^{F}-\bm{\Omega}^{N} ) without end-to-end training. (d) Difference map ( \bm{\Omega}^{F}-\bm{\Omega}^{N} ) with end-to-end training. Figure 4: Effect of \ell_{1} regularization parameter \lambda on time series forecast and reconstruction. (a) Selected dimensions of \bm{z}_{t} in black (reference) and their forecasts \hat{\bm{z}}_{t} for varying \lambda (in colors) over time. (b–d) Reconstructions at t=263 : (b) Ground truth \bm{x}_{t} . (c) Reconstruction \hat{\bm{x}}_{t} for \lambda=0.003 . (d) Reconstruction \hat{\bm{x}}_{t} for \lambda=0.032 . To inspect the estimated dynamics in more detail and identify the spatial origins of differences between experimental conditions, we compute the visual contribution maps \bm{\Omega}^{(i)} for each time series i and average them across all runs within the Familiar (F) and Novel (N) conditions, obtaining \bm{\Omega}^{F} and \bm{\Omega}^{N} . Figure 3 displays these maps, comparing training without end-to-end gradients (Panels a, c) to our proposed full end-to-end approach (Panels b, d). The difference maps \bm{\Omega}^{F}-\bm{\Omega}^{N} (Panels c, d) reveal clear differences between the experimental conditions. The contribution map \bm{\Omega}^{F} (Panels a, b) is predominantly positive, indicating higher outflow signal in the estimated coefficients in the familiar condition F across multiple neural assemblies. This finding aligns with empirical evidence that familiar environments exhibit more stable and coordinated population activity ( 37 ) : The higher outflow in F reflects stronger, more established influence relationships between neural assemblies. As seen from the difference maps, the novel condition N shows weaker structure, consistent with an exploratory phase where dynamics are less coordinated. Comparing the two training strategies, our proposed end-to-end approach (Panels b, d) produces markedly sparser and more localized maps, revealing distinct, identifiable spatial structures. In contrast, the embedded model without end-to-end gradients (Panels a, c) yields more diffuse and less interpretable patterns of influence. In particular, end-to-end training (Panel d) produces a more distinct and localized pattern of the condition difference compared to training without backpropagation through LARS (panel c). These visual differences demonstrate how backpropagation through the LARS solver shapes the learned representations to be more interpretable. As a consistency check, we applied the proposed test at the level of influence vectors, comparing all F runs against all N runs. Both training approaches yield significant differences: the embedded model gives p=0.026 and the end-to-end model gives p=0.018 , confirming that the aggregated influence vectors \bm{c}^{(i)} retain discriminative information from the full coefficient matrices. We furthermore assessed the sensitivity of both the latent forecasts and the resulting reconstructions to the regularization parameter \lambda . As shown in Figure 4 , lower regularization (e.g., \lambda=0.003 ) produces forecasts that closely track the reference signal (Panel a), and the corresponding reconstruction (Panel c) closely matches the ground truth (Panel b), capturing nearly all transient activations. In contrast, higher regularization (e.g., \lambda=0.032 ) leads to sparser forecasts that retain only the strongest activations (Panel a), and the reconstruction (Panel d) accordingly captures only the most prominent features while suppressing weaker transients. This shows that \lambda provides intuitive control over the trade-off between reconstruction fidelity and coefficient sparsity. When tuning \lambda , visually inspecting the reconstruction or observing \mathcal{L}_{\text{rec}} gives feedback on the desired level of regularization. The approach works for a range of \lambda values, and as intended, \lambda effectively controls the sparsity of the learned coefficients. Yet, the identified structure and the reconstruction appear to be rather similar overall, at least in the example in Figure 4 , even when changing \lambda by an order of a magnitude. Therefore, results might not be very sensitive to this tuning parameter, which could avoid the need for careful tuning. 3.5 End-to-end training yields a more predictable latent space To evaluate the effectiveness of our proposed end-to-end training strategy with differentiable LARS , we conducted an ablation study comparing three different approaches for combining the autoencoder (AE) and the VAR model, summarized in Table 2 . The goal is to understand how the integration method impacts reconstruction error \mathcal{L}_{\text{rec}} and the predictability of the latent space dynamics. To assess the latter, we use the relative VAR prediction error \mathcal{R}_{\text{var}} , which normalizes each time point’s squared error by its squared signal magnitude: \mathcal{R}_{\text{var}}=\frac{1}{N}\sum_{i=1}^{N}\frac{1}{T_{i}-p}\sum_{t=p+1}^{T_{i}}\frac{\|\bm{z}_{t}^{(i)}-\hat{\bm{z}}_{t}^{(i)}\|^{2}}{\|\bm{z}_{t}^{(i)}\|^{2}}, where \hat{\bm{z}}_{t}^{(i)}=f_{\text{VAR}}(\bm{z}_{t-1}^{(i)},\ldots,\bm{z}_{t-p}^{(i)}) . Table 2: Ablation study comparing different methods of combining the autoencoder and the VAR model (sequential training, embedded VAR without end-to-end gradients, and our proposed end-to-end approach) via reconstruction error ( \mathcal{L}_{\text{rec}} ) and prediction error \mathcal{R}_{\text{var}} at three different levels of \lambda . Sequential Embedded End-to-End \lambda=0.005 \mathcal{L}_{\text{rec}} [ 10^{-3} ] 0.087 \pm 0.030 0.101 \pm 0.035 0.103 \pm 0.038 \mathcal{R}_{\text{var}} 0.472 \pm 0.040 0.421 \pm 0.054 0.398 \pm 0.068 \lambda=0.01 \mathcal{L}_{\text{rec}} [ 10^{-3} ] 0.087 \pm 0.030 0.106 \pm 0.037 0.112 \pm 0.042 \mathcal{R}_{\text{var}} 0.682 \pm 0.063 0.611 \pm 0.074 0.530 \pm 0.081 \lambda=0.02 \mathcal{L}_{\text{rec}} [ 10^{-3} ] 0.087 \pm 0.030 0.113 \pm 0.040 0.118 \pm 0.045 \mathcal{R}_{\text{var}} 0.853 \pm 0.061 0.791 \pm 0.086 0.699 \pm 0.072 A sequential baseline (left column of Table 2 ), where the AE is trained first for reconstruction and the VAR model is fitted afterwards, achieves the best reconstruction but the poorest latent predictability, as the latent space is not optimal for the VAR task. Embedding the VAR model within the AE, using the VAR forecast \bm{\hat{z}}_{t} for reconstruction but without backpropagation through LARS (middle column of Table 2 ), significantly improves \mathcal{R}_{\text{var}} . As a result, \mathcal{L}_{\text{rec}} increases as the decoder reconstructs from the VAR forecast \bm{\hat{z}}_{t} rather than the original latent variable \bm{z}_{t} . This configuration shows that even implicitly guiding the AE via the VAR forecast helps shape a more predictable latent space. Our full proposed method (right column of Table 2 ), with end-to-end training via differentiable LARS , produces a further reduction in \mathcal{R}_{\text{var}} , achieving the best latent predictability overall. This key improvement, gained by allowing gradients to flow through the LARS computation, comes at the cost of a further small increase in \mathcal{L}_{\text{rec}} . These results are consistent across a wide range of penalty parameter \lambda values. While embedding the VAR model offers benefits over a sequential approach, the key step is enabling full end-to-end differentiation through the LARS algorithm. This allows the VAR objective to directly shape the latent space, leading to a better capture of the dynamics by the sparse linear model. 4 Discussion In this work, we presented an end-to-end trainable framework that integrates a convolutional autoencoder with an \ell_{1} -penalized VAR model, in which static components are addressed with a skip connection. Consequently, we combine the representational capabilities of artificial neural networks with the interpretability and theoretical grounding of sparse regression models. The proposed framework produces interpretable, dimension-reduced representations of neural dynamics in an exemplary two-photon calcium imaging dataset, where a differentiable LARS procedure enables optimal, sparse temporal latent spaces. The three key innovations, the aggregate skip connection for separating static from dynamic content, the differentiable LARS procedure, and the subsequent statistical testing approach, complement each other. The skip connection frees the latent space from static clutter, while differentiable LARS allows the encoder to directly optimize for predictable temporal dynamics. An ablation study confirmed that both components contribute to performance: Embedding the VAR model improves latent predictability over sequential training, and enabling gradient flow through LARS produces further gains. The statistical testing approach then allows to assess the validity of patterns found in the data. The sparsely estimated VAR coefficients are meaningful descriptors of dynamics, e.g. capturing significant differences between experimental conditions in the exemplary application, while remaining robust to within-condition variability. The proposed contribution map approach further indicate that end-to-end training produces sparser, more localized representations compared to non-differentiated approaches, thus improving interpretability. Despite these promising results, our approach has several limitations. The embedded LARS fitting introduces computational complexity. We did not explore alternative \ell_{1} -solvers, which do not allow for gradients in a straightforward manner. Also, the current architecture flattens the 2D latent maps before the VAR model, potentially discarding spatial relationships that space-aware statistical models could exploit ( 17 ) . While precise spatial relationships were less important in the exemplary application, as neurons may be connected via intermediate neurons that are not visible in the imaging plane, other applications might benefit from spatial information. For example, the VAR model could be adapted to only allow for connections up to a certain distance. Nevertheless, the present results already indicate that the differentiable LARS method may prove valuable beyond this specific application, as it provides a general mechanism for integrating sparse regression into deep learning pipelines while avoiding the gradient conflicts and scaling issues of multi-task loss formulations ( 35 ) . Future work could refine the skip connection with adaptive mechanisms ( 28 ) or reduce latent dimensionality via differentiable top-k selection ( 43 ) . More broadly, the successful differentiation of LARS encourages exploring similar approaches for other numerical procedures, potentially benefiting domains such as climate modeling ( 40 ) or video analysis. Surrogate gradients ( 6 ) may further improve gradient quality through non-differentiable solver components. More generally, our results show that differentiable programming techniques can bridge between artificial neural networks and sparse regression modeling for combining the benefits of both types of approaches.