pycrostates.segmentation.compute_expected_transition_matrix#

pycrostates.segmentation.compute_expected_transition_matrix(labels, n_clusters, stat='probability', ignore_repetitions=True)[source]#

Compute the expected transition matrix.

Compute the theoretical transition matrix as if time course was ignored, but microstate proportions was kept (i.e. shuffled segmentation). This matrix can be used to quantify/correct the effect of microstate time coverage on the observed transition matrix obtained with the pycrostates.segmentation.compute_transition_matrix(). Transition “from” and “to” unlabeled segments -1 are ignored.

Parameters:
labelsarray of shape (n_samples,) or (n_epochs, n_samples)

Microstates labels attributed to each sample, i.e. the segmentation.

n_clustersint

The number of clusters, i.e. the number of microstates.

statstr

Aggregate statistic to compute transitions. Can be:

  • probability or proportion: normalize count such as the probabilities along the first axis is always equal to 1.

  • percent: normalize count such as the probabilities along the first axis is always equal to 100.

ignore_repetitionsbool

If True, ignores state repetitions. For example, the input sequence AAABBCCD will be transformed into ABCD before any calculation. This is equivalent to setting the duration of all states to 1 sample.

Returns:
Tarray of shape (n_cluster, n_cluster)

Array of transition probability values from one label to another. First axis indicates state "from". Second axis indicates state "to".