optimap.phaseΒΆ

Functions for computing, filtering, and analyzing phase maps from videos, and for detecting phase singularities.

optimap.phase.compute_phase(video, offset=-0.5)[source]ΒΆ

Computes phase using Hilbert transformation, takes a normalized video or time-series as input.

Parameters:
  • video ({t, x, y} ndarray) – normalized video

  • offset (float) – offset to add to video before computing phase, default is -0.5

Returns:

phase in range [-pi, pi]

Return type:

{t, x, y} ndarray

optimap.phase.detect_phase_singularities(phase: ndarray, separate_by_charge=False)[source]ΒΆ

Detect phase singularities in a phase map video using [Iyer and Gray, 2001] method. Unlike [Iyer and Gray, 2001], the phase integral used here is only over four pixels.

TODO: verify if positions are (x, y) or (y, x)

Parameters:
  • phase (ndarray) – Phase map video, shaped {t, x, y}

  • separate_by_charge (bool, optional) – Whether to separate phase singularities by charge, by default False See return value for details.

Returns:

  • list of tuples – List of phase singularities for each frame (if separate_by_charge is False)

  • (list of tuples, list of tuples) – (positive_ps_list, negative_ps_list) (if separate_by_charge is True)

optimap.phase.phasefilter_angle_threshold(phase: ndarray, wx: int, wy: int, wt: int, tr_angle: float, mask: ndarray | None = None)[source]ΒΆ

Remove outliers in a phase video by comparing them against their neighbors in space and time.

Parameters:
  • phase ({t, x, y} ndarray) – phase video

  • wx (int) – window size in x-direction

  • wy (int) – window size in y-direction

  • wt (int) – window size in t-direction

  • tr_angle (float) – threshold angle in radians

  • mask ({x, y} ndarray, optional) – only consider pixels where mask is True

Returns:

phase video with outliers removed

Return type:

{t, x, y} ndarray

optimap.phase.phasefilter_disc(phase: ndarray, wx: int, wy: int, wt: int, mask: ndarray | None = None)[source]ΒΆ

TODO: Docstring for phasefilter_disc.

optimap.phase.phasefilter_fillsmooth(phase: ndarray, wx: int, wy: int, wt: int, threshold: float, mask: ndarray | None = None)[source]ΒΆ

Fills holes in phase video by smoothing over space and time.

Parameters:
  • phase ({t, x, y} ndarray) – phase video

  • wx (int) – window size in x-direction

  • wy (int) – window size in y-direction

  • wt (int) – window size in t-direction

  • threshold (float) – threshold for filling holes TODO??

  • mask ({x, y} ndarray, optional) – only consider pixels where mask is True

Returns:

phase video with holes filled

Return type:

{t, x, y} ndarray