moseq2_app.viz package

Submodules

Viz - Controller Module

Main syllable crowd movie viewing, comparing, and labeling functionality.

class moseq2_app.viz.controller.CrowdMovieComparison(config_data, index_path, df_path, model_path, syll_info, output_dir, get_pdfs, load_parquet)

Bases: CrowdMovieCompareWidgets

crowd_movie_preview(syllable, groupby, nexamples)

run the crowd_movie_wrapper function and creates the HTML divs containing the generated crowd movies.

Args: syllable (int or ipywidgets.DropDownMenu): Currently displayed syllable. nexamples (int or ipywidgets.IntSlider): Number of mice to display per crowd movie.

generate_crowd_movie_divs(grouped_syll_dict)

Generate HTML divs containing crowd movies and syllable metadata tables from the given syllable dict file.

Returns: divs (list of Bokeh.models.Div): Divs of HTML videos and metadata tables. bk_plots (list): list of corresponding position heatmap figures.

get_mean_group_dict(group_df)

Create a dict object to convert to a displayed table containing syllable scalars.

Args: group_df (pd.DataFrame): DataFrame containing mean syllable scalar data for each session and their groups

get_pdf_plot(group_syllable_pdf, group_name)

create a bokeh plot with the given PDF heatmap and figure title.

Args: group_syllable_pdf (2D np.ndarray): Mean syllable position PDF heatmap. group_name (str): Name of group for generated syllable pdf

Returns: pdf_fig (bokeh.figure): Create bokeh figure.

get_selected_session_syllable_info(sel_sessions)

Prepare dict of session-based syllable information to display.

Args: sel_sessions (list): list of selected session names.

get_session_mean_syllable_info_df()

Populate session-based syllable information dict with usage and scalar information.

set_default_cm_parameters()

set default parameter for rendering crowd movie parameters.

class moseq2_app.viz.controller.SyllableLabeler(model_fit, model_path, index_file, config_file, max_sylls, select_median_duration_instances, max_examples, crowd_movie_dir, save_path)

Bases: SyllableLabelerWidgets

get_crowd_movie_paths(index_path, model_path, config_data, crowd_movie_dir)

Populate the syllable information dict with the respective crowd movie paths.

Args: crowd_movie_dir (str): Path to directory containing all the generated crowd movies

get_mean_group_dict(group_df)

Create a dict object to convert to a displayed table containing syllable scalars.

Args: group_df (pd.DataFrame): DataFrame containing mean syllable scalar data for each session and their groups

get_mean_syllable_info()

Populate syllable information dict with usage and scalar information.

interactive_syllable_labeler(syllables)

create a Bokeh Div object to display the current video path.

Args: syllables (int or ipywidgets.DropDownMenu): Current syllable to label

set_default_cm_parameters(config_data)

Set default crowd movie generation parameters that may be manually updated.

Args: config_data (dict): Dict of main moseq configuration parameters.

Returns: config_data (dict): updated config parameter dictionary.

set_group_info_widgets(group_info)

read the syllable information into a pandas DataFrame and display it as a table.

Args: group_info (dict): Dictionary of grouped current syllable information

write_syll_info(curr_syll=None)

Write current syllable info data to a YAML file.

Viz - View Module

Function that displays a grid of crowd movies and plotted bokeh figures of position heatmaps.

moseq2_app.viz.view.display_crowd_movies(widget_box, curr_name, desc, divs, bk_figs)

display the crowd movies in jupyter notebook.

Args: divs (list of bokeh.models.Div): list of HTML Div objects containing videos to display

Returns:

Viz - Widgets Module

Widgets module containing classes with components for each of the interactive syllable visualization tools

class moseq2_app.viz.widgets.CrowdMovieCompareWidgets

Bases: object

clear_on_click(b=None)

Clear the cell output

Args: b (buttion click)

on_click_trigger_button(b=None)

Generate crowd movies and displays them when the user clicks the trigger button

Args: b (ipywidgets.Button click event): User clicks “Generate Movies” button

select_session(event=None)

get the session scalar information.

Args: event (event): User clicks on multiple sessions in the SelectMultiple widget

show_session_select(change)

change current view to show session selector.

Args: change (event): User switches their DropDownMenu selection

class moseq2_app.viz.widgets.SyllableLabelerWidgets

Bases: object

clear_on_click(b=None)

Clear the cell output

Args: b (button click)

on_next(event=None)

trigger an view update when the user clicks the “Next” button.

Args: event (ipywidgets.ButtonClick): User clicks next button.

on_prev(event=None)

trigger an view update when the user clicks the “Previous” button.

Args: event (ipywidgets.ButtonClick): User clicks ‘previous’ button.

on_set(event=None)

save the dict to syllable information file.

Args: event (ipywidgets.ButtonClick): User clicks the ‘Save’ button.

Module contents