This repo contains the code for generating figures in Lowet et al., Nature, 2025 [PDF]. In order to run, it is also necessary to download the data from Dryad, which should be placed in a directory alongside the code folder as follows (this repo is equivalent to the code folder):
├── parent_dir
│ ├── code
│ ├── ├── neural_analysis
│ ├── ├── behavior_analysis
│ ├── ├── ann_decoding
│ ├── ├── envs
│ ├── ├── ...
│ ├── data
│ ├── ├── neural-plots
│ ├── ├── behavior-plots
│ ├── ├── ann_decoding
│ ├── ├── behavior
│ ├── ├── ...
The necessary conda environment for running the code is available in envs/environment.yml. For glm_analysis, the tf.yml file environment should be used instead. To do so, ensure conda is installed and then execute the command conda env create -f environment.yml.
In order to match the plotting style used in the paper, it is necessary to copy the paper_export.mplstyle file (found in the utils folder) to your environment-specific matplotlib stylelib folder. On my computer, this is found in ~/anaconda3/envs/neural/lib/python3.8/site-packages/matplotlib/mpl-data/stylelib/, although yours may differ depending on your conda installation.
The code is formatted as Jupyter notebooks. There are ten such notebooks, each located within the relevant subfolder.
neural_analysis/recording_figs.ipynbplots neural recording data (mostly Figs. 2, 3, 4 and ED Figs. 2-4, 6-8, and 10d-e.behavior_analysis/compare_optostim.ipynbplots optogenetic stimulation data (Fig. 5 and ED Fig. 7a-m, 11).behavior_analysis/licking_all_sessions.ipynbplots licking data (Fig. 1c, ED Fig. 1f-g, 8b, 10c).behavior_analysis/behavioral_decoding.ipynbplots (Fig. 1d, ED Fig. 1h, 9b-c).neural_analysis/plot_smoothed_data.ipynbplots Fig. 1f-g., ED Fig. 2b, 10a-bneural_analysis/plot_sample_data.ipynbplots Fig. 1h, 4d,g.neural_analysis/glm_analysis.ipynbplots data from ED Fig. 5 and 9d-f.neural_analysis/compare_fano.ipynbplots Fano factor analysis (ED Fig. 6).ann_decoding/ann_decoding.ipynbplots data from ANN-based decoding (ED Fig. 4f-l).behavioral_analysis/plot_facemap_components.ipynbplots ED Fig. 1e.
They should all run after following the instructions above. If they don't, post an issue and I'll investigate!