bycycle

Cycle-by-cycle analysis of neural oscillations.

https://github.com/bycycle-tools/bycycle

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    5 of 16 committers (31.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.1%) to scientific vocabulary

Keywords from Contributors

eeg meg ecog neuroscience electrophysiology lfp local-field-potential oscillations power-spectral-density meta-analysis
Last synced: 6 months ago · JSON representation ·

Repository

Cycle-by-cycle analysis of neural oscillations.

Basic Info
Statistics
  • Stars: 87
  • Watchers: 8
  • Forks: 24
  • Open Issues: 8
  • Releases: 10
Created over 7 years ago · Last pushed 9 months ago
Metadata Files
Readme Contributing License Code of conduct Citation

README.rst

========================================================
bycycle - cycle-by-cycle analysis of neural oscillations
========================================================

|ProjectStatus| |Version| |BuildStatus| |Coverage| |License| |PythonVersions| |Publication|

.. |ProjectStatus| image:: https://www.repostatus.org/badges/latest/active.svg
   :target: https://www.repostatus.org/#active
   :alt: project status

.. |Version| image:: https://img.shields.io/pypi/v/bycycle.svg
   :target: https://pypi.org/project/bycycle/
   :alt: version

.. |BuildStatus| image:: https://github.com/bycycle-tools/bycycle/actions/workflows/build.yml/badge.svg
   :target: https://github.com/bycycle-tools/bycycle/actions/workflows/build.yml
   :alt: build status

.. |Coverage| image:: https://codecov.io/gh/bycycle-tools/bycycle/branch/main/graph/badge.svg
   :target: https://codecov.io/gh/bycycle-tools/bycycle
   :alt: coverage

.. |License| image:: https://img.shields.io/pypi/l/bycycle.svg
   :target: https://opensource.org/license/apache-2-0
   :alt: license

.. |PythonVersions| image:: https://img.shields.io/pypi/pyversions/bycycle.svg
   :target: https://pypi.org/project/bycycle/
   :alt: python versions

.. |Publication| image:: https://img.shields.io/badge/publication-10.1152%2Fjn.00273.2019-blue.svg
   :target: https://journals.physiology.org/doi/abs/10.1152/jn.00273.2019
   :alt: publication

ByCycle is a module for analyzing neural oscillations in a cycle-by-cycle approach.

Overview
--------

``bycycle`` is a tool for quantifying features of neural oscillations in the time domain, as opposed to the
frequency domain, using a cycle-by-cycle approach. Rather than applying narrowband filters and other methods
that use a sinusoidal basis, this approach segments a recording into individual cycles and directly measures
each of their properties including amplitude, period, and symmetry.

This is most advantageous for analyzing the waveform shape properties of neural oscillations.
It may also provide advantages for studying traditional amplitude and frequency effects, as well.
Using cycle properties can also be used for burst detection.

A full description of the method and approach is available in the paper below.

Documentation
-------------

Documentation for ``bycycle`` is available on the
`documentation site `_.

This documentation includes:

- `Tutorials `_:
  with a step-by-step guide through the approach and how to apply it
- `Examples `_:
  demonstrating an example analysis and use case
- `API list `_:
  which lists and describes all the code and functionality available in the module
- `Glossary `_:
  which defines key terms used in the module

Dependencies
------------

``bycycle`` is written in Python, and requires >= Python 3.7 to run.

It has the following dependencies:

- `neurodsp `_ >= 2.1.0
- `numpy `_ >= 1.18.5
- `scipy `_ >=  1.4.1
- `pandas `_ >= 0.25.3
- `matplotlib `_ >= 3.0.3

There are also optional dependencies, that offer extra functionality:

- `tqdm `_ is needed to print progress bars
- `pytest `_ is needed to run tests locally

Install
-------

The current major release is the 1.X.X series, which is a breaking change from the prior 0.X.X series.

Check the `changelog `_ for notes on updating to the new version.

**Stable Version**

To install the latest stable release, you can use pip:

.. code-block:: shell

    $ pip install bycycle

ByCycle can also be installed with conda, from the conda-forge channel:

.. code-block:: shell

    $ conda install -c conda-forge bycycle

**Development Version**

To get the latest, development version, you can get the code using git:

.. code-block:: shell

    $ git clone https://github.com/bycycle-tools/bycycle

To install this cloned copy, move into the directory you just cloned, and run:

.. code-block:: shell

    $ pip install .

**Editable Version**

To install an editable, development version, move into the directory you cloned and install with:

.. code-block:: shell

    $ pip install -e .

Reference
---------

If you use this code in your project, please cite:

::

    Cole SR & Voytek B (2019) Cycle-by-cycle analysis of neural oscillations. Journal of neurophysiology
    122(2), 849-861. DOI: 10.1152/jn.00273.2019

Direct Link: https://doi.org/10.1152/jn.00273.2019

Contribute
----------

This project welcomes and encourages contributions from the community!

To file bug reports and/or ask questions about this project, please use the
`Github issue tracker `_.

To see and get involved in discussions about the module, check out:

- the `issues board `_ for topics relating to code updates, bugs, and fixes
- the `development page `_ for discussion of potential major updates to the module

When interacting with this project, please use the
`contribution guidelines `_
and follow the
`code of conduct `_.

Quickstart
----------

The classes in ``bycycle`` are ``Bycycle``, which takes a time series and some
parameters as inputs, and returns a table of features for each cycle. ``BycycleGroup``
may be used when working with 2d and 3d signals.

For example, consider having a 1-dimensional numpy array, ``sig``, which is a neural signal time series
sampled at 1000 Hz (``fs``) with an alpha (8-12 Hz, ``f_range``) oscillation. We can compute the table
of cycle features with the following:

.. code-block:: python

    from neurodsp.sim import sim_bursty_oscillation
    from bycycle import Bycycle

    # Simulate
    fs = 1000

    f_range = (8, 12)

    sig = sim_bursty_oscillation(10, fs, freq=10)

    # Fit
    bm = Bycycle()

    bm.fit(sig, fs, f_range)

    bm.df_features


The above example used default parameters to localize extrema and detect
bursts of oscillations. However, it is important to knowledgeably select these parameters, as described in the
`algorithm tutorial `_.

The following example introduces some potential parameter changes:

.. code-block:: python

    thresholds = {
        'amp_fraction_threshold': .2,
        'amp_consistency_threshold': .5,
        'period_consistency_threshold': .5,
        'monotonicity_threshold': .8,
        'min_n_cycles': 3
    }

    narrowband_kwargs = {'n_seconds': .5}

    bm = Bycycle(
        center_extrema='trough',
        burst_method='cycles',
        thresholds=thresholds,
        find_extrema_kwargs={'filter_kwargs': narrowband_kwargs}
    )

    bm.fit(sig, fs, f_range)


- **center_extrema** determines how the cycles are segmented. 'T' indicates the center extrema is \
  a trough, so cycles are segmented peak-to-peak.
- **burst_method** selects which method to use for burst detection. The 'cycles' option \
  uses features of adjacent cycles in order to detect bursts (e.g. period consistency, see next \
  item). The 'amp' option uses an amplitude threshold to determine the cycles that are part of an \
  oscillatory burst.
- **thresholds** sets the keyword arguments for the burst detection functions. For the \
  ``cycles`` method, there are 5 keyword arguments (see the end of the \
  `algorithm tutorial `_ \
  for advice on choosing these parameters).
- **find_extrema_kwargs** sets the keyword arguments for the function used to localize peaks and \
  troughs. Most notably, you can change the duration of the bandpass filter (``n_seconds``) used \
  during extrema localization (see section 1 of the \
  `algorithm tutorial `_)

DataFrame Output
~~~~~~~~~~~~~~~~

The output of ``bycycle`` is a ``pandas.DataFrame``, which is a table, as shown below.
There are many columns, so the table is split into two images here.

Each row of this table corresponds to an individual segment of the signal, or a putative cycle of
the rhythm of interest.

.. image:: https://raw.githubusercontent.com/bycycle-tools/bycycle/main/doc/img/cycledf_1.png

|

.. image:: https://raw.githubusercontent.com/bycycle-tools/bycycle/main/doc/img/cycledf_2.png

Columns include:

- **sample_peak**: the sample of the signal at which the peak of this cycle occurs
- **period**: period of the cycle
- **time_peak**: duration of the peak period
- **volt_amp**: amplitude of this cycle, average of the rise and decay voltage
- **time_rdsym**: rise-decay symmetry, the fraction of the cycle in the rise period (0.5 is symmetric)
- **time_ptsym**: peak-trough symmetry, the fraction of the cycle in the peak period (0.5 is symmetric)
- **period_consistency**: consistency between the periods of the adjacent cycles, used in burst detection
- **is_burst**: indicator if the cycle is part of an oscillatory burst

The features in this table can be further analyzed, as demonstrated in the
`resting state data tutorial `_
and the `data example `_.
For example, we may be interested in the distribution of rise-decay symmetry values in a resting state recording, shown below.

Burst Detection Results
~~~~~~~~~~~~~~~~~~~~~~~

.. image:: https://raw.githubusercontent.com/bycycle-tools/bycycle/main/doc/img/bursts_detected.png

Funding
-------

Supported by NIH award R01 GM134363 from the
`NIGMS `_.

.. image:: https://www.nih.gov/sites/all/themes/nih/images/nih-logo-color.png
  :width: 400

|

Owner

  • Name: ByCycle
  • Login: bycycle-tools
  • Kind: organization

Cycle-by-Cycle analyses of neural oscillations.

Citation (CITATION.cff)

cff-version: 1.2.0
message: >-
  If you use this software, please cite it using the metadata from this file.
type: software
title: 'bycycle: cycle-by-cycle analysis of neural oscillations'
authors:
- given-names: 'Ryan'
  family-names: 'Hammonds'
  orcid: 'https://orcid.org/0000-0002-5032-3241'
- given-names: 'Scott'
  family-names: 'Cole'
  orcid: 'https://orcid.org/0000-0002-6168-9951'
- given-names: 'Thomas'
  family-names: 'Donoghue'
  orcid: 'https://orcid.org/0000-0001-5911-0472'
- given-names: 'Bradley'
  family-names: 'Voytek'
  orcid: 'https://orcid.org/0000-0003-1640-2525'
repository-code: 'https://github.com/bycycle-tools/bycycle'
url: 'https://bycycle-tools.github.io/'
license: Apache-2.0
preferred-citation:
  type: article
  authors:
  - given-names: 'Scott'
    family-names: 'Cole'
    orcid: 'https://orcid.org/0000-0002-6168-9951'
  - family-names: 'Voytek'
    given-names: 'Bradley'
    orcid: 'https://orcid.org/0000-0003-1640-2525'
  title: 'Cycle-by-cycle analysis of neural oscillations'
  doi: '10.1152/JN.00273.2019'
  journal: 'Journal of Neurophysiology'
  month: 8
  year: 2019
  volume: 122
  issue: 2
  start: 849
  end: 861

GitHub Events

Total
  • Create event: 5
  • Release event: 1
  • Issues event: 3
  • Watch event: 6
  • Delete event: 7
  • Issue comment event: 17
  • Push event: 20
  • Pull request review event: 1
  • Pull request event: 13
  • Fork event: 2
Last Year
  • Create event: 5
  • Release event: 1
  • Issues event: 3
  • Watch event: 6
  • Delete event: 7
  • Issue comment event: 17
  • Push event: 20
  • Pull request review event: 1
  • Pull request event: 13
  • Fork event: 2

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 424
  • Total Committers: 16
  • Avg Commits per committer: 26.5
  • Development Distribution Score (DDS): 0.533
Past Year
  • Commits: 32
  • Committers: 7
  • Avg Commits per committer: 4.571
  • Development Distribution Score (DDS): 0.531
Top Committers
Name Email Commits
ryanhammonds r****s@u****u 198
Scott Cole s****0@g****m 100
TomDonoghue t****e@u****u 34
ryanhammonds R****s@u****u 33
Tom Donoghue t****h@g****m 25
ryanhammonds r****s@u****u 15
McGregor Joyner m****r@g****m 5
Alex a****6@g****m 5
ryanhammonds r****s@g****m 2
Michael m****n@u****u 1
Bradley Voytek b****k@g****m 1
Andrew Bender a****0@g****m 1
Nick Tolley n****y@g****m 1
Sydney s****8@g****m 1
Joshua Adelman s****s 1
Natalie n****r 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 43
  • Total pull requests: 89
  • Average time to close issues: 7 months
  • Average time to close pull requests: 3 months
  • Total issue authors: 20
  • Total pull request authors: 11
  • Average comments per issue: 2.16
  • Average comments per pull request: 1.78
  • Merged pull requests: 76
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 12
  • Average time to close issues: N/A
  • Average time to close pull requests: 20 days
  • Issue authors: 1
  • Pull request authors: 4
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.83
  • Merged pull requests: 10
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ryanhammonds (12)
  • TomDonoghue (7)
  • rahul-jayaram1 (3)
  • nschawor (2)
  • srcole (2)
  • davidglitvin (2)
  • apoorva6262 (2)
  • ShuangquanFeng (1)
  • ethanrich (1)
  • ntolley (1)
  • iinnpp (1)
  • benzimidazole (1)
  • dillancellier (1)
  • mcgsjoyner (1)
  • melissafasol (1)
Pull Request Authors
  • ryanhammonds (51)
  • TomDonoghue (23)
  • kguarian (4)
  • srcole (2)
  • mzabolocki (2)
  • drpedapati (2)
  • synapticarbors (1)
  • mcgsjoyner (1)
  • bcmartinb (1)
  • alexrockhill (1)
Top Labels
Issue Labels
1.0.0 (7) 0.1.3 (4) question (3) documentation (2) enhancement (1) bug (1)
Pull Request Labels
1.0.0 (6) documentation (1)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 396 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 2
    (may contain duplicates)
  • Total versions: 12
  • Total maintainers: 2
pypi.org: bycycle

Cycle-by-cycle analyses of neural oscillations.

  • Versions: 10
  • Dependent Packages: 0
  • Dependent Repositories: 2
  • Downloads: 396 Last month
Rankings
Stargazers count: 8.0%
Forks count: 8.4%
Dependent packages count: 10.1%
Average: 10.6%
Dependent repos count: 11.5%
Downloads: 15.1%
Maintainers (2)
Last synced: 7 months ago
conda-forge.org: bycycle
  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 34.0%
Stargazers count: 35.0%
Forks count: 36.7%
Average: 39.2%
Dependent packages count: 51.2%
Last synced: 7 months ago

Dependencies

optional-requirements.txt pypi
  • tqdm *
requirements-docs.txt pypi
  • mne *
  • neurodsp >=2.0.0
  • numpydoc *
  • pactools *
  • pillow *
  • scikit-learn *
  • seaborn *
  • sphinx *
  • sphinx-copybutton *
  • sphinx-gallery *
  • sphinx_bootstrap_theme *
requirements.txt pypi
  • matplotlib >=3.0.3
  • numpy >=1.18.5
  • pandas >=0.25.3
  • scipy >=1.4.1
setup.py pypi
  • req *
.github/workflows/build.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • codecov/codecov-action v3 composite