pynapple.process.tuning_curves#

Functions to compute tuning curves for features in 1 dimension or 2 dimension.

Functions

compute_1d_mutual_info(tc, feature[, ep, ...])

Mutual information of a tuning curve computed from a 1-d feature.

compute_1d_tuning_curves(group, feature, nb_bins)

Computes 1-dimensional tuning curves relative to a 1d feature.

compute_1d_tuning_curves_continuous(...[, ...])

Computes 1-dimensional tuning curves relative to a feature with continuous data.

compute_2d_mutual_info(dict_tc, features[, ...])

Mutual information of a tuning curve computed from 2-d features.

compute_2d_tuning_curves(group, features, ...)

Computes 2-dimensional tuning curves relative to a 2d features

compute_2d_tuning_curves_continuous(...[, ...])

Computes 2-dimensional tuning curves relative to a 2d feature with continuous data.

compute_discrete_tuning_curves(group, dict_ep)

Compute discrete tuning curves of a TsGroup using a dictionary of epochs.

pynapple.process.tuning_curves.compute_1d_mutual_info(tc, feature, ep=None, minmax=None, bitssec=False)[source]#

Mutual information of a tuning curve computed from a 1-d feature.

See:

Skaggs, W. E., McNaughton, B. L., & Gothard, K. M. (1993). An information-theoretic approach to deciphering the hippocampal code. In Advances in neural information processing systems (pp. 1030-1037).

Parameters:
  • tc (pandas.DataFrame or numpy.ndarray) – Tuning curves in columns

  • feature (Tsd (or TsdFrame with 1 column only)) – The 1-dimensional target feature (e.g. head-direction)

  • ep (IntervalSet, optional) – The epoch over which the tuning curves were computed If None, the epoch is the time support of the feature.

  • minmax (tuple or list, optional) – The min and max boundaries of the tuning curves. If None, the boundaries are inferred from the target feature

  • bitssec (bool, optional) – By default, the function return bits per spikes. Set to true for bits per seconds

Returns:

Spatial Information (default is bits/spikes)

Return type:

pandas.DataFrame

pynapple.process.tuning_curves.compute_1d_tuning_curves(group, feature, nb_bins, ep=None, minmax=None)[source]#

Computes 1-dimensional tuning curves relative to a 1d feature.

Parameters:
  • group (TsGroup) – The group of Ts/Tsd for which the tuning curves will be computed

  • feature (Tsd (or TsdFrame with 1 column only)) – The 1-dimensional target feature (e.g. head-direction)

  • nb_bins (int) – Number of bins in the tuning curve

  • ep (IntervalSet, optional) – The epoch on which tuning curves are computed. If None, the epoch is the time support of the feature.

  • minmax (tuple or list, optional) – The min and max boundaries of the tuning curves. If None, the boundaries are inferred from the target feature

Returns:

DataFrame to hold the tuning curves

Return type:

pandas.DataFrame

Raises:

RuntimeError – If group is not a TsGroup object.

pynapple.process.tuning_curves.compute_1d_tuning_curves_continuous(tsdframe, feature, nb_bins, ep=None, minmax=None)[source]#

Computes 1-dimensional tuning curves relative to a feature with continuous data.

Parameters:
  • tsdframe (Tsd or TsdFrame) – Input data (e.g. continuous calcium data where each column is the calcium activity of one neuron)

  • feature (Tsd (or TsdFrame with 1 column only)) – The 1-dimensional target feature (e.g. head-direction)

  • nb_bins (int) – Number of bins in the tuning curves

  • ep (IntervalSet, optional) – The epoch on which tuning curves are computed. If None, the epoch is the time support of the feature.

  • minmax (tuple or list, optional) – The min and max boundaries of the tuning curves. If None, the boundaries are inferred from the target feature

Return type:

pandas.DataFrame to hold the tuning curves

Raises:

RuntimeError – If tsdframe is not a Tsd or a TsdFrame object.

pynapple.process.tuning_curves.compute_2d_mutual_info(dict_tc, features, ep=None, minmax=None, bitssec=False)[source]#

Mutual information of a tuning curve computed from 2-d features.

See:

Skaggs, W. E., McNaughton, B. L., & Gothard, K. M. (1993). An information-theoretic approach to deciphering the hippocampal code. In Advances in neural information processing systems (pp. 1030-1037).

Parameters:
  • dict_tc (dict of numpy.ndarray or numpy.ndarray) – If array, first dimension should be the neuron

  • features (TsdFrame) – The 2 columns features that were used to compute the tuning curves

  • ep (IntervalSet, optional) – The epoch over which the tuning curves were computed If None, the epoch is the time support of the feature.

  • minmax (tuple or list, optional) – The min and max boundaries of the tuning curves. If None, the boundaries are inferred from the target features

  • bitssec (bool, optional) – By default, the function return bits per spikes. Set to true for bits per seconds

Returns:

Spatial Information (default is bits/spikes)

Return type:

pandas.DataFrame

pynapple.process.tuning_curves.compute_2d_tuning_curves(group, features, nb_bins, ep=None, minmax=None)[source]#

Computes 2-dimensional tuning curves relative to a 2d features

Parameters:
  • group (TsGroup) – The group of Ts/Tsd for which the tuning curves will be computed

  • features (TsdFrame) – The 2d features (i.e. 2 columns features).

  • nb_bins (int or tuple) – Number of bins in the tuning curves (separate for 2 feature dimensions if tuple provided)

  • ep (IntervalSet, optional) – The epoch on which tuning curves are computed. If None, the epoch is the time support of the feature.

  • minmax (tuple or list, optional) – The min and max boundaries of the tuning curves given as: (minx, maxx, miny, maxy) If None, the boundaries are inferred from the target features

Returns:

A tuple containing:

tc (dict): Dictionary of the tuning curves with dimensions (nb_bins, nb_bins).

xy (list): List of bins center in the two dimensions

Return type:

tuple

Raises:

RuntimeError – If group is not a TsGroup object or if features is not 2 columns only.

pynapple.process.tuning_curves.compute_2d_tuning_curves_continuous(tsdframe, features, nb_bins, ep=None, minmax=None)[source]#

Computes 2-dimensional tuning curves relative to a 2d feature with continuous data.

Parameters:
  • tsdframe (Tsd or TsdFrame) – Input data (e.g. continuous calcium data where each column is the calcium activity of one neuron)

  • features (TsdFrame) – The 2d feature (two columns)

  • nb_bins (int or tuple) – Number of bins in the tuning curves (separate for 2 feature dimensions if tuple provided)

  • ep (IntervalSet, optional) – The epoch on which tuning curves are computed. If None, the epoch is the time support of the feature.

  • minmax (tuple or list, optional) – The min and max boundaries of the tuning curves. Should be a tuple of minx, maxx, miny, maxy If None, the boundaries are inferred from the target feature

Returns:

A tuple containing:

tc (dict): Dictionary of the tuning curves with dimensions (nb_bins, nb_bins).

xy (list): List of bins center in the two dimensions

Return type:

tuple

Raises:

RuntimeError – If tsdframe is not a Tsd/TsdFrame or if features is not 2 columns

pynapple.process.tuning_curves.compute_discrete_tuning_curves(group, dict_ep)[source]#

Compute discrete tuning curves of a TsGroup using a dictionary of epochs. The function returns a pandas DataFrame with each row being a key of the dictionary of epochs and each column being a neurons.

This function can typically being used for a set of stimulus being presented for multiple epochs.

An example of the dictionary is :

>>> dict_ep =  {
        "stim0": nap.IntervalSet(start=0, end=1),
        "stim1":nap.IntervalSet(start=2, end=3)
    }

In this case, the function will return a pandas DataFrame :

>>> tc
           neuron0    neuron1    neuron2
stim0        0 Hz       1 Hz       2 Hz
stim1        3 Hz       4 Hz       5 Hz
Parameters:
  • group (nap.TsGroup) – The group of Ts/Tsd for which the tuning curves will be computed

  • dict_ep (dict) – Dictionary of IntervalSets

Returns:

Table of firing rate for each neuron and each IntervalSet

Return type:

pandas.DataFrame

Raises:

RuntimeError – If group is not a TsGroup object.