This repository contains code to simulate and analyze the model and data related to thresholded Gaussian process model, which is a model of place maps observed in CA1 region of mammalian hippocampus. The model works across commonalities (1, 2, and 3 dimensional place maps), across spatialscale, and across species (bats and rodents).
You can find the paper here: Universal statistics of hippocampal place fields across species and dimensionalities
import numpy as np
from gp_model import GaussField, PlaceField1D, PlaceFieldModel1D, PlaceFieldComparisonWe will simulate a dummy data by sampling and thresholding a Gaussian Process to show how to the use of the code. Replace example_psth with your neural recording.
num_cells = 500 # Number of neurons to simulate
length = 200 # Size of the environment after binning
res = 0.2 # Resolution of sptial bins
sigma = 2.5 # Correlation length of the neural activity
theta = 1 # Threshold value
example_psth = np.maximum(
GaussField(num_cells, int(length / res), sigma=sigma / res) - theta, 0
)
print(" => Shape (N, P) = ", example_psth.shape)=> Shape (N, P) = (500, 1000)
Set the environment size and load data to PlaceField1D. Normalized threshold of the data will be automatically inferred and you can supply predicted correlation length to PlaceFieldModel1D.
# Length of the 1D environment in meters
L = 200
data_1D = PlaceField1D(example_psth, L, filtering=0)
#Filtering treshold rectifies the recording to remove small baseline-noise. We use 'filtering=0.5'.
# Predicted correlation length for data
sigma_model = 2.5
model_1D= PlaceFieldModel1D(data_1D, sigma_model, multiple=3)
print(f" => Inferred theta {model_1D.theta:.2f}")=> Inferred theta 0.99
Once the model is generated and we can use the PlaceFieldCommparison class to easily compare the data and model. Refer to the documentation in the code for more comparison features
comparison = PlaceFieldComparison(data_1D, model_1D)
comparison.analyze()
field_length_data, field_length_model = comparison('widths') # returns arrays of widths of all place fields across all cells in model and data
field_gaps_data, field_gaps_model = comparison('gaps') # returns arrays of gaps of all place fields across all cells in model and data
print(" => Data mean field size = {:.2f}, Model mean field size = {:.2f}".format(*comparison('widths').mean())) # compares mean length directly=> Data mean field size = 5.55, Model mean field size = 5.64
You can generate the mean Euler characteristic of the neural data as follows and to compare it with the model, you need to normalize the neural PSTH by data_1D.scaling.
data_1D.analyze_euler_characteristic() # Empirical euler characterstic of the data -- for the model we known the Euler characterstic analytically
data_1D.scaling = (lambda x, y: x / y)(*comparison('max_firing_rates').mean())from gp_model import PlaceField3D, PlaceFieldModel3D, PlaceFieldComparison3D