2D Diffusion & Mean Squared Displacement (MSD) Analysis
Introduction
Diffusion is the spontaneous net movement of particles from regions of higher concentration to regions of lower concentration driven by microscopic thermal fluctuations (Brownian motion). In cellular and molecular biophysics, single-particle tracking (SPT) microscopy enables researchers to trace coordinate trajectories of fluorescently tagged molecules, vesicles, and bacteria over time.
To extract the macroscopic diffusion coefficient (
Theoretical Framework
Trajectory Coordinates
Consider a particle tracked across
Mean Squared Displacement (MSD)
For an integer lag window
Extracting the Diffusion Coefficient ( )
In two-dimensional isotropic Brownian diffusion, Einstein's diffusion relation dictates:
Plotting
NOTE
The "Max Window" Statistical Anomaly:
As the lag window
Empirical Trajectory Dataset
The experimental trajectory consists of 65 sequential time slices (
| Time Slice | Time | ||
|---|---|---|---|
| 1 | 5 | 88 | 15 |
| 2 | 10 | 87 | 16 |
| 3 | 15 | 85 | 18 |
| 4 | 20 | 81 | 21 |
| 5 | 25 | 80 | 21 |
| 10 | 50 | 67 | 25 |
| 20 | 100 | 50 | 11 |
| 30 | 150 | 46 | 20 |
| 40 | 200 | 48 | 21 |
| 50 | 250 | 50 | 19 |
| 60 | 300 | 40 | 14 |
| 65 | 325 | 44 | 18 |
(Full timeseries of 65 coordinate pairs archived in lab/projects/diffusion-coefficient/msd.py)
Computational Methodology
The MSD pipeline is implemented in Python using NumPy and Pandas:
def calculate_msd(data, dt=5.0):
N = len(data)
lags = np.arange(1, N)
msd_values = []
for lag in lags:
dx = data['x'].diff(periods=lag).dropna()
dy = data['y'].diff(periods=lag).dropna()
squared_displacement = dx**2 + dy**2
msd_values.append(squared_displacement.mean())
tau_values = lags * dt
return tau_values, np.array(msd_values)Linear regression over the initial 25% data cutoff (
Interactive Marimo Notebook Pipeline (Future Integration)
The reactive computation script lab/projects/diffusion-coefficient/msd.py is configured with PEP 723 metadata:
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "marimo>=0.20.2",
# "matplotlib==3.10.8",
# "numpy==2.4.2",
# "pandas==3.0.1",
# ]
# ///Note: Per portfolio architecture specifications, full client-side WebAssembly (WASM) marimo runtime integration is scheduled for subsequent releases, with the analytical mathematical models and empirical timeseries preserved in native Markdown.
References
- Einstein, A. (1905). Über die von der molekularkinetischen Theorie der Wärme geforderte Bewegung von in ruhenden Flüssigkeiten suspendierten Teilchen. Annalen der Physik, 322(8), pp. 549–560.
- Qian, H., Sheetz, M.P. and Elson, E.L. (1991). Single particle tracking: analysis of diffusion and flow in two-dimensional systems. Biophysical Journal, 60(4), pp. 910–921.
- Michalet, X. (2010). Mean square displacement analysis of single-particle trajectories with localization error: Brownian motion in an isotropic medium. Physical Review E, 82(4), 041914.