UMAP API

Compute UMAP embedding

CePNEMAnalysis.compute_extrapolated_CePNEM_posterior_stats — Function
compute_extrapolated_CePNEM_posterior_stats(
    fit_results, analysis_dict, datasets, θh_pos_is_ventral; n_idx=10001, use_pumping=true, normalize=true
)

Computes statistics of the CePNEM fits of all neurons in each dataset across the set of extrapolated behaviors.

Arguments

  • fit_results: CePNEM fit results.
  • analysis_dict: CePNEM fit analysis results dictionary.
  • datasets: Array of datasets to use.
  • θh_pos_is_ventral: Whether positive θh value corresponds to ventral (true) or dorsal (false) head bending.
  • n_idx (optional, default 10001): Number of particles in CePNEM fits.
  • use_pumping (optional, default true): Whether to use pumping in CePNEM fits.
  • normalize (optional, default true): Whether to normalize CePNEM fits by signal value.

Returns

  • median_CePNEM_fits: Median of the CePNEM fits of each neurons in each dataset across the set of extrapolated behaviors.
  • mean_CePNEM_fits: Mean of the CePNEM fits of each neurons in each dataset across the set of extrapolated behaviors.
  • var_CePNEM_fits: Variance of the CePNEM fits of each neurons in each dataset across the set of extrapolated behaviors.
CePNEMAnalysis.append_median_CePNEM_fits — Function
append_median_CePNEM_fits(fit_results, analysis_dict, umap_dict, datasets)

Appends median CePNEM fits together into a single array.

Arguments

  • fit_results: CePNEM fit results.
  • analysis_dict: CePNEM fit analysis results dictionary containing the extrapolated_behaviors key.
  • umap_dict: UMAP results dictionary containing the median_CePNEM_fits key.
  • datasets: Array of datasets to use.

Project new datasets into UMAP space

CePNEMAnalysis.project_CePNEM_to_UMAP — Function
project_CePNEM_to_UMAP(fit_results, analysis_dict, umap_dict, datasets, θh_pos_is_ventral; n_idx=10001, use_pumping=true)

Projects median CePNEM fits to UMAP space.

Arguments

  • fit_results: CePNEM fit results.
  • analysis_dict: CePNEM fit analysis results dictionary.
  • umap_dict: UMAP results dictionary containing the extrapolated_umap_median key.
  • datasets: Array of datasets to use.
  • θh_pos_is_ventral: Whether positive θh value corresponds to ventral (true) or dorsal (false) head bending.
  • n_idx (optional, default 10001): Number of particles in CePNEM fits.
  • use_pumping (optional, default true): Whether to use pumping in the model.

Visualize UMAP embeddings

CePNEMAnalysis.make_umap_rgb — Function
make_umap_rgb(feature_imgs, feature_colors, full_umap_img, color_all, contrast)

Makes RGB image out of UMAP space.

Arguments:

  • feature_imgs: List of UMAP-projected images showing features of interest.
  • feature_colors: List of UMAP-projected images showing colors of interest.
  • full_umap_img: List of full UMAP image
  • color_all: Background color of full UMAP image
  • contrast: Contrast of features vs full UMAP image.
CePNEMAnalysis.compute_umap_subcategories! — Function
compute_umap_subcategories!(
    fit_results, analysis_dict, umap_dict, datasets; dataset_cats="2021-05-26-07", 
    rng_cats=1, ewma_step=5, ewma_max=50, suffix="_median", use_median=false
)

Computes UMAP projections for each encoding category.

# Arguments
- `fit_results`: CePNEM fit results.
- `analysis_dict`: CePNEM fit analysis results dictionary.
- `umap_dict`: UMAP results dictionary. Modified in-place by this function.
- `datasets`: Array of datasets to use.
- `dataset_cats` (optional, default `"2021-05-26-07"`): Dataset to use for finding encoding categories.
- `rng_cats` (optional, default `1`): Range to use for finding encoding categories.
- `ewma_step` (optional, default `5`): Step size for exponentially weighted moving average.
- `ewma_max` (optional, default `50`): Maximum number of steps for exponentially weighted moving average.
- `suffix` (optional, default `"_median"`): Suffix for extrapolated UMAP key in `analysis_dict`.
- `use_median` (optional, default `false`): Whether to use median (`true`) or all posterior points (`false`) for extrapolated UMAP projections.