Skip to content

Commit 9353581

Browse files
committed
Merge branch 'main' into filter_report
2 parents 993893c + ea27979 commit 9353581

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3583
-1022
lines changed

.github/workflows/build.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow runs CI tests: it installs Python dependencies and run tests across a variety of Python versions
2+
3+
name: build
4+
5+
on:
6+
push:
7+
branches: [ main ]
8+
pull_request:
9+
branches: [ main ]
10+
11+
jobs:
12+
build:
13+
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version: [3.6, 3.7, 3.8, 3.9]
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install pytest
29+
pip install pytest-cov
30+
pip install -r requirements.txt
31+
- name: Test with pytest
32+
run: |
33+
pytest --cov=./
34+
- name: Upload coverage to Codecov
35+
uses: codecov/codecov-action@v1

.travis.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 107 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,131 @@
11
# Contributing Guidelines
22

3-
Thank you for your interest in contributing to NeuroDSP!
3+
Thank you for your interest in contributing to `neurodsp`!
44

5-
We welcome contributions to the project that extend or improve code and/or documentation
6-
in the module!
5+
We welcome all contributions to the project that extend or improve code and/or documentation!
76

8-
Note that contributors to NeuroDSP are expected to follow the
9-
[Code of Conduct](https://github.com/neurodsp-tools/neurodsp/blob/master/CODE_OF_CONDUCT.md).
7+
This page includes information for how to get involved and contribute to the project, and guidelines for how to do so.
108

11-
## How to Contribute
9+
This project adheres to a
10+
[code of conduct](https://github.com/neurodsp-tools/neurodsp/blob/main/CODE_OF_CONDUCT.md)
11+
that you are expected to uphold when participating in this project.
1212

13-
If you are interested in getting involved in helping with and maintaining `NeuroDSP`, the best place to start is on the [issues](https://github.com/neurodsp-tools/neurodsp/issues) board. Check through if there are any open issues that you might be able to contribute to!
13+
On this page, you can find information on:
1414

15-
If you have a new idea you would like to contribute to NeuroDSP, please do the following:
15+
* [Reporting a problem](#reporting-a-problem)
16+
* [Getting involved in the project](#getting-involved)
17+
* [Project scope](#project-scope)
18+
* [Making a contribution](#making-a-contribution)
19+
* [Project conventions](#project-conventions)
1620

17-
1. Check that your idea is in scope for the project (as discussed below)
18-
2. Open an [issue](https://github.com/neurodsp-tools/neurodsp/issues) in the repository suggesting and describing your idea
19-
3. Get feedback from project maintainers, and coordinate a plan for the contribution
20-
4. Make the contribution (as described below)
21+
## Reporting a problem
2122

22-
To contribute a fix, or add an update of the repository, do the following:
23+
To report an issue with the code, please submit it to our [issue tracker](https://github.com/neurodsp-tools/neurodsp/issues).
2324

24-
1. Make a fork of the NeuroDSP repository
25-
2. Update the fork of the repository with any updates and/or additions to the project
26-
3. Check that any additions to the project follow the conventions (described below)
27-
4. Make a pull request from your fork to the `NeuroDSP` repository
28-
5. Address any feedback and/or recommendations from reviewers, until the contribution is ready to be merged
25+
In doing so, please try to include the following:
2926

30-
## Scope
27+
1. A short, top-level summary of the issue (usually 1-2 sentences)
28+
2. A short, self-contained code snippet to reproduce the issue, ideally allowing a simple copy and paste to reproduce
29+
- Please do your best to reduce the code snippet to the minimum required
30+
3. The actual outcome of the code snippet
31+
4. The expected outcome of the code snippet
3132

32-
All contributions to `NeuroDSP` must be within the scope of the module.
33+
## Getting Involved
3334

34-
The scope of `NeuroDSP` is digital signal processing approaches for neural data, that operate on neural time series. Within this scope, the goal of the module is to provide a collection of useful analyses approaches. These analyses should be agnostic to specific data modalities, and particularities of how the data is organized. Code and utilities that focused on data management are considered out of scope.
35+
We welcome all kinds of contributions to the project, including suggested features and help with documentation, maintenance, and updates.
3536

36-
## Conventions
37+
If you have a new idea you would like to suggest or contribute, please do the following:
38+
39+
1. Check if the idea is already being discussed on the
40+
[issues](https://github.com/neurodsp-tools/neurodsp/issues) or
41+
[development](https://github.com/neurodsp-tools/Development) page
42+
2. Check that your idea is within the [project scope](#project-scope)
43+
3. Open an [issue](https://github.com/neurodsp-tools/neurodsp/issues) describing
44+
what you would like to see added / changed, and why
45+
4. Indicate in the issue if the idea is something you would be willing to help implement
46+
- if so, project maintainers can give feedback to help make a plan for the contribution
47+
5. If you want to work on the contribution, follow the [contribution guidelines](#making-a-contribution) to do so
48+
49+
If you are interested in getting involved and helping with the project, a great place to start is to visit the
50+
[issues](https://github.com/neurodsp-tools/neurodsp/issues) or
51+
[development](https://github.com/neurodsp-tools/Development) page
52+
and see if there is anything you would be interested in helping with. If so, join the conversation, and project developers can help get you started.
53+
54+
## Project Scope
55+
56+
All contributions must be within the scope of the module.
57+
58+
`neurodsp` is a module that collects digital signal processing approaches for neural data that operate on neural time series. This includes filtering, spectral estimation, time-frequency analyses, and more. The majority of the methods operate on single time-series, though multivariate approaches may be added on a case-by-case basis.
59+
60+
This module collects analyses that are broadly agnostic to specific recording modalities, and particularities of how the data is organized, operating on arrays of time-series. Code and utilities that focused on data management are considered out of scope. Algorithms and topics that are already available and well-supported in other Python toolboxes will typically not be added here.
61+
62+
## Making a Contribution
63+
64+
If there is a feature you would like to add, or an issue you saw that you think you can help with, you are ready to make a submission to the project!
65+
66+
If you are working on a feature, please indicate so in the relevant issue, so that we can keep track of who is working on what.
67+
68+
Once you're ready to start working on your contribution, do the following:
69+
70+
1. [Fork this repository](https://help.github.com/articles/fork-a-repo/), which makes your own version of this project you can edit
71+
2. [Make your changes](https://guides.github.com/activities/forking/#making-changes), updating or adding code to add the desired functionality
72+
3. [Check the project conventions](#project-conventions), and make sure all new or updated code follows the guidelines
73+
4. [Submit a pull request](https://help.github.com/articles/proposing-changes-to-a-project-with-pull-requests/), to start the process of merging the new code to the main branch
74+
75+
If it's your first time contributing to open source software, check out this free resource on [how to contribute to an open-source project on GitHub](https://app.egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github).
76+
77+
## Project Conventions
3778

3879
All code contributed to the module should follow these conventions:
3980

4081
1. Code Requirements
41-
* All code should be written in Python 3.5+
42-
* Adding new dependencies is discouraged, if it can be avoided.
43-
* If any more dependencies are required, they must be added to the `requirements.txt` file.
82+
* All code should be written in Python, and run on the minimum required version that is noted in the README
83+
* New dependencies should be avoided if possible, especially if they are not in the Anaconda distribution
84+
* If any new dependencies are needed, they should be added to the `requirements.txt` file
4485

4586
2. Code Style
46-
* Code should follow the [PEP8](https://www.python.org/dev/peps/pep-0008/) style guide
47-
* Docstrings for public functions should be in
48-
[Numpy docs](https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt) format.
49-
At minimum, there should be a sentence describing what the function does and a list of
50-
parameters and returns.
51-
* If you can, add an `Examples` section in the docstring, demonstrating use, that can be run with doctest
52-
* Private functions should be indicated with a leading underscore, and should still include a
53-
docstrings including at least a sentence describing what the function does.
54-
* Use standard casing:
55-
* Function names in snake_case (all lowercase with underscores)
56-
* Class names are in CamelCase (leading capitals with no separation)
87+
* Code should generally follow [PEP8](https://www.python.org/dev/peps/pep-0008/) style guidelines
88+
* Max line length is 100 characters
89+
* Merge candidates will be checked using [pylint](https://www.pylint.org)
5790

5891
3. API & Naming Conventions
59-
* The API should be kept consistent within NeuroDSP, using standard naming and parameter ordering, for example:
92+
* Try to keep the API consistent with existing code in terms of parameter names and ordering
93+
* Standard naming and parameter ordering in NeuroDSP include:
6094
* `sig` is commonly the first input, representing the neural time series
6195
* `fs` is commonly the second input, representing the sampling rate
62-
* Variables named 'f_...' refer to frequencies (e.g. 'f_range' is a bandpass filter's cutoff frequencies)
63-
* If code is calling and using external implementations, for example, `scipy.signal`, naming and input ordering, as described in NeuroDSP, should be consistent with the external functions that are being used
64-
65-
4. Tests
66-
* All code within NeuroDSP requires test code that executes that code
67-
* These tests, at a minimum, must be 'smoke tests' that execute the
68-
code and check that it runs through, without erroring out, and returning appropriate variables.
69-
* If possible, including more explicit test code that checks more stringently for accuracy is encouraged,
70-
but not strictly required.
71-
* Before a pull request is merged, code coverage must demonstrate that new code is tested,
72-
and continuous integration checks running this test code must all pass
73-
74-
5. Module Documentation
75-
* Any public facing code updates should included relevant updates to the [documentation site](https://neurodsp-tools.github.io/neurodsp/)
76-
* If you add any new public functions, note this function in the doc/api.rst file,
77-
so that this function gets included in the documentation site API listing
78-
* If a new public function is added, it should should be added and described in the relevant tutorials section, with a quick description and demonstration of using it
96+
* variables named 'f_...' refer to frequencies (e.g. 'f_range' is a bandpass filter's cutoff frequencies)
97+
* Use standard casing, for example:
98+
* function names should be in snake_case (all lowercase with underscores)
99+
* class names should be in CamelCase (leading capitals with no separation)
100+
* If passing through arguments to an external function, the naming and ordering of parameters in this module should generally follow that of the external function
101+
102+
4. Code Documentation
103+
* All code should be documented, including in-code comments describing procedures, and detailed docstrings
104+
* Docstrings should follow the [numpy docs](https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard) format
105+
* At minimum, there should be a sentence describing what the function does and a list of parameters and returns
106+
* Private functions should be indicated with a leading underscore, and should still include a docstring including at least a sentence describing what the function does
107+
* If possible, add an `Examples` section to the docstrings, that demonstrates a simple use case
108+
* If so, these examples should be executable, using [doctest](https://docs.python.org/3/library/doctest.html)
109+
* If examples cannot be run, use the SKIP directive
110+
111+
5. Code Tests
112+
* This project uses the [pytest](https://docs.pytest.org/en/latest/) testing tool for testing module code
113+
* All new code requires test code, written as unit tests that check each function and class in the module
114+
* Tests should be, at a minimum, 'smoke tests' that execute the code and check that it runs without raising an error
115+
* Where possible, accuracy checking is encouraged, though not strictly required
116+
* Merge candidates must pass all existing tests, and add new tests such as to not reduce test coverage
117+
* To run the tests locally, pytest needs to be installed (`pip install pytest`)
118+
* To run the tests on a local copy of the module, move into the folder and run `pytest .`
119+
120+
6. Documentation Website
121+
* This project uses a documentation website, created using [sphinx](https://www.sphinx-doc.org/)
122+
* Any new public functions or classes should be added to the `doc/api.rst` file, so they get included in the API list
123+
* Any new functionality should be added and described in the tutorials and/or examples
124+
* If a new approach is added, a new tutorial or example may be appropriate
125+
* To build and check the documentation locally:
126+
* Install the requirements for the docsite (`pip install -r requirements-doc.txt`)
127+
* Move to the `neurodsp/doc` directory (`cd doc`)
128+
* Run `make html` to create a local copy of the documentation website
129+
* The documentation can then be opened in a web browser by opening the file `neurodsp/doc/_build/html/index.html`
130+
131+
For more guidelines on how to write well formated and organized code, check out the [Python API Checklist](http://python.apichecklist.com).

README.rst

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
.. |Version| image:: https://img.shields.io/pypi/v/neurodsp.svg
1111
.. _Version: https://pypi.python.org/pypi/neurodsp/
1212

13-
.. |BuildStatus| image:: https://travis-ci.com/neurodsp-tools/neurodsp.svg
14-
.. _BuildStatus: https://travis-ci.com/github/neurodsp-tools/neurodsp
13+
.. |BuildStatus| image:: https://github.com/neurodsp-tools/neurodsp/actions/workflows/build.yml/badge.svg
14+
.. _BuildStatus: https://github.com/neurodsp-tools/neurodsp/actions/workflows/build.yml
1515

16-
.. |Coverage| image:: https://codecov.io/gh/neurodsp-tools/neurodsp/branch/master/graph/badge.svg
16+
.. |Coverage| image:: https://codecov.io/gh/neurodsp-tools/neurodsp/branch/main/graph/badge.svg
1717
.. _Coverage: https://codecov.io/gh/neurodsp-tools/neurodsp
1818

1919
.. |License| image:: https://img.shields.io/pypi/l/neurodsp.svg
@@ -27,6 +27,21 @@
2727

2828
Tools to analyze and simulate neural time series, using digital signal processing.
2929

30+
Overview
31+
--------
32+
33+
`neurodsp` is a collection of approaches for applying digital signal processing to neural time series, including algorithms that have been proposed for the analysis of neural time series. It also includes simulation tools for generating plausible simulations of neural time series.
34+
35+
Available modules in ``NeuroDSP`` include:
36+
37+
- ``filt`` : Filter data with bandpass, highpass, lowpass, or notch filters
38+
- ``burst`` : Detect bursting oscillations in neural signals
39+
- ``rhythm`` : Find and analyze rhythmic and recurrent patterns in time series
40+
- ``spectral`` : Compute spectral domain features such as power spectra
41+
- ``timefrequency`` : Estimate instantaneous measures of oscillatory activity
42+
- ``sim`` : Simulate time series, including periodic and aperiodic signal components
43+
- ``plts`` : Plotting functions
44+
3045
Documentation
3146
-------------
3247

@@ -45,7 +60,7 @@ open an `issue <https://github.com/neurodsp-tools/neurodsp/issues>`_ and ask!
4560
Dependencies
4661
------------
4762

48-
``NeuroDSP`` is written in Python, and requires Python >= 3.5 to run.
63+
``NeuroDSP`` is written in Python, and requires Python >= 3.6 to run.
4964

5065
It has the following dependencies:
5166

@@ -102,36 +117,23 @@ To install an editable version, download the development version as above, and r
102117
103118
$ pip install -e .
104119
105-
Please use the
106-
`Github issue tracker <https://github.com/neurodsp-tools/neurodsp/issues>`_
107-
to file bug reports and/or ask questions about this project.
108-
109-
Modules
110-
-------
111-
112-
Available modules in ``NeuroDSP`` include:
113-
114-
- ``filt`` : Filter data with bandpass, highpass, lowpass, or notch filters
115-
- ``burst`` : Detect bursting oscillations in neural signals
116-
- ``rhythm`` : Find and analyze rhythmic and recurrent patterns in time series
117-
- ``spectral`` : Compute spectral domain features such as power spectra
118-
- ``timefrequency`` : Estimate instantaneous measures of oscillatory activity
119-
- ``sim`` : Simulate time series, including periodic and aperiodic signal components
120-
- ``plts`` : Plotting functions
121-
122120
Contribute
123121
----------
124122

125-
``NeuroDSP`` welcomes and encourages contributions from the community!
123+
This project welcomes and encourages contributions from the community!
126124

127-
If you have an idea of something to add to NeuroDSP, please start by opening an
128-
`issue <https://github.com/neurodsp-tools/neurodsp/issues>`_.
125+
To file bug reports and/or ask questions about this project, please use the
126+
`Github issue tracker <https://github.com/neurodsp-tools/neurodsp/issues>`_.
129127

130-
When writing code to add to NeuroDSP, please follow the
131-
`Contribution Guidelines <https://github.com/neurodsp-tools/neurodsp/blob/master/CONTRIBUTING.md>`_.
128+
To see and get involved in discussions about the module, check out:
132129

133-
We also require that all contributors follow our
134-
`Code of Conduct <https://github.com/neurodsp-tools/neurodsp/blob/master/CODE_OF_CONDUCT.md>`_.
130+
- the `issues board <https://github.com/neurodsp-tools/neurodsp/issues>`_ for topics relating to code updates, bugs, and fixes
131+
- the `development page <https://github.com/neurodsp-tools/Development>`_ for discussion of potential major updates to the module
132+
133+
When interacting with this project, please use the
134+
`contribution guidelines <https://github.com/neurodsp-tools/fooof/blob/main/CONTRIBUTING.md>`_
135+
and follow the
136+
`code of conduct <https://github.com/neurodsp-tools/neurodsp/blob/main/CODE_OF_CONDUCT.md>`_.
135137

136138
Reference
137139
---------
@@ -165,9 +167,10 @@ Bibtex:
165167
Funding
166168
-------
167169

168-
Supported by NIH award R01 GM134363
169-
170-
`NIGMS <https://www.nigms.nih.gov/>`_
170+
Supported by NIH award R01 GM134363 from the
171+
`NIGMS <https://www.nigms.nih.gov/>`_.
171172

172173
.. image:: https://www.nih.gov/sites/all/themes/nih/images/nih-logo-color.png
173174
:width: 400
175+
176+
|

doc/api.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ Periodic Signals
214214

215215
sim_oscillation
216216
sim_bursty_oscillation
217+
sim_variable_oscillation
217218

218219
Aperiodic Signals
219220
~~~~~~~~~~~~~~~~~
@@ -324,3 +325,12 @@ Rhythm
324325

325326
plot_swm_pattern
326327
plot_lagged_coherence
328+
329+
Time Frequency
330+
~~~~~~~~~~~~~~
331+
332+
.. currentmodule:: neurodsp.plts
333+
.. autosummary::
334+
:toctree: generated/
335+
336+
plot_timefrequency

neurodsp/aperiodic/autocorr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def compute_autocorr(sig, max_lag=1000, lag_step=1, demean=True):
3131
sig = sig - sig.mean()
3232

3333
autocorrs = np.correlate(sig, sig, "full")[len(sig)-1:]
34-
autocorrs = autocorrs[:max_lag] / autocorrs[0]
34+
autocorrs = autocorrs[:max_lag+1] / autocorrs[0]
3535
autocorrs = autocorrs[::lag_step]
3636

37-
timepoints = np.arange(0, max_lag, lag_step)
37+
timepoints = np.arange(0, max_lag+1, lag_step)
3838

3939
return timepoints, autocorrs

0 commit comments

Comments
 (0)