Contents
We are open to many types of contributions, from bugfixes to functionality enhancements. mne-python is meant to be maintained by a community of labs, and as such, we seek enhancements that will likely benefit a large proportion of the users who use the package.
Before starting new code, we highly recommend opening an issue on mne-python GitHub to discuss potential changes. Getting on the same page as the maintainers about changes or enhancements before too much coding is done saves everyone time and effort!
Standard python style guidelines set by pep8 and pyflakes are followed with very few exceptions. We recommend using an editor that calls out style violations automatcally, such as Spyder. From the MNE code root, you can check for violations using flake8 with:
$ make flake
Use numpy style for docstrings. Follow existing examples for simplest guidance.
New functionality must be covered by tests. For example, a
mne.Evoked
method in mne/evoked.py
should have a corresponding
test in mne/tests/test_evoked.py
.
Changes must be accompanied by updated documentation, including doc/whats_new.rst and doc/python_reference.rst.
After making changes, ensure all tests pass. This can be done by running:
$ make test
To run individual tests, you can also run e.g.:
$ nosetests mne/tests/test_evoked:test_io_evoked -x --verbose
Make sure you have the testing dataset, which you can get by doing:
>>> mne.datasets.testing.data_path(verbose=True)
These are guidelines that are generally followed:
nosetests --with-timer
on modified tests.doc/whats_new.rst
file last, just before merge to avoid merge conflicts.numpy as np
, scipy
submodules)
3. others
4. mne imports (relative within the MNE module, absolute in the examples)matplotlib
and optional modules (sklearn
, and pandas
, etc.) within the MNE module should be nested (i.e., within a function or method, not at the top of a file).mne.viz
package and use these in the corresponding methods.show
parameter and return a fig
handle.RdBu_r
colormap for signed data with a meaningful middle (zero-point) and Reds
otherwise in visualization functions and examples.self
, functions should return copies (where applicable).filter
, map
and other functional idioms.list()
, dict
).**kwargs
and *args
in function signatures.All changes to the codebase must be properly documented. To ensure that documentation is rendered correctly, the best bet is to follow the existing examples for class and function docstrings, and examples and tutorials.
Our documentation (including docstring in code) uses ReStructuredText format, see Sphinx documentation to learn more about editing them. Our code follows the NumPy docstring standard.
Documentation is automatically built remotely during pull requests. If
you want to also test documentation locally, you will need to install
sphinx sphinx-gallery sphinx_bootstrap_theme numpydoc
, and then within
the mne/doc
directory do:
$ make html_dev-noplot
If you are working on examples or tutorials, you can build specific examples with:
$ PATTERN=plot_background_filtering.py make html_dev-pattern
Consult the sphinx gallery documentation for more details.
To learn more about profiling python codes please see the scikit learn profiling site.
Changes to code can be submitted using a standard GitHub Pull Request, as documented in Using GitHub to make a Pull Request.