In this blog, you can find tutorials for analyzing electrophysiological properties using Python and the software Clampfit (see full list here). In the end, you generally get tabular data with numerical results from which you can extract information. The following Jupyter notebooks show examples of how to explore, plot, and calculate stats from datasets in Python.
If you do not know how to clone the repository, you can simply copy the code as usual. Feel free to adapt the scripts to your needs. Email me if something is unclear or the code does not work as expected.
Contents
Example data
For these Jupyter notebooks, I use the brain cell database from the Allen Institute for Brain Science as an example dataset. You can also download the table directly from the Allen Brain Atlas website by clicking “Download Cell Feature Data.” This dataset contains electrophysiological and morphological data obtained from patch-clamp recordings in both mouse and human brains. These features were used to classify neurons into distinct subtypes (Figure 1), which is one of the main challenges in neuroscience because of the brain’s high cellular diversity.
Defining a cell type is not trivial (Zheng, 2022), and morphoelectrical features can be combined with transcriptomic data for a more integrative classification (Gouwens et al., 2020, Scala et al., 2021). The goal is to identify cell types with similar attributes and functions to understand neural networks and behaviors. For example, although inhibitory interneurons (Tremblay et al., 2016) are fewer than excitatory neurons in the cortex (about 20% vs. 80%), there are at least four major classes of inhibitory neurons with distinct intrinsic and functional properties: Pvalb, Vip, Sst, and Lamp5 (Figure 1b).

You can further explore the Allen Institute Cell Database using the interactive website or the Allen Software Development Kit (SDK). Through the Allen SDK, you can access all available electrophysiology measurements and morphological reconstructions.
- Cell Types Database. Example notebooks and documentation.
- Open Neuroscience Education. Excellent teaching resources created by Dr. Ashley Juavinett.
- Transgenic mouse lines. The Allen Institute for Brain Science used Cre mouse lines to identify genetically defined cell classes. Driver lines are used to target specific populations, while reporter lines are used to visualize (with fluorescent proteins) or manipulate (e.g., optogenetics) those populations.
Jupyter notebooks
Dataframes
This is a more general notebook that shows examples of how to explore tables with Pandas, plot data using Matplotlib and Seaborn, and do statistical tests using SciPy.
Honestly, I enjoy plotting and doing statistics more using GraphPad, since coding a similar plot in Python can be a painful experience. Unfortunately, GraphPad is a very expensive software. Fortunately, LLM applications can be of great help for fine-tuning plots in Python. R is also considered more user-friendly for statistical analysis, and it may be worth trying both, with the help of LLMs, to find the right tool for your analysis. Nevertheless, statistical analysis of patch-clamp data does not generally require complex models, and Python libraries such as SciPy and statsmodels do the job.
Estimation statistics
This notebook adapts code from the paper “Moving beyond P values: data analysis with estimation graphics” by Ho et al., 2019 (PDF). Ho et al. developed DABEST (‘data analysis with bootstrap-coupled estimation for calculating and plotting estimation statistics’). DABEST is an open-source library for Matlab, Python, and R, and is also available as a web application called estimationstats.
Ho and colleagues argue that estimation methods and plots can be a better (complementary, I would say) alternative to null hypothesis significance testing. In the case of plots, the figure below shows how to improve two-group data graphics from a bar plot (Figure 2a) to an estimation plot (Figure 2e).

Superplots and nested analysis
This Jupyter notebook shows how to make SuperPlots in Python using Matplotlib and Seaborn, adapting the tutorial by Lord et al., 2020.
In neuroscience, we have to consider both sample-to-sample (or individual-to-individual) differences and cell-to-cell variability in our experiments. What is n? This depends on the population you want to compare. In general, it is the number of independent experiments, unless you are specifically interested in cell-to-cell variability, as in patch-clamp experiments. One approach to communicate variability is to use “superplots” to show both summary statistics and the individual experiments within the dataset (Figure 3).

To analyze the clustered or nested data, one conservative approach is to use only the mean of each replicate. However, a nested analysis (or multilevel analysis) accounts for both the variability between and within clusters. Clustered data arise when the data in a study can be grouped into several units or clusters, such as cells nested within animals (Figure 4b). The notebook also shows how to use statsmodels for a nested ANOVA.

Resources
There are now many guidelines and tutorials focused on biology and neuroscience that help us to learn and improve our analyses. It is an ongoing process because journals have only started to standardize practices for reporting statistical information in the last few years (e.g., Nature journals).
- General
- An Updated Guide to Robust Statistical Methods in Neuroscience by Wilcox and Rousselet (2023). This is a comprehensive article that discusses methods and limitations for comparing groups and studying associations.
- Common statistical tests are linear models. Lindelov, 2019. Very interesting to get an understanding of how common statistical tests work.
- GraphPad User Guide. Clear explanations of the most common statistical analyses. I also find the book Intuitive Biostatistics by Motulsky very useful. Another short book I often check to learn or refresh basic concepts is Fundamental Statistical Principles for the Neurobiologist by Stephen W. Scheff (2016). Used copies of both books can be found for a relatively good price.
- Science Forum: Ten common statistical mistakes to watch out for when writing or reviewing a manuscript by Makin and Orban de Xirvy (2019). A short ‘checklist’ of common mistakes useful for both writing and reviewing.
- Python
- Learning Statistics with Python. Ethan Weed adapted for Python Danielle Navarro’s book Learning Statistics with R.
- Python Data Science Handbook. Jake VanderPlas, 2016.
- Python for Neuroscientists: Statistics in Python. Online course by Ruslan Klymentiev.
- Statistical Power and Power Analysis in Python by Jason Brownlee. A clear tutorial on how to use statsmodels for calculating statistical power and sample size. Another free and popular tool is GPower. Due to the many nuances related to sample size in biology, no common best practices are yet standardized.