navis.connectivity_sparseness¶
- navis.connectivity_sparseness(x, which='LTS')[source]¶
Calculate sparseness.
Sparseness comes in three flavors:
Lifetime kurtosis (LTK) quantifies the widths of tuning curves (according to Muench & Galizia, 2016):
where is the number of observations, the value of observation , and and the mean and the standard deviation of the observations’ values, respectively. LTK is assuming a normal, or at least symmetric distribution.
Lifetime sparseness (LTS) quantifies selectivity (Bhandawat et al., 2007):
where is the number of observations, and is the value of an observation.
Activity ratio describes distributions with heavy tails (Rolls and Tovee, 1995).
Notes
NaN
values will be ignored. You can use that to e.g. ignore zero values in a large connectivity matrix by changing these values toNaN
before passing it tonavis.sparseness
.- Parameters:
x (DataFrame | array-like) – (N, M) dataset with N (rows) observations for M (columns) neurons. One-dimensional data will be converted to two dimensions (N rows, 1 column).
which ("LTS" | "LTK" | "activity_ratio") – Determines whether lifetime sparseness (LTS) or lifetime kurtosis (LTK) is returned.
- Returns:
pandas.Series
if input was pandas DataFrame, elsenumpy.array
.- Return type:
sparseness
Examples
Calculate sparseness of olfactory inputs to group of neurons:
>>> import navis >>> import numpy as np >>> import matplotlib.pyplot as plt >>> # Get ORN response matrix from DoOR database >>> url = 'https://raw.githubusercontent.com/ropensci/DoOR.data/master/data/door_response_matrix.csv' >>> adj = pd.read_csv(url, delimiter=';') >>> # Calculate lifetime sparseness >>> S = navis.connectivity_sparseness(adj, which='LTS') >>> # Plot distribution >>> ax = S.plot.hist(bins=np.arange(0, 1, .1)) >>> _ = ax.set_xlabel('LTS') >>> plt.show()