Jupyter notebooks in neurophysiology

The computer age has seen many advances in science, including how scientists analyse data and report results. While some tools are complex and make it difficult for other scientists to understand exactly what steps were followed, other tools strive to increase the transparency and reproducibility of research.

iPython and Jupyter notebooks

A new and exciting tool is the electronic notebook. Notebooks were introduced by the folks that brought us IPython, an interactive Python interpreter with additional built-in functionality to facilitate scientific computing. Notebooks provide a way to document your project and analysis, and intersperse these notes with actual computer code. The beauty of notebooks is that they are a living document that can be shared, executed and modified.

If you have never seen an IPython electronic notebook before, have a look at this example on Matplotlib. Note how text and descriptions are interspersed between snippets of code and output figures. This approach to data analysis is appealing because it can shared with collaborators that are not familiar with Python. The text describes the logic and the figures show the result. If the code is well written and well documented, even a non-coder should be able to follow the logic of the code. To get a better idea of what notebooks are capable of, have a look at these examples on the three body problem (cool embedded videos!), statistical graphs in Matplotlib and a Python crash course for scientists.

Notebooks have become so popular the IPython notebook has branched into its own project, called Jupyter notebook. Jupyter notebooks provide a unified scientific computing platform since they can be used to run code from over 40 different programming languages, including Julia, Python and R (hence the name).

Notebooks for neurophysiology research

Rosenberg and Horn recently published a paper in the Journal of Neurophysiology on the use of free and open-source software as part of a scientific workflow. The paper discusses many of the most important tools and programming languages and provides a worked example of how these tools can be used to analyse and report neurophysiological data.

The paper is well written and does not assume any prior knowledge of notebooks or programming. The Github page associated with the paper provides all the data, code and notebooks used in the paper. These notebooks contain wonderful examples, and include some pretty neat tricks, including embedding a web page into notebooks and calling R statistical functions from within Python.

My only concern with this paper is that the more advanced scientific examples, those that analyse real neurophysiolgical data, are difficult to get working. While it is possible to view the notebooks, you have to ensure you have all the correct Python packages installed if you actually want to re-run the code yourself. Despite having experience with Python and IPython notebooks, I was not able to properly install the OpenElectrophy 0.3.4 package. This package had dependencies, and installing the package through Conda or Pip (two tools that make installing Python packages much easier) did not work. Hopefully others don’t have the same difficulty as me getting this package to work, because there is nothing more effective to deter a newcomer than to have a bad first experience.

The paper by Rosenberg and Horn is an example of the new approach some scientists are using to ensure their research is reproducible and transparent. Notebooks have been used in other scientific fields for many years, and it is great to see that they are now officially part of the neurophysiolgist’s toolbox!

Reference

Rosenberg DM, Horn CC (2016). Neurophysiological analytics for all! Free open-source software tools for documenting, analyzing, visualizing, and sharing using electronic notebooks. J Neurophysiol. Apr 20:jn.00137.2016. doi: 10.1152/jn.00137.2016.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s