moseq2_viz.info package

Info - Utilities Module

Utility functions for computing syllable usage entropy, and syllable transition entropy rate.

moseq2_viz.info.util.entropy(labels, truncate_syllable=40, smoothing=1.0, relabel_by='usage')

Compute syllable usage entropy, base 2.

Args: labels (list of numpy.ndarray): list of predicted syllable label arrays from a group of sessions truncate_syllable (int): maximum number of relabeled syllable to keep for this calculation smoothing (float): a constant as pseudocount added to label usages before normalization relabel_by (str): mode to relabel predicted labels. Either ‘usage’, ‘frames’, or None.

Returns: ent (list): list of entropies for each session.

moseq2_viz.info.util.entropy_rate(labels, truncate_syllable=40, normalize='bigram', smoothing=1.0, tm_smoothing=1.0, relabel_by='usage')

Compute entropy rate, base 2 using provided syllable labels. If syllable labels have not been re-labeled by usage, this function will do so.

Args: labels (list or np.ndarray): a list of label arrays, where each entry in the list is an array of labels for one session. truncate_syllable (int): maximum number of labels to keep for this calculation. normalize (str): the type of transition matrix normalization to perform. smoothing (float): a constant as pseudocount added to label usages before normalization tm_smoothing (float): a constant as pseudocount added to label transtition counts before normalization. relabel_by (str): how to re-order labels. Options are: ‘usage’, ‘frames’, or None.

Returns: ent (list): list of entropy rates per syllable label

moseq2_viz.info.util.transition_entropy(labels, tm_smoothing=0, truncate_syllable=40, transition_type='incoming', relabel_by='usage')

Compute directional syllable transition entropy. Based on whether the given transition_type is ‘incoming’ or or ‘outgoing’.

Args: labels (list or np.ndarray): a list of label arrays, where each entry in the list is an array of labels for one session. tm_smoothing (float): a constant as pseudocount added to label transtition counts before normalization. truncate_syllable (int): maximum number of relabeled syllable to keep for this calculation transition_type (str): can be either “incoming” or “outgoing” to compute the entropy of each incoming or outgoing syllable transition. relabel_by (str): how to re-order labels. Options are: ‘usage’, ‘frames’, or None.

Returns: entropies (list of np.ndarra): a list of transition entropies (either incoming or outgoing) for each session and syllable.