This repository contains the Matlab code used to analyze the data and generate the figures in Ecker et al., State dependence of noise correlations in macaque primary visual cortex, Neuron (2014).
We analyzed the data using a data management framework called DataJoint, which uses a relational database (MySQL) to store data and analysis results.
Our primary intention was to publish the actual code that we used to analyze the data and create the figures, to provide full transparency and to enable readers to read it and find out the exact details of what was done. The section "understanding the code" below gives some pointers to navigate it.
Running the code yourself to reproduce the figures or build upon it is a bit more involved. In addition to a couple of external libraries, you will need a MySQL server and download the database dump (8.5 GB). The installation is described at the end of this document. If you go this route, please make sure to read the remarks on the license (next section).
The code in this repository by A. Ecker is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
Note that the dataset associated with the paper is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. This means you are free to use the data to reproduce and validate our results. However, if you want to use our data in your own research and publish a new analysis, we kindly ask you to get in touch with us before doing so. We imposed the no derivatives clause for two (hopefully understandable) reasons:
-
To avoid misunderstandings and/or misinterpretations of the data we would like to know about results by other people before they are published.
-
In case we are working on a similar project, we would like to avoid getting scooped with our own data.
We used a data management framework called DataJoint to organize data and code. Under DataJoint the results of any analysis are stored in a relational database. Each result is stored along with the parameters that were used to obtain it. In addition, dependencies between subsequent analysis steps are kept track of and are enforced automatically. This process tremendously simplifies staying on top of complex analysis toolchains, such as the one for the current project. Details can be found in the DataJoint documentation.
In DataJoint, every analysis consists of one or multiple database tables, each of which is associated with its own Matlab class. Such a group of tables is populated automatically via a specific class method called makeTuples(). This method is where the actual work is done.
Below we provide an overview of the analysis tables used for the current project. In addition, the functions that create the figures are a good entry point to find out which classes/tables are relevant for a certain figure. These functions are located in the folder 'figures'. You will notice that those functions don't do much other than getting data/results from the database [fetch(...)], plot it and sometimes do some statistics on it.
In addition to the classes defined in this repository, we use a number of general purpose libraries for the basic organization of our experimental data and tasks such as spike detection and sorting. These libraries can be found on Github as well:
- https://github.com/atlab/sessions -- meta data stored by acquisition system and processing toolchain (database schemas acq, detect, sort)
- https://github.com/atlab/spikedetection -- spike detection
- https://github.com/aecker/moksm -- spike sorting
- https://github.com/aecker/gpfa -- Gaussian Process Factor Analysis (GPFA)
Spike detection is done by a separate library. See https://github.com/atlab/spikedetection
The function detectSpikesTetrodesV2.m
is used.
Parameter settings etc. are defined in sessions/sort.KalmanAutomatic
. The actual spike sorting is done by a separate library. See https://github.com/aecker/moksm for more information.
Basic single unit statistics such as firing rates, variances, rate stability etc. are computed in the class nc.UnitStats
. Quantities related to tuning properties such as orientation and direction tuning, their significance and visual responsiveness are computed in the class nc.OriTuning
. For statistics of pairs of neurons, see next section (Noise Correlations).
Pairwise analyses such as computing signal and noise correlations, but also more basic properties such as geometric mean firing rate, distance between electrodes, maximum contamination or rate instability, are computed in the class nc.NoiseCorrelationSet
.
Fitting the GPFA model is performed in the classses nc.GpfaModelSet
(for evoked responses) and nc.GpfaSpontSet
(for spontaneous responses). More precisely, these classes deal with preparing the data, i.e. partitioning for cross-validation, pre-transforming etc. The actual work (model fitting and evaluation) is done by a separate library. See https://github.com/aecker/gpfa for details.
Computing variance explained and residual correlations is performed by the class nc.GpfaResidCorrSet
. Again here, the actual work is done by the GPFA library.
The Generalized Linear Model using the local field potention (LFP) as input to predict correlated variability is fit by the class nc.LfpGlmSet
.
Power spectrograms of the LFP are computed in the class nc.LfpSpectrogram
. The correlation between LFP power ratio and overall correlation is performed by the classes nc.LfpPowerRatioGpfaSet
and nc.NetworkStateVar
.
All sessions and cells that were included in the analysis are listed in the tables nc.AnalysisStims
and nc.AnalysisUnits
. The populate relation (property popRel
) of those classes defines the restrictions that are applied.
Each Matlab package (+xyz) maps to a database schema and each Matlab class to a database table.
This schema contains the metadata entered into the database by the recording software during data collection. The following tables are most relevant:
Subjects
: list of monkeysSessions
: experimental sessions (can contain multiple recordings and stimuli)Ephys
: electrophysiological recordingStimulation
: visual stimulus presentationEphysStimuliationLink
: links simultaneous ephys recordings and stimulus presentations
Implements the spike detection part of the processing toolchain. This is highly customized code to be run on specific, optimized computers. The actual spike detection is done by an external library.
Implements the spike sorting toolchain. The sort.Kalman*
classes are the ones used for the Mixture of Kalman filter model we use (Calabrese & Paninski 2011). The actual model fitting is done by an external library.
The schema contains general purpose electrophysiology tables. Only ephys.Spikes
is relevant here; it contains the spike times for each single unit.
This schema contains my (AE) general purpose electrophysiology tables. The following tables are most relevant:
SpikesByTrial
: spike times relative to stimulus onset for each trialSpikeCounts
: spike count in a certain window (seeSpikeCountParams
) for each cell and each trialLfp
: bandpass-filtered LFP trace (seeLfpParams
for parameters)LfpByTrial
: LFP snippet for each trial aligned to stimulus onset
This schema contains the concrete analyses done in the paper. The specific tables are listed in the previous sections for each analysis. In addition, the following tables may be of interest:
Gratings
,GratingConditions
: contain the grating parameters for the different stimulus conditionsAnesthesia
: lists monkeys used for awake vs. anesthetized recordingsCrossCorrSet
: computes the cross-correlograms (Supplemental Information, Fig. S3)UnitPairs
,UnitPairMembership
: contains all pairs of units
-
Download and install the MySQL Community Server
-
Insert database dump.
- Download the database dump
- Insert the dump file into the database (replace
<HOST>
and<USER>
by the database host and username, respectively):mysql -h <HOST> -u <USER> -p < ecker2014.sql
-
Download the following repositories, depending on what you intend to do. All repositories should reside in the same base folder as this repository.
- https://github.com/aecker/ecker2014 -- [required] main analysis code (this repo)
- https://github.com/datajoint/datajoint-matlab -- [required] DataJoint
- https://github.com/datajoint/mym -- [required] Matlab/MySQL interface
- https://github.com/atlab/sessions -- [required] meta data stored by acquisition system and processing (spike detection and sorting) toolchain
- https://github.com/aecker/gpfa -- [required] Gaussian Process Factor Analysis (GPFA) implementation
- https://github.com/atlab/spikedetection -- spike detection
- https://github.com/aecker/moksm -- spike sorting
-
Set Matlab path
- In Matlab, run
ecker2014/startup
to set the path etc. - You may have to compile mym, the Matlab-MySQL database connector utility. Refer to the readme of the mym repository for details.
- In Matlab, run