ddm#

Differential dynamic microscopy interface with backends.

The image structure function is computed from the images \(I(\vec{x}, t)\) as

\[D(\vec{q},\Delta t)= \langle \lvert \tilde{I}(\vec{q},t+\Delta t) - \tilde{I}(\vec{q},t) \rvert^2 \rangle_t\]

where \(\tilde{I}(\vec{q},t)\) is the 2D Fourier transform of the image at time \(t\).

The image power spectrum is computed as

\[\mathrm{PS}(\vec{q})= \langle\lvert\tilde{I}(\vec{q}, t)\rvert^2\rangle_t .\]

The background-corrected image power spectrum is computed as

\[\mathrm{VAR}(\vec{q})= \langle\lvert\tilde{I}(\vec{q},t)-\tilde{I}_0(\vec{q})\rvert^2\rangle_t= \mathrm{PS}(\vec{q}) - \lvert \tilde{I}_0 (\vec{q}) \rvert^2\]

where \(\tilde{I}_0(\vec{q}) = \langle\tilde{I}(\vec{q}, t)\rangle_t\). This is just the variance over time of the 2D Fourier transformed image sequence.

fastddm._ddm.ddm(img_seq: ndarray, lags: Iterable[int], *, core: str = 'py', mode: str = 'fft', window: ndarray | None = None, **kwargs) ImageStructureFunction#

Perform Differential Dynamic Microscopy analysis on given image sequence. Returns the full image structure function.

Parameters:
  • img_seq (numpy.ndarray) – Image sequence of shape (t, y, x) where t is time.

  • lags (Iterable[int]) – The delays to be inspected by the analysis.

  • core (str, optional) – The backend core, choose between “py”, “cpp”, and “cuda”. Default is “py”.

  • mode (str, optional) – The mode of calculating the structure function, choose between “diff” and “fft”. Default is “fft”.

  • window (numpy.ndarray, optional) – A 2D array containing the window function to be applied to the images. Default is None.

Returns:

The image structure function.

Return type:

ImageStructureFunction

Raises:
  • RuntimeError – If a value for core other than “py”, “cpp”, and “cuda” are given.

  • RuntimeError – If a value for mode other than “diff” and “fft” are given.

  • RuntimeError – If window and img_seq shapes are not compatible.

  • RuntimeError – If negative lags are given.