a, Summary of average relative contributions of the different behavioural variables for neurons belonging to each cluster as calculated by the no-refitting approach (see Methods). Left, average relative contributions of cue period behavioural variables to neural activity for each cluster. Right, average relative contribution of reward for each cluster. b, As in a, but for the clustering analysis performed on the contributions calculated using the refitting approach (see Methods). c, Normalized confusion matrix for the cluster identities of each neuron, obtained by comparing the clustering of the relative contributions based on either the no-refitting or the refitting approach (see Methods for description of two approaches). The main diagonal represents neurons for which the cluster identities matched (97.8%). d, Average relative contributions of clusters obtained by separately analysing two random halves of the trials for each neuron. Correlations between the average relative contributions in each cluster across the two sets are as follows (n = 5 in all cases). Position: ρ = 0.99, P < 8 × 10−5. Cues: ρ = 0.99, P < 4 × 10−4. Kinematics: ρ = 0.99, P < 2 × 10−4. Accuracy: ρ = 0.99, P < 3 × 10−4. Previous reward: ρ = 0.99, P < 0.001. Reward response: ρ = 0.48, P < 0.42. e, Normalized confusion matrix for the cluster identities of each neuron, obtained by clustering the two random halves of the data. The main diagonal represents neurons for which the cluster identities matched (79.1%). Note that the chance level of matching is 20%. The matrix was calculated for neurons for which a cluster was assigned in the procedures for both halves of the data (>75% probability to belong to a cluster, n = 91). f, Average absolute value of the correlations for all pairs of predictors across all behavioural variables during the cue period (average across all predictor pairs and mice). g, Average relative contributions assessed separately using three different approaches: no refitting (NR; used in the paper); no refitting + Lasso regularization (NR + L); and refitting (R). Correlations between the results of the different approaches are as follows: ρ(NR, NR + L) = 1, P < 7 × 10−9. ρ(NR, R) = 0.99, P < 1 × 10−4. ρ(NR + L, R) = 0.99, P < 8 × 10−5 (n = 6 in all cases). When omitting the reward response contributions: ρ(NR, NR + L) = 1, P < 2 × 10−5. ρ(NR, R) = 0.91, P < 0.04. ρ(NR + L, R) = 0.92, P < 0.03 (n = 5 in all cases). Lasso regularization was applied using the lasso function in MATLAB; the mean square error (MSE) of the model was estimated using fivefold cross-validation, and we chose the lambda value that minimized the MSE. The results with lasso regularization were almost identical to the result without regularization, which suggests that there was not significant overfitting in our model. h, Average relative contributions assessed separately using two random halves of the data. For each neuron, we randomly divided all the trials in which the neuron was recorded into two separate subsets while matching the number of rewarded and previously rewarded trials between the subsets. Each subset of trials was then used to calculate the relative contributions of the behavioural variables (ρ = 0.99, P < 3 × 10−4 for all behavioural variables (n = 6), ρ = 0.8, P < 0.11 when omitting the reward response contributions (n = 5)). i, We tested the robustness of the clustering results by performing an alternative clustering procedure based on the predicted neuronal traces. After determining the regression weights for all neurons, behavioural predictors from one session were used to generate predicted activity traces for all neurons. A similarity matrix was constructed by taking the absolute correlation between the predicted traces for each neuronal pair. The similarity matrix was clustered using information-based clustering20 (see Methods) and ordered by the obtained clusters (right panel; cluster identity for each neuron depicted by a coloured stripe to the right). j, Normalized confusion matrix for the cluster identities of each neuron, comparing clustering of the relative contributions (method used in the main text; Fig. 3) and the alternative method described here. The two clustering methods involve conceptual differences that may result in different clustering organizations. For example, the method used in Fig. 3, which clusters the relative contributions of the behavioural variables, is independent of a particular tuning for these variables, whereas the method presented here should be affected by such tuning (for example, upward versus downward position ramps). Nevertheless, we find a similar overall clustering structure between the two methods, with the main differences as follows. Original clusters 3 and 5 (associated with previous reward and accuracy) are joined in a single cluster (new cluster 5); and original cluster 1 (associated with kinematics) is now split into two clusters (new clusters 1 and 3). Further investigation of the split of the kinematics cluster showed that the neurons that split from the main kinematics cluster have stronger modulation for the view angle component of kinematics (based on the regression coefficient values). Such a split could not occur in the formulation used in the main text, which combined all the kinematics components (speed, acceleration and view angle). k, Further validation of the encoding model by simulating data with known relative contributions of the different behavioural variables. We replaced the activity of each neuron by a simulated trace that was computed using known relative contributions of the different behavioural variables as follows: first, the predictors corresponding to each behavioural variable were summed, resulting in one predictor per variable. Each predictor was z-scored and multiplied by a different relative contribution (taken from the values obtained for the real data). The scaled predictors were then summed, resulting in a single vector that forms the basis of the firing rate of the simulated neuron. To this vector, we added a constant to obtain an average firing rate close to 5 Hz (which was observed in in vivo electrophysiological recordings22). After zeroing negative values of this firing rate vector, we used it to generate a spike train using a Poisson process. Finally, the spike train was convolved with an approximate GCaMP kernel (see Methods). We proceeded to estimate the relative contributions for the simulated trace using the encoding model procedure. The relative contributions used to simulate the traces (x axis) and the recovered contributions (y axis) for a given behavioural variable are shown; the correlation between the original and recovered relative contributions and its associated P value are denoted (n = 233 in all cases).