bycycle-tools / bycycle

Cycle-by-cycle analysis of neural oscillations.
https://bycycle-tools.github.io/
Apache License 2.0
82 stars 21 forks source link

[ENH] Period and amplitude consistency mode #106

Closed ryanhammonds closed 2 years ago

ryanhammonds commented 3 years ago

This adds an optional parameter (consistency_mode) to change how consistency measures are determined. Previously, amplitude consistency was computed as np.min([consist_current, consist_next, consist_last]). The first cycle of a burst would always have a small consist_last (the last cycle would always have a small consist_next), results in potentially mislabeled first/last cycles per each burst.

A solution was merged in #90, which allowed lowering the consistency thresholds for the edges of bursts. This PR offers an alternative, which allows taking the mean or max of adjacent periods/amplitudes, in addition to the min.

I'd argue that setting consistency_mode == 'mean', is a better default in some cases. One potential downside of using mean consistency, however, is that the consistency of non-burst cycles next to bursts will be a inflated. I have left the default to the original 'min' for now.

codecov-commenter commented 3 years ago

Codecov Report

Merging #106 (9b941f0) into main (da8c9b7) will increase coverage by 0.83%. The diff coverage is 92.30%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #106      +/-   ##
==========================================
+ Coverage   96.27%   97.11%   +0.83%     
==========================================
  Files          23       29       +6     
  Lines         860     1385     +525     
==========================================
+ Hits          828     1345     +517     
- Misses         32       40       +8     
Impacted Files Coverage Δ
bycycle/features/features.py 96.42% <ø> (ø)
bycycle/features/burst.py 97.80% <90.90%> (+0.15%) :arrow_up:
bycycle/objs/fit.py 100.00% <100.00%> (ø)
bycycle/plts/burst.py 93.42% <0.00%> (-2.36%) :arrow_down:
bycycle/utils/dataframes.py 100.00% <0.00%> (ø)
bycycle/spikes/features/shape.py 100.00% <0.00%> (ø)
bycycle/spikes/objs.py 98.55% <0.00%> (ø)
bycycle/spikes/plts.py 100.00% <0.00%> (ø)
bycycle/spikes/utils.py 97.56% <0.00%> (ø)
bycycle/spikes/cyclepoints.py 100.00% <0.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update da8c9b7...9b941f0. Read the comment docs.