yasa.SpindlesResults.compare_channels#
- SpindlesResults.compare_channels(score='f1', max_distance_sec=0, *, method='distance', iou_threshold=0.2)[source]#
Compare detected spindles across channels.
This is a wrapper around the
yasa.compare_detectionfunction. 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. Only used with
method="distance".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.
- methodstr
How to match spindles.
"distance"(default) only compares their start times."intersection"compares their full extent, using both the start and end times without rounding. Seeyasa.compare_detectionfor details.- iou_thresholdfloat
Minimum overlap for two spindles to match with
method="intersection", measured as the intersection over union (default 0.2).
- Returns:
- scores
pandas.DataFrame A Pandas DataFrame with the output scores, of shape (n_chan, n_chan).
- scores
Notes
Some use cases of this function:
What proportion of spindles detected in one channel are also detected on another channel (if using
score="recall").What is the overall agreement in the detected events between channels?
Is the agreement better in channels that are close to one another?