#Python
Python is the language I most often reach for when turning ideas into working code, whether that involves simulations, data analysis, image processing, or small research utilities. It therefore appears across many different contexts on this blog, from neuroscience and physics to more general computational experiments. Posts tagged this way usually include concrete Python examples, short tutorials, practical life hacks, and longer how to style explorations of scientific workflows. The focus is not on language features in the abstract, but on writing code that is readable, reproducible, and actually useful in day to day research.
There are currently 113 articles with this tag (newest first):
Distinguishing correlation from the coefficient of determination: Proper reporting of r and R²
I noticed that people sometimes report R² (‘R-squared’) instead of the Pearson correlation coeffi...
Rate models as a tool for studying collective neural activity
Rate models provide simplified representations of neural activity in which the precise spike timi...
On the role of gap junctions in neural modelling: Network example
As a follow-up to our previous post on gap junctions, we will now explore how gap junctions can b...
On the role of gap junctions in neural modelling
Gap junctions are specialized intercellular connections that facilitate direct electrical and che...
New teaching material: Functional imaging data analysis – From calcium imaging to network dynamics
We have just completed our new course, Functional Imaging Data Analysis: From Calcium Imaging to ...
Miniforge: The minimal, open solution for institutional Python environments
In response to recent licensing changes by Anaconda, Inc., Miniforge has emerged as the recommend...
Exploring connected notes: Local graph views for DEVONthink knowledge bases
DEVONthink has long been my preferred tool for managing personal knowledge. Its smart features, l...
New teaching material: Dimensionality reduction in neuroscience
We just completed a new two-day course on Dimensionality Reduction in Neuroscience, and I am plea...
Long-term potentiation (LTP) and long-term depression (LTD)
Both long-term potentiation (LTP) and long-term depression (LTD) are forms of synaptic plasticity...
Bienenstock-Cooper-Munro (BCM) rule
The Bienenstock-Cooper-Munro (BCM) rule is a cornerstone in theoretical neuroscience, offering a ...
Campbell and Siegert approximation for estimating the firing rate of a neuron
The Campbell and Siegert approximation is a method used in computational neuroscience to estimate...
Exponential (EIF) and adaptive exponential Integrate-and-Fire (AdEx) model
The exponential Integrate-and-Fire (EIF) model is a simplified neuronal model that captures the e...
Olfactory processing via spike-time based computation
In their work ‘Simple Networks for Spike-Timing-Based Computation, with Application to Olfactory ...
Frequency-current (f-I) curves
In this short tutorial, we will explore the concept of frequency-current (f-I) curves exemplified...
What are alpha-shaped post-synaptic currents?
In some recent posts, we have applied a specific type of integrate-and-fire neuron model, the iaf...
Example of a neuron driven by an inhibitory and excitatory neuron population
In this tutorial, we recap the NEST tutorial ‘Balanced neuron example’. We will simulate a neuron...
Brunel network: A comprehensive framework for studying neural network dynamics
In his work from 2000, Nicolas Brunel introduced a comprehensive framework for studying the dynam...
Oscillatory population dynamics of GIF neurons simulated with NEST
In this tutorial, we will explore the oscillatory population dynamics of generalized integrate-an...
Izhikevich SNN simulated with NEST
In this post, we explore how easy it is to set up a large-scale, multi-population spiking neural...
Connection concepts in NEST
In the previous post, we learned about the basic concepts of the NEST simulator and how to create...
Step-by-step NEST single neuron simulation
While NEST is designed for large-scale simulations of neural spike networks, the underlying model...
NEST simulator – A powerful tool for simulating large-scale spiking neural networks
The NEST simulator is a powerful software tool designed for simulating large-scale networks of sp...
Simulating spiking neural networks with Izhikevich neurons
The Izhikevich neuron model that we have discussed earlier is known for its simplicity and comput...
Izhikevich model
Computational neuroscience utilizes mathematical models to understand the complex dynamics of neu...
Hodgkin-Huxley model
An important step beyond simplified neuronal models is the Hodgkin-Huxley model. This model is ba...
FitzHugh-Nagumo model
In the previous post, we analyzed the dynamics of Van der Pol oscillator by using phase plane an...
Van der Pol oscillator
In this post, we will apply phase plane analysis to the Van der Pol oscillator. The Van der Pol o...
Nullclines and fixed points of the Rössler attractor
After introducing phase plane analysis in the previous post, we will now apply this method to the...
Using phase plane analysis to understand dynamical systems
When it comes to understanding the behavior of dynamical systems, it can quickly become too comp...
PyTorch on Apple Silicon
Already some time ago, PyTorch became fully available for Apple Silicon. It’s no longer necessary...
Rössler attractor
Unlike the Lorenz attractor which emerges from the dynamics of convection rolls, the Rössler attr...
Understanding Hebbian learning in Hopfield networks
Hopfield networks, a form of recurrent neural network (RNN), serve as a fundamental model for und...
Building a neural network from scratch using NumPy
Ever thought about building you own neural network from scratch by simply using NumPy? In this po...
Python’s version logos
Have you ever noticed that Python has introduced individual version logos starting with version 3...
Conditional GANs
I was wondering whether it would be possible to let GANs generate samples conditioned on a specif...
Eliminating the middleman: Direct Wasserstein distance computation in WGANs without discriminator
We explore an alternative approach to implementing WGANs. Contrasting from the standard implemen...
Wasserstein GANs
We apply the Wasserstein distance to Generative Adversarial Networks (GANs) to train them more ef...
Probability distance metrics in machine learning
Probabilistic distance metrics play a crucial role in a broad range of machine learning tasks, in...
Comparing Wasserstein distance, sliced Wasserstein distance, and L2 norm
In machine learning, especially when dealing with probability distributions or deep generative mo...
Approximating the Wasserstein distance with cumulative distribution functions
In the previous two posts, we’ve discussed the mathematical details of the Wasserstein distance, ...
Wasserstein distance via entropy regularization (Sinkhorn algorithm)
Calculating the Wasserstein distance can be computational costly when using linear programming. T...
Wasserstein distance and optimal transport
The Wasserstein distance, also known as the Earth Mover’s Distance (EMD), provides a robust and i...
Visualizing Occam’s Razor through machine learning
Here, we illustrate the concept of Occam’s Razor, a principle advocating for simplicity, by exami...
Mamba vs. Conda: Unleashing lightning-fast Python package installations
If you’ve ever experienced the frustration of waiting for ages while installing Python packages w...
Integrate and Fire Model: A simple neuronal model
In this post we explore the Integrate-and-Fire model, a simplified representation of a neuron. We...
Bioimage analysis with Napari
I’ve added new teaching material on using the free and open-source software (FOSS) Napari for bio...
Using random forests for pixel classification
Beyond traditional classification problems, random forests have proven their effectiveness in pix...
Decision Trees vs. Random Forests for classification and regression: A comparison
Decision trees and random forests are popular machine learning algorithms that are widely used fo...
Image denoising techniques: A comparison of PCA, kernel PCA, autoencoder, and CNN
In this post, we explore the performance of PCA, Kernel PCA, denoising autoencoder, and CNN for i...
Using Autoencoders to reveal hidden structures in high-dimensional data
In this Python tutorial, we explore the application of Autoencoders for dimensionality reduction,...
Unlocking hidden patterns with Factor Analysis
In this Python tutorial, we dive into Factor Analysis, a powerful statistical method used to unco...
Untangling complexity: Harnessing PCA for data dimensionality reduction
This tutorial explores the use of Principal Component Analysis (PCA), a powerful tool for reducin...
t-SNE and PCA: Two powerful tools for data exploration
Dimensionality reduction techniques play a vital role in both data exploration and visualization....
Understanding L1 and L2 regularization in machine learning
Regularization techniques play a vital role in preventing overfitting and enhancing the generaliz...
Understanding gradient descent in machine learning
Gradient descent is a fundamental optimization algorithm widely used in machine learning for find...
Loading and saving files in Google Colab
Enable I/O support in your notebooks running in Google Colab with just a few additional commands.
Mutual information and its relationship to information entropy
Mutual information is an essential measure in information theory that quantifies the statistical ...
Information entropy
A fundamental concept that plays a pivotal role in quantifying the uncertainty or randomness of a...
Understanding entropy
In physics, entropy is a fundamental concept that plays a crucial role in understanding the behav...
Zen and natural sciences
In this post, I broaden the scope and explore the intersections of Zen and natural sciences more...
The Zen of Python
The connection between Zen and programming is not a subjective one at all. For instance, Python h...
The Zen of programming
Some thoughts about the connections between Zen and programming.
Bio-image registration with Python
Which method works best for which registration problem? In this tutorial we compare different met...
How to run PyTorch on the M1 Mac GPU
As for TensorFlow, it takes only a few steps to enable a Mac with M1 chip (Apple silicon) for mac...
How to run TensorFlow on the M1 Mac GPU
In just a few steps you can enable a Mac with M1 chip (Apple silicon) for machine learning tasks ...
Is there a difference between miniconda and miniforge?
Simply said: not really. Miniconda is the company driven minimal conda installer, while miniforge...
Hacks and extensions to improve your coding with Visual Studio Code
This curated list contains useful hacks and extensions to improve the overall coding performance ...
Setting up Visual Studio Code for Python
In just a few steps you can turn Visual Studio Code (VS Code) into a powerful Python editor for b...
Enable interactive plots and other plot modes in Jupyter notebooks
Learn how to enable interactive, static and stand-alone window plots in Jupyter notebooks with th...
Enable code folding in JupyterLab
Learn how to enable code folding in JupyterLab for both, Jupyter Notebooks and pure Python scripts.
How to create and apply a requirements.txt file in Python
Learn how to install Python packages with a requirements.txt file and how to create one yourself.
Virtual environments with venv
In addition to conda’s create command, Python’s built-in venv command offers another way for cre...
Using pip to install Python packages
pip is another package installer for Python. Learn how to use it for installing and managing Pyth...
How to install and run Python code from GitHub
Learn how to install code from GitHub, that is, e.g., not (yet) available via conda or pip.
A minimal Python installation with miniconda
Learn how to install miniconda to have a quick and minimal Python installation on any operating s...
Using Zarr for images – The OME-ZARR standard
As for any other NumPy array, we can use the Zarr file format to store image files. In this post ...
Zarr – or: How to efficiently save NumPy arrays
What is Zarr and why is it probably the most suitable file format for saving NumPy arrays?
How to read patch clamp recordings in WaveMetrics IGOR binary files (ibw) in Python
This is a mini tutorial on how to read patch clamp recordings in WaveMetrics IGOR binary files (*...
How to add statistical annotations to matplotlib plots
This mini tutorial shows, how to add statistical annotations to matplotlib plots with just a few ...
Make matplotlib plots look more appealing with just a few extra commands
Learn how to enhance matplotlib plots with just a few hacks.
Variable explorer in Jupyter notebooks
Extend your Jupyter environment with Notebook Extensions and enable, e.g., the option to explore ...
Opening a Jupyter notebook from GitHub in Binder: A step-by-step guide
Opening a Jupyter notebook from GitHub in Binder simplifies access to shared code and facilitates...
New Teaching Material: Python Cheat Sheets
I’ve started a collection of various Python cheat sheets that contain some useful and commonly us...
New Teaching Material: Statistical data analysis and basic time series analysis with Python
I’ve added two new tutorials in the teaching section on statistical data analysis and basic time ...
New Teaching Material: Analyzing IGOR binary files of patch clamp recordings
I’ve added a new tutorial in the teaching section on how to read and process IGOR binary files (i...
strftime Cheat Sheet
Cheat Sheet on formatted date and time strings used, e.g., in Python, C/C++ or even on Jekyll web...
Supported syntax highlighting in Jekyll
A list of supported programming languages for Jekyll’s syntax highlighting.
New Teaching Material: Markdown Guide
I’ve composed a Markdown Guide for my teaching courses.
The Weierstrass function and the beauty of fractals
Fractals are captivating mathematical objects that exhibit intricate patterns and self-similarity...
The Lotka-Volterra equations: Modeling predator-prey dynamics
The Lotka-Volterra system, also known as the predator-prey equations, is a mathematical model tha...
Interactive COVID-19 data exploration with Jupyter notebooks
Amidst the ongoing challenges of the COVID-19 pandemic, I have written a Jupyter notebook that fa...
The SIR model: A mathematical approach to epidemic dynamics
In the wake of the COVID-19 pandemic, epidemiological models have garnered significant attention ...
The two-body problem
The two-body system is a classical problem in physics. It describes the motion of two massive obj...
Solving the Lorenz system using Runge-Kutta methods
In my previous post, I introduced the Runge-Kutta methods for numerically solving ordinary differ...
Runge-Kutta methods for solving ODEs
In physics and computational mathematics, numerical methods for solving ordinary differential equ...
A spectral (FFT) Poisson solver for 1D electrostatic PIC
In our previous post on Particle-in-Cell methods, we implemented a minimal 1D electrostatic PIC c...
Particle-in-Cell methods in kinetic plasma simulations
The Particle-in-Cell (PIC) method is a powerful numerical technique for simulating kinetic plasma...
Krook collision operator as velocity-space relaxation
The Krook collision operator provides a minimal model for velocity-space relaxation in kinetic pl...
Kappa versus Maxwell distributions: Suprathermal tails in collisionless plasmas
In many space plasmas, particle velocity distributions deviate from the Maxwellian form due to we...
Bi-Maxwellian distributions and anisotropic pressure
In many space and laboratory plasmas, velocity distributions are anisotropic with respect to the ...
What velocity moments miss: Core plus beam distributions
In this post, we explore how different initial velocity distributions lead to qualitatively disti...
Vlasov–Poisson dynamics: Landau damping and the two-stream instability
The Vlasov–Poisson system provides a minimal kinetic framework to illustrate fundamental plasma p...
Kinetic plasma theory: From distribution functions to the Vlasov equation
Kinetic plasma theory describes a plasma as an ensemble of particles represented by a distributio...
The Alfvén wave as a fundamental mode of magnetized plasmas
Among all plasma waves, the Alfvén wave occupies a special conceptual position. It is the simples...
Plasma waves in space plasmas
Space plasmas support a rich spectrum of collective wave phenomena that have no direct analogue i...
Magnetic reconnection via X-point collapse
In this post, we explore a complementary toy model of magnetic reconnection based on the collapse...
Magnetic reconnection: Theory and a simple numerical model
Magnetic reconnection is a fundamental plasma process that changes magnetic field topology and co...
The solar wind and the Parker model
The solar wind is a continuous, supersonic outflow of ionized plasma from the solar corona into i...
Magnetohydrodynamics (MHD): A theoretical overview with a numerical toy example
Magnetohydrodynamics (MHD) describes the coupled dynamics of a conducting fluid and electromagnet...
Adiabatic invariants and magnetic mirrors
Adiabatic invariants provide the central simplification behind most practical descriptions of cha...
Earth’s dipolar magnetic field
In physics and computational mathematics, numerical methods for solving ordinary differential equ...
Single-particle description of plasmas: Equation of motion, gyration, and ExB drift
In plasma physics, the motion of a single charged particle in prescribed electromagnetic fields p...
Characteristics of a plasma: Collective behavior, shielding, and intrinsic time scales
Both in space and astrophysics as well as in laboratory settings, plasma is the most common state...