yasa.SpindlesResults.compare_channels#

SpindlesResults.compare_channels(score='f1', max_distance_sec=0)[source]#

Compare detected spindles across channels.

This is a wrapper around the yasa.compare_detection function. Please refer to the documentation of this function for more details.

Parameters:
scorestr

The performance metric to compute. Accepted values are “precision”, “recall” (aka sensitivity) and “f1” (default). The F1-score is the harmonic mean of precision and recall, and is usually the preferred metric to evaluate the agreement between two channels. All three metrics are bounded by 0 and 1, where 1 indicates perfect agreement.

max_distance_secfloat

The maximum distance between spindles, in seconds, to consider as the same event.

Warning

To reduce computation cost, YASA rounds the start time of each spindle to the nearest decisecond (= 100 ms). This means that the lowest possible resolution is 100 ms, regardless of the sampling frequency of the data. Two spindles starting at 500 ms and 540 ms on their respective channels will therefore always be considered the same event, even when max_distance_sec=0.

Returns:
scorespandas.DataFrame

A Pandas DataFrame with the output scores, of shape (n_chan, n_chan).

Notes

Some use cases of this function:

  1. What proportion of spindles detected in one channel are also detected on another channel (if using score="recall").

  2. What is the overall agreement in the detected events between channels?

  3. Is the agreement better in channels that are close to one another?