make_latent_traversal_movie

behavenet.plotting.cond_ae_utils.make_latent_traversal_movie(lab, expt, animal, session, model_class, alpha, beta, n_ae_latents, rng_seed_model, experiment_name, n_labels, trial_idxs, batch_idxs, trials, hparams=None, label_min_p=5, label_max_p=95, channel=0, sess_idx=0, sess_ids=None, force_sess_ids=False, n_frames=10, n_buffer_frames=5, crop_kwargs=None, n_cols=3, movie_kwargs={}, panel_titles=None, order_idxs=None, split_movies=False, save_file=None, **kwargs)[source]

Create a multi-panel movie with each panel showing traversals of an individual latent dim.

The traversals will start at a lower bound, increase to an upper bound, then return to a lower bound; the traversal of each dimension occurs simultaneously. It is also possible to specify multiple base frames for the traversals; the traversal of each base frame is separated by several blank frames. Note that support for plotting markers on top of the corresponding supervised dimensions is not supported by this function.

Parameters:
  • lab (str) – lab id

  • expt (str) – expt id

  • animal (str) – animal id

  • session (str) – session id

  • model_class (str) – model class in which to perform traversal; currently supported models are: ‘ae’ | ‘vae’ | ‘cond-ae’ | ‘cond-vae’ | ‘ps-vae’ note that models with conditional encoders are not currently supported

  • alpha (float) – ps-vae alpha value

  • beta (float) – ps-vae beta value

  • n_ae_latents (int) – dimensionality of unsupervised latents

  • rng_seed_model (int) – model seed

  • experiment_name (str) – test-tube experiment name

  • n_labels (str) – dimensionality of supervised latent space (ignored when using fully unsupervised models)

  • trial_idxs (array-like of int) – trial indices of base frames used for interpolation; if an entry is an integer, the corresponding entry in trials must be None. This value is a trial index into all test trials, and is not affected by how the test trials are shuffled. The trials argument (see below) takes precedence over trial_idxs.

  • batch_idxs (array-like of int) – batch indices of base frames used for interpolation; correspond to entries in trial_idxs and trials

  • trials (array-like of int) – trials of base frame used for interpolation; if an entry is an integer, the corresponding entry in trial_idxs must be None. This value is a trial index into all possible trials (train, val, test), whereas trial_idxs is an index only into test trials

  • hparams (str, optional) – If not NoneType, uses these hparams instead of required args

  • label_min_p (float, optional) – lower percentile of training data used to compute range of traversal

  • label_max_p (float, optional) – upper percentile of training data used to compute range of traversal

  • channel (int, optional) – image channel to plot

  • sess_idx (int, optional) – session index into data generator

  • sess_ids (list, optional) – each entry is a session dict with keys ‘lab’, ‘expt’, ‘animal’, ‘session’; for loading labels and labels_sc

  • force_sess_ids (bool, optional) – True to force the creation of a new data generator based on the provided sess_ids, rather than the default associated with the model; necessary for performing latent traversals on sessions that were not used for training

  • n_frames (int, optional) – number of frames (points) to display for traversal across latent dimensions; the movie will display a traversal of n_frames across each dim, then another traversal of n_frames in the opposite direction

  • n_buffer_frames (int, optional) – number of blank frames to insert between base frames

  • crop_kwargs (dict, optional) – if crop_type is not None, provides information about the crop (for a fixed crop window) keys : ‘y_0’, ‘x_0’, ‘y_ext’, ‘x_ext’; window is (y_0 - y_ext, y_0 + y_ext) in vertical direction and (x_0 - x_ext, x_0 + x_ext) in horizontal direction

  • n_cols (int, optional) – movie is n_cols panels wide

  • movie_kwargs (dict, optional) – additional kwargs for individual panels; possible keys are ‘markersize’, ‘markeredgecolor’, ‘markeredgewidth’, and ‘text_color’

  • panel_titles (list of str, optional) – optional titles for each panel

  • order_idxs (array-like, optional) – used to reorder panels (which are plotted in row-major order) if desired; can also be used to choose a subset of latent dimensions to include

  • split_movies (bool, optional) – True to save a separate latent traversal movie for each latent dimension

  • save_file (str, optional) – absolute path of save file; does not need file extension, will automatically be saved as mp4. To save as a gif, include the ‘.gif’ file extension in save_file hparams : dict, optional

  • kwargs – arguments are keys of hparams, for example to set train_frac, rng_seed_model, etc.