Plotting API

Compute optimal time ranges to plot

CePNEMAnalysis.get_pumping_ranges — Function
get_pumping_ranges(datasets::Vector{String}, P_ranges::Dict; rngs_valid::Vector{Int}=[1,2])

Computes time ranges with the most pumping variance for each dataset.

Arguments:

  • datasets::Vector{String}: List of datasets to analyze
  • P_ranges::Dict: Dictionary of pumping ranges for each dataset
  • rngs_valid::Vector{Int} (optional, default [1,2]): List of time ranges to consider

Cluster visualization tool

CePNEMAnalysis.dendrocolor! — Function
dendrocolor!(dg, clusters, colors; progenitors=nothing, k=nothing)

Color the dendrogram dg according to the cluster assignments in clusters. The colors argument should be a vector of colors, one for each cluster. The progenitors argument can be a vector of indices of the progenitor nodes to use for coloring. Alternatively, the k argument can be an integer specifying the number of clusters to use for coloring.

Arguments

  • dg: A StatsPlots dendrogram of a hierarchical clustering result.
  • clusters: The clusters being plotted in the dendrogram.
  • colors::Vector{Color}: The colors to use for coloring.
  • progenitors::Vector{Int} = nothing: The indices of the progenitor nodes to use for coloring.
  • k::Int = nothing: The number of clusters to use for coloring.

Returns

  • node_assignments::Dict{Int,Int}: A dictionary mapping node indices to cluster assignments.

Also in-place modifies the plot object dg to color it correctly.

Other plotting utilities

CePNEMAnalysis.plot_posterior_heatmap! — Function
plot_posterior_heatmap!(fit_results, dataset, rng, neuron, param1, param2; init=true, color=palette(:default)[2], x_rng=-3:0.1:3, y_rng=-3:0.1:3, rgb=false)

Plots the heatmap of the projection of posterior particles of a neuron into a 2D susbspace.

Arguments:

  • fit_results: Dictionary of Gen fit results.
  • dataset: Dataset containing the neuron.
  • rng: Range where the neuron was fit.
  • neuron: Neuron
  • param1: First parameter to plot (as an index 1 through 9)
  • param2: Second parameter to plot (as an index 1 through 9)
  • c1rng: First parameter range
  • c2rng: Second parameter range
  • init (optional, default true): Initialize a new plot, rather than overlaying on top of a preexisting plot
  • color (optional, default palette(:default)[2]): Color of the heatmap
  • x_rng (optional, default -3:0.1:3): x-axis range
  • y_rng (optional, default -3:0.1:3): y-axis range
  • rgb (optional, default false): If set, return RGB histogram and x and y ranges, instead of a plot.
CePNEMAnalysis.plot_deconvolved_neural_activity! — Function
plot_deconvolved_neural_activity!(
    dataset, rngs, deconvolved_activity_plot, v_ranges_plot, θh_ranges_plot, P_ranges_plot, axis;
    res=200, plot_size=(700,350), init=true, len=200, pos=[100]
)

Plots deconvolved neural activity.

Arguments:

  • dataset
  • rngs: Ranges to plot
  • deconvolved_activity_plot: Deconvolved neural activity, for plotting
  • v_ranges_plot: velocity ranges
  • θh_ranges_plot: head curvature ranges
  • P_ranges_plot: feeding ranges
  • axis: variable to plot. Can be 2 to plot velocity while varying head curvature, or 3 to plot feeding.
  • res (optional, default 200): Resolution of plot
  • plot_size (optional, default (700,350)): Size of plot.
  • init (optional, default true): Initialize a new plot.
  • len: Length to extrapolate other behaviors
  • pos: Position of other behaviors to use
CePNEMAnalysis.plot_colorbar — Function
plot_colorbar(rng_min::Real, rng_max::Real, other_ticks::Vector, cmap, n_colors::Integer, figsize::Tuple{Real, Real})

Plots a colorbar with a gradient of colors ranging from rng_min to rng_max with n_colors colors. The other_ticks argument is a vector of additional ticks to be displayed on the colorbar. The cmap argument is a ColorMap object that specifies the color scheme to be used. The n_colors argument is an Integer specifying the number of colors to be used in the gradient. The figsize argument is a tuple of two Real values that specifies the size of the figure.

Arguments:

  • rng_min::Real: The minimum value of the range of values to be displayed on the colorbar.
  • rng_max::Real: The maximum value of the range of values to be displayed on the colorbar.
  • other_ticks::Vector: A vector of additional ticks to be displayed on the colorbar.
  • cmap: A ColorMap that specifies the color scheme to be used.
  • n_colors::Integer: The number of colors to be used in the gradient.
  • figsize::Tuple{Real, Real}: A tuple of two Real values that specifies the size of the figure.

Returns:

  • Nothing. The function is called for its side effects of plotting the colorbar.
CePNEMAnalysis.color_to_rgba — Function
color_to_rgba(color::Color, alpha::Real) -> Tuple{Float64, Float64, Float64, Float64}

Converts a Color object to an RGBA tuple with the given alpha value.

Arguments:

  • color: The Color object to convert.
  • alpha: The alpha value to use for the RGBA tuple.

Returns:

  • A tuple of four Float64 values representing the RGBA values of the input Color object with the given alpha value.
CePNEMAnalysis.plot_arrow! — Function
plot_arrow!(arrow_start::Tuple{Real, Real}, arrow_end::Tuple{Real, Real}, arrow_color::Color, arrow_width::Real, arrow_length::Real)

Plots an arrow from arrow_start to arrow_end with a given arrow_color, arrow_width, and arrow_length.

Arguments:

  • arrow_start::Tuple{Real, Real}: Starting point of the arrow.
  • arrow_end::Tuple{Real, Real}: Ending point of the arrow.
  • arrow_color::Color: Color of the arrow.
  • arrow_width::Real: Width of the arrow.
  • arrow_length::Real: Length of the arrow.
CePNEMAnalysis.get_color_from_palette — Function
get_color_from_palette(value::Real, min_val::Real, max_val::Real, cmap::ColorMap) -> Color

Returns the color corresponding to a given value in a colormap. The colormap is defined by the cmap argument, which is a ColorMap object. The value argument is the value for which the corresponding color is to be found. The min_val and max_val arguments define the range of values that the colormap spans.

Arguments:

  • value: The value for which the corresponding color is to be found.
  • min_val: The minimum value of the range of values that the colormap spans.
  • max_val: The maximum value of the range of values that the colormap spans.
  • cmap: A ColorMap object that defines the colormap.

Returns:

  • A Color object corresponding to the given value in the colormap.