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 idexpt (
str) – expt idanimal (
str) – animal idsession (
str) – session idmodel_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 supportedalpha (
float) – ps-vae alpha valuebeta (
float) – ps-vae beta valuen_ae_latents (
int) – dimensionality of unsupervised latentsrng_seed_model (
int) – model seedexperiment_name (
str) – test-tube experiment namen_labels (
str) – dimensionality of supervised latent space (ignored when using fully unsupervised models)trial_idxs (
array-likeofint) – 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-likeofint) – batch indices of base frames used for interpolation; correspond to entries in trial_idxs and trialstrials (
array-likeofint) – 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 trialshparams (
str, optional) – If not NoneType, uses these hparams instead of required argslabel_min_p (
float, optional) – lower percentile of training data used to compute range of traversallabel_max_p (
float, optional) – upper percentile of training data used to compute range of traversalchannel (
int, optional) – image channel to plotsess_idx (
int, optional) – session index into data generatorsess_ids (
list, optional) – each entry is a session dict with keys ‘lab’, ‘expt’, ‘animal’, ‘session’; for loading labels and labels_scforce_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 trainingn_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 directionn_buffer_frames (
int, optional) – number of blank frames to insert between base framescrop_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 directionn_cols (
int, optional) – movie is n_cols panels widemovie_kwargs (
dict, optional) – additional kwargs for individual panels; possible keys are ‘markersize’, ‘markeredgecolor’, ‘markeredgewidth’, and ‘text_color’panel_titles (
listofstr, optional) – optional titles for each panelorder_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 includesplit_movies (
bool, optional) – True to save a separate latent traversal movie for each latent dimensionsave_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, optionalkwargs – arguments are keys of hparams, for example to set train_frac, rng_seed_model, etc.