moseq2_viz.helpers package

Helpers - Wrappers Module

Wrapper functions CLI and GUI.

moseq2_viz.helpers.wrappers.add_group_wrapper(index_file, config_data)

Update group name in index file (moseq2-index.yaml) with specified group name.

Args: index_file (str): path to index file config_data (dict): dictionary for configuration parameters

moseq2_viz.helpers.wrappers.copy_h5_metadata_to_yaml_wrapper(input_dir)

Copy h5 metadata dictionary contents into the respective file’s yaml file.

Args: input_dir (str): path to directory that contains h5 files.

moseq2_viz.helpers.wrappers.get_best_fit_model_wrapper(model_dir, cp_file, output_file, plot_all=False, ext='p', fps=30, objective='duration (mean match)')

find the model that best match the model-free changepoint given an objective.

Args: model_dir (str): Path to directory containing multiple models. cp_file (str): Path to model-free changepoints output_file (str): Path to file to save figure to. plot_all (bool): boolean flag that plots all model changepoint distributions. ext (str): File extension to search for models with fps (int): Frames per second objective (str): The objective for matching model-free changpoint and the model changepoint

Returns: best_model_info (dict): Dictionary containing the best model info with respect to given objective. fig (pyplot.figure): figure of model and model-free changepoint comparison.

moseq2_viz.helpers.wrappers.init_wrapper_function(index_file=None, output_dir=None, output_file=None)

parse the index file for index data and sorted uuid.

Args: index_file (str): path to index file to load. output_dir (str): path to directory to save crowd movies in. output_file (str): path to saved figures.

Returns: index (dict): loaded index file dictionary sorted_index (dict): OrderedDict object representing a sorted version of index

moseq2_viz.helpers.wrappers.make_crowd_movies_wrapper(index_file, model_path, output_dir, config_data)

create crowd movie videos for each syllable.

Args: index_file (str): path to index file model_path (str): path to trained model. output_dir (str): directory to store crowd movies in. config_data (dict): dictionary conataining all the necessary parameters to generate the crowd movies.

Returns: cm_paths (dict): Dictionary of syllables and their generated crowd movie paths

moseq2_viz.helpers.wrappers.plot_mean_group_position_pdf_wrapper(index_file, output_file, normalize=False, norm_color=<matplotlib.colors.LogNorm object>)

Compute the position PDF for each session, averages the PDFs within each group, and plots the averaged PDFs.

Args: index_file (str): path to index file. output_file (str): filename for the group heatmap graph. normalize (bool): normalize the PDF so that min and max values range from 0-1. norm_color (mpl.colors Color Scheme or None): a color scheme to use when plotting heatmaps.

Returns: fig (pyplot.figure): figure to graph in Jupyter Notebook.

moseq2_viz.helpers.wrappers.plot_scalar_summary_wrapper(index_file, output_file, groupby='group', colors=None, show_scalars=['velocity_2d_mm', 'velocity_3d_mm', 'height_ave_mm', 'width_mm', 'length_mm'])

Create a scalar summary graph.

Args: index_file (str): path to index file. output_file (str): path to save graphs groupby (str): scalar_df column to group sessions by when graphing scalar and position summaries colors (list): list of colors to serve as the palette in the scalar summary show_scalars (list): list of scalar variables to plot; variable names must equal columns in the scalar_df DataFrame.

Returns: scalar_df (pandas DataFrame): df containing scalar data per session uuid.

moseq2_viz.helpers.wrappers.plot_syllable_stat_wrapper(model_fit, index_file, output_file, stat='usage', sort=True, count='usage', group=None, max_syllable=40, ordering=None, ctrl_group=None, exp_group=None, colors=None, figsize=(10, 5))

Plot syllable statistic from a trained AR-HMM model.

Args: model_fit (str): path to trained model. index_file (str): path to index file. output_file (str): filename for syllable usage graph. stat (str): syllable statistic to plot. sort (bool): sort syllables by parameter specified in count paramter. count (str): method to compute syllable mean usage, either ‘usage’ or ‘frames’. group (tuple, list, None): tuple or list of groups to include in usage plot. (None to graph all groups) max_syllable (int): the index of the maximum number of syllables to include ordering (list, range, str, None): order to list syllables. ctrl_group (str): Control group to graph. exp_group (str): Experimental group to compare with control group. colors (list): list of colors to serve as the sns palette in the scalar summary. If None, default colors are used. figsize (tuple): tuple value of length 2, representing (columns x rows) of the plotted figure dimensions

Returns: fig (pyplot.figure): figure to show in Jupyter Notebook.

moseq2_viz.helpers.wrappers.plot_transition_graph_wrapper(index_file, model_fit, output_file, config_data)

plot transition graphs.

Args: index_file (str): path to index file model_fit (str): path to trained model. output_file (str): filename for syllable usage graph. config_data (dict): dictionary containing the user specified keys and values

Returns: plt (pyplot.figure): graph to show in Jupyter Notebook.

moseq2_viz.helpers.wrappers.plot_verbose_pdfs_wrapper(index_file, output_file, normalize=False, norm_color=<matplotlib.colors.LogNorm object>)

Compute the PDF for the mouse position for each session in the index file.

Args: index_file (str): path to index file. output_file (str): filename for the verbose heatmap graph. normalize (bool): normalize the PDF so that min and max values range from 0-1. norm_color (mpl.colors Color Scheme or None): color scheme to use when plotting heatmaps.

Returns: fig (pyplot.figure): figure to graph in Jupyter Notebook.