isolating single cycles of oscillatory activity in neuronal spiking


Keywords
Neuroscience, Oscillation, Cycle
License
CC-BY-NC-SA-4.0
Install
pip install isoCycle==0.1.16

Documentation

isoCycle

preprint pip pip pip

A Deep Network-Based Decoder for Isolating Single Cycles of Neural Oscillations in Spiking Activity

Neural oscillations are prominent features of brain activity, observable as frequency-specific power changes in electroencephalograms (EEG) and local field potentials (LFP). They are also manifested as rhythmic coherence across the brain regions. Although the identification of oscillations has primarily relied on EEG and LFP, the intrinsic relation between neural oscillations and neuronal spiking is noteworthy. We investigate the potential to detect individual cycles of neural rhythms solely through the spiking activity of neurons, using recent advances in densely recording large populations of neurons within a local network. Numerous spikes from neurons within a local network estimate the network's activity over time, enabling us to identify cyclic patterns. Here, we employ recurrent neural networks to effectively isolate individual cycles of neural oscillations from the spiking of a densely recorded population of neurons. This isolation occurs in the temporal domain, where cycles from different time scales may combine in various ways to shape the network's spiking probability. We simulated the population spiking probability by synthesizing a signal using the known neural cycles as the basis functions. We also incorporated noise and variations in the width of each cycle instance to match the spectral profile of the recorded population spikings. We then used this synthesized signal to train a multi-layer Long Short Term Memory (LSTM) network for detecting the timing of the underlying cycles. We used this network to robustly isolate the cycles across different time scales in different brain regions of mice.

https://github.com/esiabri/isoCycle/blob/main/isoCycle/files/decoder_schematics.jpg

Extract the Cycle Times in Your Spiking Data on Google Colab

https://colab.research.google.com/assets/colab-badge.svg

On the Google Colab linked above, you can use isoCycle online to extract the times of the cycle you choose (e.g., gamma, theta, etc.) in your data. All you need is to have your recorded spike times (from all the nearby units combined) saved in a .npy file. If you're using kilosort/phy for spike sorting, you can use this matlab function to generate the .npy file for this google colab, otherwise this python function could be helpful to include spikes fron the desired units into the cycle detection.

The default figures in this Colab notebook show the average shape of gamma and beta cycles, as well as slower cycles, in the spiking activity of 131 neurons simultaneously recorded in the mouse primary visual cortex (V1) during a passive visual stimulation experiment. You can regenerate these figures using this data file. For the local machine version of this notebook see example.

GPU acceleration

isoCycle employs a decoder developed with TensorFlow. Leveraging a GPU highly reduces execution time, a factor particularly crucial for long recordings. However, configuring your GPU to work with TensorFlow requires additional steps post-package installation. For quick guidance, refer to Setting up TensorFlow with GPU Support.

Installation

quick: install isoCycle with pip, consider a new environment as conflicts are likely

pip install isoCycle

Steps for installation from scratch using Anaconda:

  1. First, ensure that you have Anaconda installed on your computer. If you don't have Anaconda, you can download it from the official Anaconda website. Anaconda is a popular distribution of Python that comes with many pre-installed packages and a package manager called conda, making it convenient for data analysis and scientific computing tasks.

  2. Once you have Anaconda installed, open a terminal or command prompt on your computer, and create a new conda environment by executing the following command:

conda create --name myenv

Replace myenv with the desired name for your environment.

  1. Activate the newly created environment with the following command:
conda activate myenv

Again, replace myenv with the name of your environment.

  1. Install isoCycle and its dependencies by running the command:
conda install isoCycle
  1. After the installation is complete, you can import isoCycle into your Python scripts or notebooks using the statement
import isoCycle

Now, with Anaconda installed, a new environment created, and isoCycle successfully installed, you are ready to analyze your data using isoCycle. One option is to use Jupyter Notebook. Here is an example Notebook: isoCycle_example.ipynb

Setting up TensorFlow with GPU Support

To utilize the power of GPU acceleration with TensorFlow, ensure that you have the correct hardware and software setup.

You will need a CUDA-capable GPU and you'll need to install the CUDA Toolkit and the cuDNN library. Once these are installed, you can install TensorFlow with built-in GPU support.

To check if TensorFlow is using the GPU, you can use the following Python code:

import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))

You can also log device placements with:

tf.debugging.set_log_device_placement(True)

For more detailed information, please refer to the following guides:

  1. Using a GPU with TensorFlow.
  2. CUDA Toolkit and cuDNN installation guides on the NVIDIA website. Please follow the respective instructions carefully when installing these components.