moseq2_model.helpers Package

Helpers - Data Module

Helper functions for reading data from index files, and preparing metadata prior to training., train_list, hold_out_list)

Split data by session UUIDs into training and held out datasets.

Args: data_dict (OrderedDict): dictionary of all PC scores included in the model train_list (list): list of keys included in the training data hold_out_list (list): list of keys included in the held out data

Returns: train_data (OrderedDict): dictionary of uuid to PC score key-value pairs for uuids in train_list test_data (OrderedDict): dictionary of uuids to PC score key-value pairs for uuids in hold_out_list., data_dict)

Split the data into a training and held out dataset by splitting each session by some fraction percent_split.

Args: split_frac (float): fraction to split each session into training data, leaving the rest as validation data. data_dict (OrderedDict): dict of uuid-PC Score key-value pairs for all data included in the model.

Returns: training_data (OrderedDict): the split percentage of the training data. validation_data (OrderedDict): the split percentage of the validation data, iter_lls, iter_holls, model_dir)

Graph model training performance progress throughout modeling if verbose is True

Args: config_data (dict): dictionary of model training parameters. iter_lls (list): list of training log-likelihoods for each training iteration iter_holls (list): list of held out log-likelihoods for each training iteration model_dir (str): path to the directory the model is saved in.

Returns: img_path (str): path to saved graph., data_metadata, config_data)

Set model training metadata parameters, whiten data, split data and return list of heldout keys if applicable, and update all dictionaries.

Args: data_dict (OrderedDict): loaded data dictionary. data_metadata (OrderedDict): loaded metadata dictionary. config_data (dict): dictionary containing all modeling parameters.

Returns: data_dict (OrderedDict): optionally whitened and updated data dictionary. model_parameters (dict): model parameters used to initialize the ARHMM train_list (list): list of session uuids to include for training. hold_out_list (list): list of session uuids to hold out (if hold_out == True), data_metadata, default_group='n/a', select_groups=False)

Read index file (if applicable) and return dictionaries containing metadata in the index file.

Args: index (str or None): path to index file. data_metadata (dict): loaded metadata containing uuid and group information. default_group (str): default group name to supply to data without assigned group labels select_groups (bool): when True, print metadata describing group selection

Returns: index_data (dict): loaded index file. data_metadata (dict): updated metadata dictionary., data_dict, data_metadata, select_groups=False)

Select the data to model.

Args: index_data (dict): loaded dictionary from index file data_dict (dict): dictionary containing PC scores for all sessions data_metadata (dict): dictionary containing metadata associated with the recording sessions select_groups (bool): flag to solicit user input on which groups to select for modeling

Returns: data_dict (dict): dictionary to model containing data from the selected session uuids data_metadata (dict): updated metadata containing the selected uuids and groups

Helpers - Wrappers Module

Wrapper functions for CLI and GUI.

moseq2_model.helpers.wrappers.kappa_scan_fit_models_wrapper(input_file, config_data, output_dir)

Wrapper function to output multiple model training commands for a range of kappa values.

Args: input_file (str): Path to PC Scores config_data (dict): Dictionary containing model training parameters output_dir (str): Path to output directory to save trained models

Returns: command_string (str): CLI command string for model training commands.

moseq2_model.helpers.wrappers.learn_model_wrapper(input_file, dest_file, config_data)

Wrapper function to train ARHMM on PC scores.

Args: input_file (str): path to pc scores file. dest_file (str): path to save model to. config_data (dict): dictionary containing the modeling parameters.

Returns: None