DOI: 10.5061/dryad.t1g1jwtbs
title: Data from: Adaptation to visual sparsity enhances responses to isolated stimuli

description: Sensory systems adapt their response properties to the statistics of their
 inputs. For instance, visual systems adapt to low-order statistics like
 mean and variance to encode stimuli efficiently or to facilitate specific
 downstream computations. However, it remains unclear how other statistical
 features affect sensory adaptation. Here, we explore how Drosophila’s
 visual motion circuits adapt to stimulus sparsity, a measure of the
 signal’s intermittency not captured by low-order statistics alone. Early
 visual neurons in both ON and OFF pathways alter their responses
 dramatically with stimulus sparsity, responding positively to both light
 and dark sparse stimuli but linearly to dense stimuli. These changes
 extend to downstream ON and OFF direction-selective neurons, which are
 activated by sparse stimuli of both polarities, but respond with opposite
 signs to light and dark regions of dense stimuli. Thus, sparse stimuli
 activate both ON and OFF pathways, recruiting a larger fraction of the
 circuit and potentially enhancing the salience of isolated stimuli.
 Overall, our results reveal visual response properties that increase the
 fraction of the circuit responding to sparse, isolated stimuli.
description: This dataset contains all experimental data necessary to create
 figures in Tong et al. (2024), as well as scripts to analyze them. The
 scripts are written in Matlab 2021b, and uses some functions from
 Statistics and Machine Learning Toolbox.
description: # Data from: Adaptation to visual sparsity enhances responses to isolated
 stimuli
 [https://doi.org/10.5061/dryad.t1g1jwtbs](https://doi.org/10.5061/dryad.t1g1jwtbs) ## Description of the data and file structure This repository contains the data and analysis scripts for the paper **"Adaptation to visual sparsity enhances responses to isolated stimuli."** * `sparsity_Dryad_upload.zip`: Complete dataset archive containing all data and scripts. Unzip it, and all the main analysis and plotting can be reproduced using the provided scripts and data. ### Folder structure * `scripts/`: MATLAB scripts for data analysis and figure generation * `data/`: `.mat` data files required by the scripts * `utilities/`: helper functions used by the analysis scripts ### `scripts/`: Each script reproduces the indicated figure panels from the paper (and supplements) by loading the appropriate data from `data/` * `fig1_naturalScene.m`: Fig 1A‑B, S1A‑D * `fig1_Mi1GC6f_flash.m`: Fig 1G‑N, S2F‑L * `fig2_contrastSweep.m`: Fig 2A‑E, S2A‑E, S4M‑N * `fig2_correlation.m`: Fig 2F, H‑I * `fig3_gray_ON.m`: Fig 3B * `fig3_optoGenetic.m`: Fig 3C‑H * `fig4_otherNeurons_flash.m`: Fig 4 & S4A‑L * `fig5_Mi1RFMapping.m`: Fig 5 & S5 * `fig6_otherNeurons_movingbar.m`: Fig 6 & S6A‑B * `figS6_Mi1_movingBarVelSweep.m`: Fig S6C * `fig7_T4T5_sparsitySweep.m`: Fig 7C‑H, S7 * `fig7_T4T5_singleMovingBarVelSweep.m`: Fig 7A‑B ### `data/` folder contains the following 5 folders and 8 `.mat` files which correspond one-to-one with the scripts, except that `figS2_Mi1GC7b_flash.mat` and `fig1_Mi1GC6f_flash.mat` are used by the same script `fig1_Mi1GC6f_flash.m` * `fig1_naturalScene/`: Selected natural images from the "Panoramic natural images dataset" (available at [[https://pub.uni-bielefeld.de/record/2689637](https://pub.uni-bielefeld.de/record/2689637)]), licensed under the Open Data Commons Attribution License (ODC-By) v1.0. These images are not included in this Dryad deposit. Users wishing to reproduce the analysis must obtain the original data directly from the source. The file names of the selected images are listed in `natural_imgs_selected.csv`; all the images are from the downloaded file `data_001-100.rar`. * `fig1_Mi1GC6f_flash.mat`: Imaging data from Mi1 &gt; GC6f flies presented with sparse flash stimuli (Figure 1). The file contains a struct array named `Mi1_sparseSweep_Analysis`. The `analysis` field is a cell array (usually 1×1, but sometimes multiple cells for different functionally identified cell types). Each cell is a struct with several fields. The key fields used to generate the figures are: * `Hz1All`, `Hz2All`, `Hz4All`, `Hz8All`, `Hz15All`, `Hz30All`: Matrices (`flies` × `time`) of temporal filters extracted from responses at different fill fractions (sparsity levels: 1/30, 2/30, 4/30, 8/30, 15/30, 30/30). Used to plot linear filters (Fig 1G) and calculate shape index (Fig 1H). * `Hz1LightImpulse`, `Hz2LightImpulse`, `Hz4LightImpulse`, `Hz8LightImpulse`, `Hz15LightImpulse`, `Hz30LightImpulse`: Matrices (`flies` × `time`) of light impulse responses to isolated light flashes presented in the context of each sparsity level. Used to plot light impulse responses (Fig 1I, 1K) and baseline shifts (Fig 1J). * `Hz1DarkImpulse`, `Hz2DarkImpulse`, `Hz4DarkImpulse`, `Hz8DarkImpulse`, `Hz15DarkImpulse`, `Hz30DarkImpulse`: Matrices (`flies` × `time`) of dark impulse responses to isolated dark flashes presented in the context of each sparsity level. Used to plot dark impulse responses (Fig 1L) and baseline shifts. * `indFilters`: Filters (`flies` × `time`) extracted from the whole response without considering sparsity conditions. Used for quality control to exclude flies with all-zero data (flies with no valid responses) before analysis. * `numFlies`: Scalar indicating the number of flies in the dataset. Used for display purposes in figure titles. * **Data dimensions**: Rows correspond to different flies, columns correspond to time points. The script multiplies filter values by 30 to convert from ΔF/F/contrast/frame to ΔF/F/contrast/second. * `fig2_contrastSweep/`: This folder contains 2 .mat files for contrast sweep experiments: * `Mi1_contrastSweep.mat`: Imaging data from Mi1 &gt; GC6f flies presented with flash stimuli at different contrast levels (Figure 2). The file contains a struct array named `contrastSweep_Analysis`. The `analysis` field is a cell array with the following key fields: * `kernels`: 3D matrix (`time` × `condition` × `flies`) of temporal filters. Conditions are interleaved [sparse-contrast1, dense-contrast1, sparse-contrast2, dense-contrast2, ...] for contrast levels [1.0, 0.8, 0.4, 0.2, 0.1]. Used to plot filters (Fig 2A-B), filter gain (Fig S2A-B), and shape index (Fig 2C). * `LightImpulseResps`: 3D matrix (`time` × `condition` × `flies`) of light impulse responses for each contrast/sparsity condition. Used to plot impulse responses (Fig 2D-E). * `DarkImpulseResps`: 3D matrix (`time` × `condition` × `flies`) of dark impulse responses for each contrast/sparsity condition. Used to plot impulse responses (Fig 2D-E). * `Tm1_contrastSweep.mat`: Similar structure for Tm1 &gt; GC6f flies (Figure S4M-N). * `fig2_Mi1GC6f_correlation.mat`: Imaging data from Mi1 &gt; GC6f flies presented with temporally correlated dense stimuli (Figure 2F, H-I). The file contains a struct array named `Mi1_correlation_Analysis`. The `analysis` field contains: * `kernels`: 3D matrix (`time` × `correlation_condition` × `flies`) of filters responding to dense stimuli with different temporal correlations. This is the only variable loaded from the .mat file and is used to plot the filters in Fig 2I. The script also generates stimulus autocorrelation plots (Fig 2F, 2H) from scratch. * `fig3_gray_ON/`: This folder contains 2 .mat files for optogenetic control experiments: * `fig3_gray_ON_Resps_control.mat`: Contains `gray_ON_Resps`, matrix (`time` × `flies`) of responses to a gray screen from control flies. * `fig3_gray_ON_Resps_chrimson.mat`: Contains `gray_ON_Resps`, matrix (`time` × `flies`) of responses to a gray screen from Chrimson-expressing flies. Used to compare baseline activity (Fig 3B). * `fig3_Mi1Chrimson_optoGenetic.mat`: Imaging data from Mi1 &gt; Chrimson flies with optogenetic activation (Figure 3C-H). The file contains a struct array named `Mi1_optoGenetic_Analysis`. The `analysis` field contains: * `kernels`: 3D matrix (`time` × `condition` × `flies`) of temporal filters. Conditions represent [sparse, dense, sparse+opto, dense+opto]. Used to plot filters (Fig 3D). * `LightImpulseResps`: 3D matrix (`time` × `condition` × `flies`) of light impulse responses with/without optogenetic activation. Used to plot light impulse responses (Fig 3E, G). * `DarkImpulseResps`: 3D matrix (`time` × `condition` × `flies`) of dark impulse responses with/without optogenetic activation. Used to plot dark impulse responses (Fig 3F, H). * `fig4_otherNeurons_flash/`: This folder contains multiple .mat files for different neuron and signal types responding to flash stimuli (Figure 4 & S4A-L). Each file has a similar structure with a `sparseSweep_Analysis` struct containing: * `Hz1All`, `Hz2All`, `Hz4All`, `Hz8All`, `Hz15All`, `Hz30All`: Matrices (`flies` × `time`) of temporal filters for different sparsity levels. Used to plot filters and normalized filter shapes (Fig 4, S4). * `Hz1LightImpulse` - `Hz30LightImpulse`: Matrices (`flies` × `time`) of light impulse responses. Used to plot light impulse responses (Fig 4). * `Hz1DarkImpulse` - `Hz30DarkImpulse`: Matrices (`flies` × `time`) of dark impulse responses. Used to plot dark impulse responses (Fig 4). * `indFilters`: Filters (`flies` × `time`) for quality control to exclude flies with all-zero data. * Files include: `Mi1ArcLD_flash.mat`, `L1GC6f_flash.mat`, `Mi1GACh3_flash.mat`, `Tm3GC6f_flash.mat`, `Tm1GC6f_flash.mat`, `Tm2GC6f_flash.mat`, `L3GC6f_flash.mat`, `L5GC6f_flash.mat`, `Mi1iGluSnFR_flash.mat`. * `fig5_Mi1GC6f_RF.mat`: Imaging data from Mi1 &gt; GC6f flies for receptive field mapping (Figure 5 & S5). The file contains a struct array named `sparseSweep_Analysis`. The `analysis` field contains: * `spatialTemporal_kernels`: 4D matrix (`time` × `space` × `condition` × `flies`) of spatio-temporal receptive fields. Conditions are sparse, dense, and dense-correlated (dense-correlated data are not shown in the paper). Used to plot STRFs (Fig 5B), temporal traces (Fig 5C), and quantify RF changes (Fig 5D). * `spatialTemporal_LightImpulseResps`: 4D matrix (`time` × `space` × `condition` × `flies`) of responses to light bars flashed at different locations. Used to plot light impulse-triggered RFs (Fig S5A-D, top). * `spatialTemporal_DarkImpulseResps`: 4D matrix (`time` × `space` × `condition` × `flies`) of responses to dark bars flashed at different locations. Used to plot dark impulse-triggered RFs (Fig S5A-D, bottom). * `fig6_otherNeurons_movingBar/`: This folder contains multiple .mat files for different neuron types responding to moving bars (Figure 6 & S6A-B). Each file has a `sparseSweep_Analysis` struct containing: * `kernels`: 3D matrix (`time` × `condition` × `flies`) of temporal filters. Conditions are different sparsity levels (1/12, 2/12, 4/12, 6/12, 8/12, 12/12). Used to plot filters (Fig 6C-F, S6A). * `LightImpulseResps`: 3D matrix (`time` × `condition` × `flies`) of responses to isolated moving light bars. Used to plot light impulse responses (Fig 6C-F). * `DarkImpulseResps`: 3D matrix (`time` × `condition` × `flies`) of responses to isolated moving dark bars. Used to plot dark impulse responses (Fig 6C-F). * Files include: `Mi1GC6f_movingbar.mat`, `Tm3GC6f_movingbar.mat`, `Tm1GC6f_movingbar.mat`, `Tm2GC6f_movingbar.mat`. * `figS6_Mi1GC6f_movingBarVelSweep.mat`: Imaging data from Mi1 &gt; GC6f flies for moving bar velocity sweep (Figure S6C). The file contains a `sparseSweep_Analysis` struct with: * `kernels`: 3D matrix (`time` × `condition` × `flies`) of temporal filters. Conditions are different velocities (30, 60, 120, 240 deg/s) for both sparse and dense stimuli. Used to plot filters at different velocities (Fig S6C). * `fig7_T4T5GC6f_singleMovingBarVelSweep.mat`: Imaging data from T4/T5 &gt; GC6f flies for single moving bar velocity sweep (Figure 7A-B). The file contains a `sparseSweep_Analysis` struct with multiple analysis cells for different T4/T5 subtypes: * `LightImpulseResps`: 3D matrix (`time` × `condition` × `flies`) of responses to single bars moving at different velocities. Used to plot velocity tuning curves (Fig 7B) and raw traces (Fig 7A). * `DarkImpulseResps`: 3D matrix (`time` × `condition` × `flies`) of responses to single bars moving at different velocities. Used to plot velocity tuning curves (Fig 7B). * `fliesIDAfterCombine`: Vector of fly IDs used to combine data from different T4/T5 subtypes. * `fig7_T4T5GC6f_sparsitySweep.mat`: Imaging data from T4/T5 &gt; GC6f flies for moving bar sparsity sweep (Figure 7C-H, S7). The file contains a `sparseSweep_Analysis` struct with multiple analysis cells for different T4/T5 subtypes: * `kernels`: 3D matrix (`time` × `condition` × `flies`) of temporal filters for different sparsity levels (1/12, 2/12, 4/12, 6/12, 8/12, 12/12). Used to plot filters (Fig 7C-F, S7). * `LightImpulseResps`: 3D matrix (`time` × `condition` × `flies`) of responses to moving light bars. Used to plot light impulse responses (Fig 7C-F, S7). * `DarkImpulseResps`: 3D matrix (`time` × `condition` × `flies`) of responses to moving dark bars. Used to plot dark impulse responses (Fig 7C-F, S7). * `fliesIDAfterCombine`: Vector of fly IDs used to combine data from different T4/T5 subtypes into PD/ND responses. ## Code / software Written for **MATLAB R2019b** and the Statistics & Machine Learning Toolbox. Verified on R2019b and later. ## Access information Other publicly accessible locations of the data: * Dandi: [https://dandiarchive.org/dandiset/001205](https://dandiarchive.org/dandiset/001205)