This repository contains the code used in the paper "iCSD generates spurious signals for dense electrode arrays". Steps to reproduce the figures in that paper are as follows:
We assume that you are running this code on a Linux system with slurm and the spack package manager. BlueRecording has not been tested on any other system.
Download the model data from our Zenodo repository and extract it into the config
folder.
Install Neurodamus and BlueRecording according to the instructions in the BlueRecording repository. This repo assumes that your system meets the requirements described there.
This paper relies on the BlueRecording workflow described in this paper and this repo. Briefly, to simulate LFP and objective CSD, the BlueRecording workflow involves
- Simulating one timestep from the circuit model in question, in order to generate a compartment report
- Interpolating segment positions from the circuit model
- Creating a "weights file" which describes the contribution of the transmembrane current from each segment to the desired signal (either LFP or obejctive CSD, at each electrode)
- Running a full neural simulation, which reads the weights file and reports the desired signal
In order to reproduce Figure 1c-e, run the notebook Analytic.ipynb. The formulae implemented in this notebook (Eq. 5 and 6 in the paper) are derived using the Mathematica notebook csds.nb and limitCase.nb, respectively.
Note that you can skip many of the steps described in this section by downloading the postprocessed LFP data from our Zeonodo repository. Once that data is downloaded, you can skip directly to Step 2 in "Reproducing Figure 2", Step 3 in "Reproducing Figure 3" and to Step 7 in "Reproducing Figure 4".
In order to create electrode files to calculate the LFP signals from neural simulations, the positions of the neural segments in the model must be calculated:
- In the folder
electrodes
, runlaunch.sh
to generate a 1-timestep compartment report (i.e., an h5 file that lists each of the neural segments in the model. - In the same folder, run
GetPositions.sh
to interpolate the 3D positions of each of these neural segments
- Generate electrode arrays with 20
$\mu m$ spacing, to calculate LFP and$o_DCSD$ - a. In the folder
electrodes
, runWriteCSV_HighRes.sh
to generate the csv file that defines the electrode array. - b. Run
InitializeArray_HighRes.sh
to initialize the h5 file coeffs_highRes.h5 that is read by Neurodamus - c. Run
PopulateArray_HighRes.sh
to populate the h5 file created in the previous step.
- a. In the folder
- Note that the version of the coeffs_highRes.h5 file contained in the Zenodo repository only contains the coefficients for the LFP, and not for the
$o_DCSD$ .
- Run the Python script
makeDerivatives.py
. This script generates a weights file that lists the contributions to the "standard" CSD from a unit current at each neural segment, by taking the negative second derivative of the coefficients calculated for the LFP in the previous step. The resulting weights file is namedcsdCoeffs.h5
. - Run the Jupyter notebook
derivativeHistograms.py
to generate Figure 2.
-
Launch the simulations in the folder
highRes
by running the scriptlaunch.sh
in each of the subfolders. LFP and$o_DCSD$ signal contributions from each cell in the simulation will be calculated. -
Next, sum the LFP and
$o_DCSD$ signals over cells by running the scriptGeteeg.sh
in thehighRes
folder. -
Finally, run the notebook
csdCorrelations.ipynb
to generate Figure 3.
- Generate electrode arrays with 20
$\mu m$ spacing to calculate$o_DCSD$ with various radii$\rho$
- In the folder
electrodes
, runWriteCSV_Radii.sh
to generate the csv file that defines the electrode array. - Run
InitializeArray_Radii.sh
to initialize the h5 file coeffs_radii.h5 read by Neurodamus - Run
PopulateArray_Radii.sh
to populate the h5 file created in the previous step.
-
Then launch the simulations in the folder
radii
by running the scriptlaunch.sh
in each of the subfolders. -
Next, sum the
$o_DCSD$ signals over cells by running the scriptGeteeg.sh
in the folderradii
-
Run the notebook
derivatives.ipynb
to generate the weights file that calculated non-negative CSD (nnCSD). Briefly, this notebook takes the negative second derivative of the LFP weights calculated above, and zeros out the negative values. The resulting weights file is namedderivative.h5
. -
Launch the simulations in the folder
secondDeriv
by running the scriptlaunch.sh
in each of the subfolders; this will calculate the nnCSD. -
Next, sum the
$nnCSD$ signals over cells by running the scriptGeteeg.sh
in the foldersecondDeriv
-
Finally, run the notebook
csdCorrelations_radii.ipynb
to generate Figure 4.
If you use this software, we kindly ask you to cite the following paper: Tharayil et al. (2025) iCSD can produce spurious results in dense electrode arrays. bioRxiv
The development of this software was supported by funding to the Blue Brain Project, a research center of the École polytechnique fédérale de Lausanne (EPFL), from the Swiss government's ETH Board of the Swiss Federal Institutes of Technology.