Skip to content

Compare Neural Activity Across Epochs

Compute Credits

This tool uses 1.0 compute credits per hour.

Overview

The Compare Neural Activity Across Epochs tool calculates the average activity of the calcium traces, the pairwise correlation of the calcium traces, and if an event set is provided, the average event rate during any number of user-specified epochs. An epoch can be any length but must be a single continous period. Examples of this epochs may be "Baseline, Early, Late", or "Baseline, Drug, Post-drug". The tool will then generate figures displaying the average activity and event rate of each each cell in each epoch, the pairwise difference in activity and event rate between each epoch, the timecourse of average population activity and average population event rate, and the average positive and negative correlation separately in each epoch.

Parameters

Parameter Required? Default Description
Cell Set Files True N/A Cell set files
Event Set Files False N/A Event set files
Name of Epochs False Epoch 1, Epoch 2, Epoch 3 List of names of the epochs to analyze
Epoch Periods True (0, 10), (11, 20), (21, 30) Tuples of the start and end times (in seconds) for each epoch
Epoch Color Palette True tab:grey, tab:blue, tab:cyan A list of strings to assign a color to each epoch
Time Bin Size False N/A If specified, the data will be averaged into bins of this size (in seconds), effectively downsampling the data
Method to Rescale Trace Activity Data False none If specified, the trace activity data will be rescaled using the specified method
Method to Rescale Event Rate Data False none If specified, the event rate data will be rescaled using the specified method

Input Files

The inputs to this tool are cellsets and optionally a corresponding event file. The cellset file is a .isxd file that contains the neural activity data. The event file is a .isxd file that contains the timestamps of events that occurred during the recording.

Input parmeters

The tool requires you to specify epochs to analyze. The epochs are specified by the user in the form of a list of epoch names and periods.

Epoch names

Epoch names are specified as a list of names separated by commas. The names should be unique from each other.

Epoch Periods

The periods are specified as a list of tuples, where each tuple contains the start and end time of the period in seconds. The start time should be less than the end time. The periods should be unique from each other and should not overlap.

The periods need to be less than the total duration of the recording, though if the recording is a series, the periods can be longer than the duration of the individual recording.

Epoch Colors

The colors are specified as a list of colors separated by commas. The list of colors should be the same length as the list of epoch names. The colors should be in the form of a string that can be interpreted by matplotlib.

Time Bin

The time bin is an optional parameter that specifies a time bin in seconds to bin the calcium traces and event rates. If the time bin is not provided, the files will be processed at the original sampling rate.

Rescaling method

There are three options to rescale the calcium traces and event rates, which can be selected independently.

The options are as follows:

Option Description
None The calcium traces are not rescaled.
Normalize The calcium traces and event rates are normalized to have a minimum of 0 and a maximum of 1. This ensures that each cell contributes equal variance to the population mean.
Standardize The calcium traces and event rates are standardized to have a mean of 0 and a standard deviation of 1. This process removes differences in baseline activity and scale, comparing the relative variance between cells on a common scale.

Algorithm details

graph TD A[Run Compare Neural Activity Across Epochs] --> B[Re-scale the calcium traces]; B--> C[Create time course preview of calcium traces]; C --> D[Isolate activity during each epoch]; D --> E[Calculate population level differences of calcium traces between epochs]; E --> F[Calculate cell-cell correlation between each cell pair]; A --> G[If event file is provided:]; G --> H[Re-scale the event rates]; H --> I[Create time course preview of event rates]; I --> J[Isolate event rate during each epoch]; J --> K[Calculate population level differences of event rates between epochs];

The tool uses several metrics to measure and analyze population activity, described in the following sections:

Average measures

When the activity of a cell is measured, the mean of the rescaled value is used. When the average correlation is measured, a mean is taken of the positive elements of the correlation and the negative elements of the correlation separately.

Correlation

Pairwise correlation is calculated between each cell in the population. The correlation is calculated using the Pearson correlation coefficient, implemented using np.corrcoef() using default arguments.

Outputs

Trace time course

The tool will return a .npy file with the activity of each cell across time. If a time bin is provided, the time course will be binned into the specified time bin.

Trace preview

This preview will show the traces of the first 20 cells in the population, with the epoch periods highlighted in the background.

Single cell time course preview

This preview will show the time course of the activity of all cells across time as a heat map. The top panel will also show the average population activity level with the epochs highlighted. Below is an example of the time course preview on standardized data:

Population time course preview

This preview will show the average activity of the population of neurons across time on the left, with each epoch highlighted. The average population activity within each epoch is plotted as a bar plot on the right. Below is an example of the time course preview on standardized data:

Trace Activity Data

The tool will return a .csv file with individual cells as rows, and the columns will contain the average activity of each cell in each epoch. An example of the output file is shown below:

Epoch Cell Activity
Example1 0 0.0000
Example1 1 0.0050
Example1 2 0.0550
Example1 3 0.0150
Example1 4 0.0050

Epoch - Epoch differences preview

This preview shows the pairwise difference in activity for each combination of epochs as rows. The difference is taken as Later Epoch - Earlier Epoch. The left column will show a histogram of the differences, colored by relative change. The median is indicated by a dotted black line. The right column will show a cell map of the cells in the population, with the cells colored by magnitude of relative change. On the far right is a colorbar mapping the relative change. Below is an example of the differences preview on standardized data:

Calcium activity comparison

This preview will show a comparison of the average activity of the population of neurons in each epoch as a box and strip plot, with lines connecting the same cell in each epoch. The y-axis will show the average scaled trace activity in each epoch. Below is an example of the activity comparison on standardized data:

Trace correlation

The tool will return a .npy file with the raw correlation matrix (not clustered) of the population of neurons as a dictionary.

Clustered correlation preview

This preview will show the pairwise correlation matrix of each epoch, with similar cells clustered together. The correlation matrix will be colored by the correlation value, with a colorbar on the right.

Average correlation preview

This preview will show the average positive correlation and average negative correlation of the population of neurons in each epoch as a bar plot.

Event Rate time course

The tool will return a .npy file with the eventrate of each cell across time. If a time bin is provided, the time course will be binned into the specified time bin.

Single cell time course preview

This preview will show a rasterplot of all cells across time. The top panel will also show the average population event rate with the epochs highlighted. Below is an example of the time course preview on normalized data:

Population time course preview

This preview will show the average eventrate of the population of neurons across time on the left, with each epoch highlighted. The average eventrate activity within each epoch is plotted as a bar plot on the right. Below is an example of the time course preview on normalized data:

Event Rate Activity Data

If an event set is provided, the tool will return a .csv file with individual cells as rows, and the columns will contain the average event rate of each cell in each epoch. An example of the output file is shown below:

Epoch Cell Activity
Example1 0 0.0000
Example1 1 0.0050
Example1 2 0.0550
Example1 3 0.0150
Example1 4 0.0050

Epoch - Epoch differences preview

This preview shows the pairwise difference in event rate for each combination of epochs as rows. The difference is taken as Later Epoch - Earlier Epoch. The left column will show a histogram of the differences, colored by relative change. The median is indicated by a dotted black line. The right column will show a cell map of the cells in the population, with the cells colored by magnitude of relative change. On the far right is a colorbar mapping the relative change. Below is an example of the differences preview on standardized data:

Calcium activity comparison

This preview will show a comparison of the average evenrate of the population of neurons in each epoch as a box and strip plot, with lines connecting the same cell in each epoch. The y-axis will show the average scaled event rate in each epoch.

Next steps

After running this tool, the outputs of this tool can be used as inputs to the Combine and Compare Neural Activity Across Epochs tool to compare the activity of multiple recordings together.