Predicting natural behavior from whole-brain neural dynamics

We record calcium activity from the majority of head neurons in freely moving C. elegans to reveal where and how natural behavior is encoded in a compact brain. We find that a sparse subset of neurons distributed throughout the head encode locomotion. A linear combination of these neurons’ activity predicts the animal’s velocity and body curvature and is sufficient to infer its posture. This sparse linear model outperforms single neuron or PCA models at predicting behavior. Among neurons important for the prediction are well-known locomotory neurons, such as AVA, as well as neurons not traditionally associated with locomotion. We compare neural activity of the same animal during unrestrained movement and during immobilization and find large differences between brain-wide neural dynamics during real and fictive locomotion. One Sentence Summary C. elegans behavior is predicted from neural activity.


Main Text:
How do patterns of neural activity in the brain represent an animal's behavior? Much of what is known about the neural codes for animal behaviors such as head direction (1,2), spatial location 25 (3,4) or arm movements (5) comes from studying small regions of the brain. It is unclear to what extent neurons in other regions of the brain may also carry behavior related signals, or how those signals may be encoded. Recent reports of neural signals correlated with facial expression in sensory brain areas like the visual cortex (6) suggest that behavioral information may be prevalent throughout the brain and may account for a larger fraction of neural dynamics than 30 previously thought. Advances in calcium imaging now allow for brain-wide investigations of neural activity at single cell resolution in small transparent organisms such as zebrafish (7), worms (8) or hydra (9). Pioneering work in these systems has begun to investigate how brainwide patterns of neural activity correlate with behavior, primarily by measuring fictive locomotion from immobilized animals (7,10). Here we investigate brain-wide neural coding of 35 behavior in unrestrained and freely moving Caenorhabditis elegans. We find that the brain exhibits starkly different neural dynamics during immobilization compared to awake and unrestrained locomotion. We present a linear model or 'decoder' that predicts the animal's velocity and body curvature from the activity of a subset of neurons spatially distributed throughout its head. Amongst those neurons are many that have previously been identified in 40 coding for locomotory behavior, such as AVA, SMB and AIY, as well as additional neurons that have not traditionally been implicated in locomotion (ALA, AIM, RIS, RMG, and RIP). Finally, we use our decoder to predict the animal's full posture from neural activity. Our work provides a revised picture of how behavior is encoded in brain-wide neural dynamics in the C. elegans model system. 5 Previous investigations of whole-brain neural activity of behavior in C. elegans have used animals that were immobilized with a paralytic, tetramisole (10,11). We wondered the extent to which neural dynamics of paralyzed or immobilized animals resembled those of freely moving animals. We used a whole-brain imaging system for freely moving animals ((12); see also (13)) to compare neural dynamics of the same animal during movement and immobilization. We 10 recorded neural activity as an animal crawled freely in a microfluidic arena and then delivered a paralytic, part way through the same recording (Fig. 1A, additional trial in Fig. S1). Consistent with prior reports (10), neural dynamics during immobilization showed slow, antiphasic activity in two groups of neurons. In contrast, when the same animal was freely moving, the neural activity appeared to vary more rapidly and less coherently. 15 We recorded neural dynamics from 18 additional animals that were immobilized or freely moving for the entirety of the recording (including two that were reanalyzed from (14), Fig. S2, and Table S1). We calculated the autocorrelation of calcium activity for each condition, averaged across neurons (Fig. 1D). We found pronounced peaks in the correlogram of the immobilized recordings indicating slow ( s), periodic activity of many neurons during 20 immobilization. In contrast, such pronounced peaks were absent in the correlogram for activity during movement, indicating that during movement animals exhibited less periodic activity, especially on longer timescales. Here immobilized animals included those either paralyzed with tetramisole, or immobilized using nanobeads, both of which exhibited similar dynamics (see Supplementary Text and Fig. S3). We therefore concluded that neural dynamics during 25 immobilization fluctuate more slowly and are more periodic than during movement.
To investigate the structure and dimensionality of neural dynamics during behavior we used principal components analysis (PCA, Fig. 1C). PCA extracts a basis set, called the principal components (PCs). A truncated set of PCs can be used to represent neural activity in a lowerdimensional space while retaining the features accounting for the most variance. In agreement 30 with recent reports (10,15), we observed neural dynamics during immobilization that cycle repeatedly through a stereotyped trajectory in neural state space defined by the first three PCs (Fig. 1F, blue spiral-like trajectory). Interestingly, neural dynamics of the same animal during movement followed no such stereotyped structure (Fig. 1F, red hairball), suggesting a major difference between the neural dynamics of fictive and real movement. 35 We further wondered how well the observed neural dynamics were approximated by a low dimensional representation. The first three principal components explained 74% of the variance of neural activity for the immobile portion of our recording but only 59% for the moving portion (Fig. 1E). A statistical analysis of 18 recordings (moving and immobile) revealed that the number of significant principal components was larger for recordings during movement than 40 during immobilization (Fig. S4, Supplementary Text). Similar analysis of calcium-insensitive GFP control animals suggest that these differences cannot be trivially explained by motion artefact (Supplementary Text, Fig. S4). That neural dynamics of movement are less well approximated by a three-dimensional representation than those during immobilization further suggests that there are important differences between neural dynamics of movement and 45 immobilization. We therefore proceeded to study neural activity exclusively during unrestrained movement.
To explore how behavior is encoded in the brain, we simultaneously measured locomotion and posture, and whole-brain neural activity. We extracted the animal's velocity and its body curvature (a feature directly related to turning behavior) using a PCA-based posture analysis 5 (16). We imaged freely moving wild type (WT) animals on either an agar plate or in a microfluidic arena (Fig. 2). To control for potential imaging-induced behavior effects, we also imaged lite-1 mutants that lack the animal's endogenous blue-light aversive response (17). Consistent with prior reports (10-12, 18, 19), we observed that the activity of individual neurons was correlated with velocity or body curvature (Fig. S5). We therefore developed models to 10 predict such behavior from measured neural activity.
A previous report from immobilized animals suggests that neural activity projected along only the first three PCs should be sufficient to encode behavior (10). We therefore used linear regression to test how well linear combinations of projections of activity along the first three PCs predict a freely-moving animal's velocity and body curvature (PCA model, Fig. 2A-E, G). The 15 regression model was trained on part of the recording and tested on the remaining portion ( Fig.  2C). Surprisingly, this PCA model performed poorly at predicting velocity and body curvature (median R 2 of 0.13 and 0.01, respectively). For predicting velocity its performance was comparable to that of the best single neuron, and for predicting body curvature it was dramatically worse (Fig. 2G). Therefore, we conclude that for freely moving animals, the first 20 three orthogonal components of neural activity do not trivially encode behavior.
We wondered whether a differently weighted collection of neurons could better predict behavior. We used sparse linear regression to find the linear combination of neurons from each recording whose collective activity best predicted turning and body curvature. `Elastic net' regularization was used to impose sparsity while retaining neurons with redundant but relevant signals. (see 25 Fig. 2F, methods). We performed fitting and time-series cross-validation on part of the recording and tested the performance of the model on the remaining portion (Fig. 2C, methods). The sparse linear model (SLM) outperformed both the best single neuron and the PCA model at predicting velocity and body curvature, (median R 2 of 0.37 and 0.41, respectively). When applied to calcium insensitive GFP control animals, a similar SLM performed poorly, suggesting that the 30 model derives its predictive power from calcium signals and not motion artefacts (Fig. 2G).
Model performance was not restricted to a particular environment (plate or arena) or to a genetic background (WT or lite-1).
The SLM assigned non-zero weights to 19±5 and 15±2 neurons (mean ± s.e.m., across animals) for predicting velocity and body curvature, respectively, with little overlap, accounting for 35 roughly 20% of the measured neurons (Fig. 3A, B). Neurons selected by the SLM were spread spatially throughout the recording region, with the highest density located in the nerve ring ( Fig.  3C, D). Their location was roughly stereotyped across animals. We aligned neuron locations for each recording to a known cell atlas (20) and attempted to identify those neurons selected by the SLM by name. We were reassured to find many neurons that had previously been implicated in 40 locomotory behavior, including neuron classes AVA, SMB, and AIY (Fig. 3C, D and Tab. S2) (10,18,21,22). Intriguingly, we also found neurons not traditionally known as locomotory, including ALA and RIS which are quiescence-promoting (23, 24), AIM which is involved in foraging (25), RMG which is a multisensory integration hub (26) and RIP which is less well characterized (Fig. S6). 45 To infer the animal's posture from neural activity, we integrated information about the predicted behavioral variables-velocity and body curvature -over time. Given only neural activity and the animal's starting posture, we accurately predicted posture for up to 10 seconds, after which error accumulation caused the phase between the predicted and true postures to drift (Fig. 4A, B and Video S1). The SLM accurately predicts posture and posture dynamics during forward 5 locomotion. However, during turns (when body curvature amplitude is large), the predicted curvature of the animal's posture is slightly too low (Fig. 4B). We found that adding an empirically derived nonlinearity to the body curvature decoder provided more accurate posture predictions during turns ( Fig. 4C-F). This suggests that the nervous system may nonlinearly amplify curvature related neural signals, either in the brain or at the neuromuscular junction. 10 Taken together, we conclude that a linear model with minor non-linear corrections is sufficient to fully reconstruct the animal's behavior and posture from a sparse combination of neural activity.

Discussion:
Our results provide new insights into where and how behavior is coded in a simple brain. In C. elegans we find that a sparse subset of neurons spatially located throughout the head encode 15 behavior. A linear combination of activity from these neurons alone is sufficient to predict the animal's velocity and body curvature, and to further infer its posture. Among this subset of neurons are many that have long been associated with locomotion, like AVA, SMB, and AIY (10,18,21,22), as well as others that have not traditionally been implicated in locomotion, like RMG and RIP. Together, this suggests that neural coding of behavior is spread throughout the 20 brain and includes more neurons than previously thought.
What role might these neurons have in behavior? Some, like AVA, have been shown to modulate reversal frequency and generate high-level motor commands directly (19). Other neurons, however, are probably either reporting motor commands generated elsewhere as an efference copy (27), or are detecting locomotion independently as in proprioception (28). 25 Our results also demonstrate dramatic differences between neural dynamics of fictive and real locomotion that inform our picture of the brain. Previous studies from immobilized C. elegans had reported that the brain's neural dynamics are dominated by low dimensional representations of behavior contained in the first three PCs of neural activity (10). That result implies that motor outputs constitute a large fraction of the brain's neural dynamics. In contrast, 30 our measurements in freely moving animals indicate that the first three PCs are poor predictors of behavior. The neural coding of behavior we find in moving animals is linear and low dimensional, but it does not so dominate brain wide neural dynamics as to appear in the first few principal components.
If the first few PCs of brain wide activity are not coding for behavior, what might be their 35 role instead? In addition to generating behavior, the nervous system must also sense an animal's environment and maintain internal states. In mice, an internal arousal state (as measured by pupil diameter) accounts for the majority of the variance of membrane potential in an arbitrary brain region such as auditory cortex (29). We speculate that in C. elegans the first few PCs of neural activity may be involved in either sensory coding or maintaining internal brain states such as 40 arousal, both of which complement behavior and are critical for survival.   Table S2). 10

Strains
The  -1(ce314)). The presence of the lite-1 mutation was confirmed by sequencing. Strains were maintained on standard NGM media with E. coli OP50 as food source. Animals were imaged between young adult and day 1 adult stage. Whole brain imaging of freely behaving animals Whole brain imaging of freely moving animals was performed as described previously (1, 2). Briefly, animals were placed on an imaging plate (a modified NGM media lacking cholesterol and agarose replacing agar) and covered with mineral oil. A coverslip was placed on top of the plate with 100 um plastic spacers between the coverglass and plate surface. The coverslip was fixed to the agarose plate with valap. Animals were imaged on the whole brain imager (2), which simultaneously records four video streams to image the calcium activity of the brain of freely moving animals. We record a 10x magnification darkfield image of the body posture, a 10x fluorescence image of the fluorescent brain for tracking, and a 40x image each of tagRFP, and of GCaMP6s (or GFP). The 10x images are recorded at 50 frames/s, and the neural dynamics are recorded with 200 slices/s, with a resulting acquisition rate of 6 volumes/s.

Whole brain imaging animals immobilized via nanobeads
Animals were washed in M9 and picked onto 10% agarose pads with 1 ul of 0.1 um polystyrene beads for immobilization (3). A coverslip was placed on top of the agarose and sealed with valap. The animals were recorded and analyzed as described above.

Whole brain imaging of animals paralyzed via tetramisole
For transient immobilization experiments as in Fig 1, animals were immobilized with the paralytic tetramisole during recording. A single animal was loaded into a customized 'artificial dirt' microfluidic chip arena, inspired by (4), that enabled the animal to crawl freely in an aqueous environment while precise quantities of liquid were delivered to the arena. A computercontrolled automated liquid delivery system (OB1 and MUX, Elveflow, Paris, France) was used to flow in the buffer and paralytic into the arena. M9 buffer was flowed in for the 4 minutes after which the buffer was switched to 5 uM tetramisole in M9, paralyzing the animal. The buffer switching sequence was pre-programmed and automated using the software provided by Elveflow. The animals were recorded continuously on the whole brain imager. Recording was manually synced to the start of the buffer sequence.

Segmenting and measuring neural and behavior signals from whole brain recordings
The resulting videos of freely moving, immobilized or paralyzed animals were analyzed with the NeRVE Clustering pipeline (1). In brief, the movies are synchronized temporally using light flashes. The animals' posture is extracted using an active contour fit on the frames of the 10x behavior recordings. The fit finds 100 (x,y) coordinates for each frame of the behavior recording describing the centerline of the animal. This centerline is computationally mapped onto the high magnification recordings to straighten the point set of detected neuronal nuclei. The neural dynamics are extracted by segmenting the neuronal nuclei in the red channel and straightening the image according to the body posture. Using repeated clustering, neurons are assigned identities over time. The GCaMP signal is extracted using the neural positions over time that resulted from tracking. Occasionally, badly tracked neurons were removed postanalysis during human quality checks. The pipeline returns datasets containing RFP and GCaMP6s (or GFP) fluorescence values for each successfully tracked neuron over time, and the centerline coordinates describing the posture of the animal over time. These are subsequently processed to extract neural activity or behavior features.

Extracting neural activity using independent component analysis
To measure neural activity, we sought to extract changes in fluorescence due to calcium activity and reject artifacts due to animal motion or noise. We pursued a strategy of extracting signals unique to the calcium indicator GCaMP6s and rejecting background signals common to both GCaMP6s and the calcium insensitive fluorophore RFP. We performed independent component analysis (ICA) on the red RFP and green GCaMP6s channels for each neuron independently. ICA has previously been used in neuroscience contexts, for example to identify spikes in intracranial recordings (5) or to automatically define regions of interest from large-scale calcium recordings (6). Here we use ICA to separate calcium signals from motion artifact. For each neuron, the fluorescence intensity from the red FRFP and green FGCaMP channels are smoothed with a gaussian filter of width 1 s. We then separate signal from noise using the FastICA algorithm based on the implementation described in (7) as provided by the python scikit-learn package (8). ICA extracts two components, one of which relates to the neural activity signal and the other describes any background that is present in both channels, and thus likely noise. To identify which independent component corresponds to the signal, we pick the component that is most correlated with the green channel, FGCaMP. ICA is insensitive to the sign of the component, and it can converge to components that are inverted. We therefore assign the correct sign to the component by checking if the correlation with the green channel is positive or negative. We then normalize the ICA values by first subtracting the 20 th percentile (I0) and then also dividing by that value. In this work we therefore report calcium signals as Δ" Compared to a ratiometric approach (Δ./. $ , R= FGCaMP / FRFP) that we had used previously (2), we find that the ICA approach improves the quality of extracted signals, and slightly improves the resulting performance of our models. While a ratiometric approach removes much of the noise created by motion, it handles certain types of artefacts poorly and has the disadvantage that independent channel noise is amplified by forming a ratio between the two variables. The ICA approach ultimately performs better, as illustrated in simulations (Fig. S7).

Measuring and representing behavior
To measure the animal's velocity and body curvature we used a PCA-based 'eigenworm' postural analysis (9) , as follows. Centerlines of the worms were extracted from the whole-brain imaging recordings using an active contour fit to a brightfield image of the worm as in (1). The resulting centerlines were projected onto a 4-dimensional basis set of eigenworms (9). To create the eigenworms, centerlines from 135,958 frames of behaving worms imaged in the whole brain imager were extracted. The centerline coordinates were transformed into a set of relative angles between segments and the mean angle was subtracted from each centerline. PCA of the relative angles results in a set of eigenvectors that describe the postural variation of the centerlines. The first four eigenworms explain 96% of the observed variance in the centerlines.
The projection of the centerlines onto the eigenworms results in a timeseries of coefficients, one per eigenworm. Two of the eigenworms describe the body bends that the worm creates during its sinusoidal locomotion. The phase of the body bends is Θ(1) = tan67 8 (1)/7 9 (1):, where 7 8 , 7 9 are the coefficients for the first two eigenworms. The derivative of the phase Θ̇ is the phase velocity that describes the speed of bend propagation in the worm and is approximately the animal's center of mass velocity. Per our convention, Θ̇ is referred to as 'velocity' and a positive value of Θ̇ corresponds to the worm moving forward and a negative value of Θ̇ denotes a reversal. Velocity is obtained by filtering Θ with a gaussian derivative filter with width of 3 s. The third eigenworm coefficient 7 < (1) corresponds to the body curvature of the animal, which is related to turning. For example, when the animal makes a turn its velocity is positive, and its body curvature is large. The sign of 7 < (1) describes the bend direction. 7 < (1) is filtered with a gaussian filter of width 1 s.

Principal component analysis (PCA) of neural activity
PCA was performed on the mean-centered and standard deviation scaled data using packages present in the python module scikit-learn (8).
Predicting behavior from PC's of neural activity using linear regression For the PCA model in Fig 2, we use linear regression on the first three neural principal components (PCs) to predict either velocity or turns. The model is trained (i.e., weights are found for each PC) on 60% of the neural activity data. The performance of the model is estimated on the remaining 40% of the data by calculating the coefficient of determination between model prediction and behavior.

Predicting behavior from neural activity using elastic net regularized linear models
For the sparse linear model (SLM), behavior was predicted from neural traces using a linear model with elastic net regularization which applies both l 8 and l 9 weight penalties (10).
min @ ! ,@ {|y − β $ − Xβ| 9 9 } ; subject to (1 − α)|β| 8 + α|β| 9 9 ≤ t, where α = λ 9 λ 8 + λ 9 Here, T are the model inputs, in our case the neural activities, U is the model output, in our case the behavior. β $ and β denote the slope and offset of the linear model. The parameters V, W 8 , W 9 set the relative strengths of the l 8 and l 9 weight penalties. The X 8 penalty allows weights to converge to zero, thus resulting in a sparse model. The l 9 penalty makes the fit robust to collinear inputs, by weighing them equally. In neural decoding, elastic net performs better than a simple LASSO regularization, since many of the neural traces are highly correlated.
To fit the sparse linear model, we hold out 40% of the data as test data. We use the remaining data to fit and cross-validate the model. To set the hyperparameter λ 8 , we used 5-fold timeseries cross validation. For each fold, the training data is split such that the test data for cross validation is chronologically after the training data. This reduces information 'leakage' between test and training sets. We set the relative strength α of the X 8 and X 9 penalty at 0.95, favoring the l 8 term. After determining the optimal hyperparameter, we assess the prediction quality on the held-out test set (not used in cross-validation).

Assessing model performance in predicting behavior
The quality of the prediction of the PCA and the sparse linear models was assessed by calculating the coefficient of determination between the model and the test data, termed R 9 .
where SS ]^_ is the sum of squares of the residuals between model prediction and test data, and S`a ba is the sum of squares of the test data. The coefficient of determination can be negative, since the model was trained on unseen data. A model prediction could in principle be anticorrelated with the test data and yield large negative values.

Posture dynamics reconstruction
Our three parameter description of animal posture has a direct correspondence to the predicted velocity and curvature. Because of this we can directly reconstruct an approximation of the animal's full posture from these predicted variables. To compose the posture, each eigenworm is weighted by its coefficients 7 8 , 7 9 , a < and summed. The SLM directly predicts body curvature, which correspond to a < , but the undulatory coefficients need to be calculated from the predicted velocity.
We assume that the phase of the body undulations Θ(1) lies on a circle in the 7 8 -7 9 plane with radius r, which is a good approximation for moving worms (9). To reconstruct the coefficients of the eigenworms 7 8 , 7 9 , we can use the predicted velocity and the fact that the coefficients lie on a circle. By integrating the derivative of the phase angle Θ̇, which we called the velocity, we can obtain Θ(1). We calculate 7 8 , 7 9 using 7 8 9 + 7 9 9 = r 9 tan Θ = a 8 a 9 The reconstruction requires the input of an initial Θ(1) and the true radius c(t = 0). The following 10 seconds are predicted solely from the SLM using the measured neural activity. In Supplementary Movies S1 and S2, where longer predictions are shown, we repeatedly reset the animal's predicted posture every 10 seconds using the true Θ and c.

Estimating neural identities
To estimate the identities of our recorded neurons with respect to C. elegans known neuro anatomical atlas (11) we attempted to align and register our recordings. The dataset in Fig 2a  was chosen as a reference for all alignments. The 3D positions of the reference dataset were centered around (0,0,0). For each of the remaining datasets the neuronal positions were also centered and registered to the reference with a rigid point set registration followed by a non-rigid point set registration using the python implementation of the coherent point drift algorithm (12,13). Putative neuronal identities were established by projecting the neuronal positions into two dimensions (reducing the left-right axis) and aligning to a two-dimensional neuronal atlas (14). Neurons were assigned the ID of the closest atlas neuron. Neurons were ranked by how many times they were chosen in independent recordings and the 20 highest ranked candidates are shown in Table S2.

Nonlinear enhancement of turn amplitudes
We observed that body curvature predicted by the SLM were smaller in amplitude than the true body curvature. In the posture reconstruction this manifests as a shallow bend during turning, rather than the deep bends observed in experiments. We enhanced body curvature in Fig.  4 by applying an empirically derived non-linearity. The non-linearity was found by fitting all datasets with turn predicted = A erf6turn predicted /s: -m. To quantify the improvement in posture prediction provided by this non-linearity, calculate the root mean-square error of the predicted posture and the true posture.

Datasets
Calcium activity traces, animal posture, and other relevant datasets are publicly available at doi:10.17605/OSF.IO/MW5ZS.

Supplementary Text
Differences in moving and immobile neural dynamics cannot be explained by motion artefact Recordings of freely behaving animals have the potential to contain motion artefacts and spurious correlations with behavior that would not be present in immobile animals. To test whether the neural dynamics and behavioral encoding we observe can be attributed to motion artefact, we conducted control experiments with animals expressing a calcium insensitive GFP instead of the calcium indicator GCaMP6s. Recordings of GFP control animals contain all of the motion artefacts but none of the calcium signals present in recordings of the GCaMP animals. The following evidence suggests that the behavioral encoding and neural dynamics we observe cannot be explained by motion artefact.
While recordings of freely moving GFP animals did show artefactual fluctuations, those fluctuations did not correlate well with velocity or body curvature. Crucially, GFP control animals performed extremely poorly at predicting behavior, and had essentially no predictive ability (see Fig. 2). This indicates that our predictions of behavior arise from neural signals and not motion artefact.
We further analyzed multiple recordings of freely moving GFP and GCaMP animals using PCA. We compared the number of principal components with significant eigenvalues in the GFP and GCaMP recordings. We find that GFP recordings have a smaller number of significant components than GCaMP recordings (3 and 5, respectively), indicating that there are additional, neural activity-related signals present in the GCaMP recordings that are absent in the GFP recordings (Fig. S3).

Similarities of neural dynamics during immobilization of tetramisole and nanobeads
We employ two common immobilization techniques, microbeads and paralytic drug. The neural dynamics of both appear qualitatively similar in that both show the characteristic slow antiphasic activity (Fig. S3). Others have also observed similarities in the neural dynamics of immobilization using confinement (as in a microfluidic device, presumably similar to nanobeads) compared to using paralytic (15). For all these reasons we chose to treat tetramisole and microbead recordings interchangeably as "immobilized." Details of which recordings use which immobilization technique are included in Table S1.    Eigenvalue spectra from PCA of neural activity, averaged across multiple recordings, is shown. The vertical dashed line shows an estimate of the number of significant principal components (PCs) in the recording. Specifically, it denotes the number of PCs beyond which the eigenvalues of the neural activity (red) are no longer significantly greater than a time-lag-shuffle in which each neuron's activity is circularly permuted a random amount in time (blue; Welch's t-test, p<0.05). The time-lag shuffle destroys correlations between neurons but preserves temporal correlations within each neuron. For comparison, spectra are also shown for a random shuffle (black) in which each neuron's activity is separately shuffled in time so as to also destroy temporal correlations. Eigenvalue spectra are compared for (A) immobilized animals expressing the calcium indicator GCaMP6s (N=12), (B) moving animals expressing the calcium indicator GCaMP6s (N=6) and for (C) immobile animals expressing the calcium insensitive GFP control (N=3) (D) moving animals expressing the calcium insensitive GFP control (N=6). Of the four   Table S1. Summary of recordings Details of all recordings used in this paper are described below. Unique identifier can be used to locate the corresponding publicly accessible dataset at doi:10.17605/OSF.IO/MW5ZS. The two recordings indicated with "*" were previously reported in (16).  The video shows an animal's posture predicted from its neural activity using the PCA mode (right) alongside the animal's true posture (left) for comparison. The PCA model performs more poorly than the Sparse Linear Model shown in Movie S1. The gray track shows the predicted and true center of mass location of the animal, respectively. The predicted posture is initialized with the animal's true posture at the beginning of the recording and updated every 10 seconds with information from the animal's true posture so as to correct for accumulating errors. The timestamp flashes red to indicate each update.