Decoder models API
CePNEMAnalysis.fit_decoder — Functionfit_decoder(
fit_results::Dict, datasets::Vector, decode_vars::Vector, t_val::Vector, λ_dict::Dict;
traces_use::Union{Nothing, Dict}=nothing, v_condition::String="all"
)Fit a decoder to predict the values of decode_vars from the neural traces in fit_results using L1-regularized linear regression.
Arguments
fit_results::Dict: A dictionary containing the results of fitting CePNEM to the neural data.datasets::Vector: A vector of dataset names to fit the decoder to.decode_vars::Vector: A vector of behavior variable names to decode.t_val::Vector: A vector of timepoints to use for cross-validation.λ_dict::Dict: A dictionary of regularization strengths for each variable.
Optional Arguments
traces_use::Union{Nothing, Dict}=nothing: A dictionary of trace arrays to use instead of the ones infit_results.v_condition::String="all": The velocity condition to use for selecting timepoints. Can be "all", "fwd", or "rev".
Returns
dict_sol::Dict: A dictionary of the fitted decoder models.dict_pred::Dict: A dictionary of the predicted values ofdecode_varsfor each timepoint.dict_cost::Dict: A dictionary of the mean squared error between the predicted and actual values ofdecode_varsfor each timepoint.
CePNEMAnalysis.compute_variance_explained — Functioncompute_variance_explained(dict_cost::Dict, fit_results::Dict, t_val::Vector, decode_vars::Vector, λ_dict::Dict; min_P_variance::Float64=0.5)Compute the variance explained by the decoder for each dataset, behavior variable, regularization strength, and timepoint.
Arguments
dict_cost::Dict: A dictionary of the mean squared error between the predicted and actual values ofdecode_varsfor each timepoint.fit_results::Dict: A dictionary containing the results of fitting CePNEM to the neural data.t_val::Vector: A vector of timepoints to use for cross-validation.decode_vars::Vector: A vector of behavior variable names to decode.λ_dict::Dict: A dictionary of regularization strengths for each variable.
Optional Arguments
min_P_variance::Float64=0.5: The minimum variance of thePvariable for a dataset to be included in the analysis.
Returns
dict_quality::Dict: A dictionary of the variance explained by the decoder for each dataset, behavior variable, regularization strength, and timepoint.
CePNEMAnalysis.average_dict_qualities — Functionaverage_dict_qualities(dict_qualities::Dict)Compute the average variance explained by the decoder for each dataset, behavior variable, regularization strength, and timepoint.
Arguments
dict_qualities::Dict: A dictionary of the variance explained by the decoder for each dataset, behavior variable, regularization strength, and timepoint.
Returns
dict_quality::Dict: A dictionary of the average variance explained by the decoder for each dataset, behavior variable, regularization strength, and timepoint.