Encoding metrics API

Signal value computation

CePNEMAnalysis.compute_signal — Function
compute_signal(fit_results::Dict)

Computes signal value for each neuron in each dataset.

Arguments:

  • fit_results::Dict: Dictionary of CePNEM fit results.

Extrapolated behaviors

CePNEMAnalysis.extrapolate_behaviors — Function
extrapolate_behaviors(fit_results, datasets, θh_pos_is_ventral)

Creates extrapolated behaviors by appending behaviors from individual animals.

Arguments

  • fit_results: CePNEM fit results.
  • datasets: Array of datasets to use.
  • θh_pos_is_ventral: Whether positive θh value corresponds to ventral (true) or dorsal (false) head bending.

Encoding strength metrics

CePNEMAnalysis.get_relative_encoding_strength — Function
get_relative_encoding_strength(fit_results::Dict, datasets::Vector{String}; dataset_mapping=nothing)

Computes the relative encoding strength of all neurons in all datasets.

Arguments

  • fit_results::Dict: Dictionary of Gen fit results.
  • datasets::Vector{String}: List of datasets to compute relative encoding strength for.
CePNEMAnalysis.get_relative_encoding_strength_mt — Function
get_relative_encoding_strength_mt(fit_results::Dict, dataset::String, rng::Int, neuron::Int; max_idx::Int=10001, dataset_mapping=nothing)

Computes the relative encoding strength of the three behaviors, together with standard deviations of full and deconvolved model fits.

Arguments

  • fit_results::Dict: Gen fit results.
  • dataset::String: Dataset to use
  • rng::Int: Range in that dataset to use
  • neuron::Int: Neuron to use
  • max_idx::Int (optional, default 10001): Maximum Gen posterior sample index.
  • dataset_mapping (optional, default nothing): Dictionary mapping to use different behavioral dataset.
CePNEMAnalysis.get_relative_encoding_strength! — Function
get_relative_encoding_strength!(ps::Vector{Float64}, b_v::Vector{Float64}, b_θh::Vector{Float64}, b_P::Vector{Float64}; b_null::Union{Vector{Float64}, Nothing}=nothing)

Computes the relative encoding strength of the three behaviors, together with standard deviations of full and deconvolved model fits, for a single CePNEM fit.

Arguments

  • ps::Vector{Float64}: Vector of model parameters.
  • b_v::Vector{Float64}: Vector of behavioral values for the velocity behavior.
  • b_θh::Vector{Float64}: Vector of behavioral values for the heading behavior.
  • b_P::Vector{Float64}: Vector of behavioral values for the persistence behavior.
  • b_null::Union{Vector{Float64}, Nothing} (optional, default nothing): Vector of behavioral values for the null behavior. If nothing, a vector of zeros is used.
CePNEMAnalysis.parse_tuning_strength — Function
parse_tuning_strength(tuning_strength::Dict{String, Any}, beh::String, encoding::String)

Parses the tuning strength of a neuron for a given behavior and encoding.

Arguments:

  • tuning_strength::Dict{String, Any}: A dictionary containing the tuning strength of a neuron.
  • beh::String: The behavior for which to find the tuning strength.
  • encoding::String: The encoding for which to find the tuning strength.

Returns:

  • tuning_strength::Any: The tuning strength of the neuron for the given behavior encoding.

Encoding tuning metrics

CePNEMAnalysis.get_tuning_strength — Function
get_tuning_strength(fit_results::Dict, deconvolved_activity::Dict, relative_encoding_strength::Dict, θh_pos_is_ventral::Dict, v_ranges::Dict, θh_ranges::Dict, P_ranges::Dict; stat::Function=median, metric::Function=identity)

Helper function to calculate tuning strength for all neurons in all datasets.

Args:

  • fit_results: A dictionary containing the results of the fitting process.
  • deconvolved_activity: A dictionary containing the deconvolved neural activity.
  • relative_encoding_strength: A dictionary containing the relative encoding strength.
  • θh_pos_is_ventral: A dictionary containing a boolean indicating if θh_pos is ventral.
  • v_ranges: A dictionary containing the range of v values.
  • θh_ranges: A dictionary containing the range of θh values.
  • P_ranges: A dictionary containing the range of P values.
  • stat: A function to compute the statistic of interest. Default is median.
  • metric: A function to compute the metric of interest. Default is identity.

Returns: A dictionary containing the tuning strength values for all neurons in all datasets.

CePNEMAnalysis.calculate_tuning_strength_per_neuron — Function
calculate_tuning_strength_per_neuron(
    neuron_deconv, relative_encoding_strength, signal, v_range, θh_range, P_range,
    θh_pos_is_ventral; stat::Function=median, zero_da=nothing
)

Helper function to calculate tuning strength for a given neuron.

Args: neuron_deconv: Deconvolved neural activity. zero_da: Zero deconvolved activity array. relative_encoding_strength: signal: Signal value for the current neuron. v_range: Range θh_range: Difference between θhranges. `Prange: Difference between P_ranges.θhposisventral`: Boolean indicating if θhpos is ventral.

Returns: A Dict containing tuning strength values for the neuron.

CePNEMAnalysis.get_forwardness — Function
get_forwardness(tuning_strength::Dict)

Given tuning strength values for a given neuron, returns the forwardness of that neuron.

Arguments:

  • tuning_strength::Dict: A dictionary containing the tuning strength values for a given neuron.

Returns: The forwardness of the neuron.

CePNEMAnalysis.get_dorsalness — Function
get_dorsalness(tuning_strength::Dict)

Given tuning strength values for a given neuron, returns the dorsalness of that neuron.

Arguments:

  • tuning_strength::Dict: A dictionary containing the tuning strength values for a given neuron.

Returns: The dorsalness of the neuron.

CePNEMAnalysis.get_feedingness — Function
get_feedingness(tuning_strength::Dict)

Given tuning strength values for a given neuron, returns the feedingness of that neuron.

Arguments:

  • tuning_strength::Dict: A dictionary containing the tuning strength values for a given neuron.

Returns: The feedingness of the neuron.