correct_global_phase#

deepinv.optim.phase_retrieval.correct_global_phase(x_est, x_ref, correct_magnitude=False, dim=(-2, -1), verbose=False)[source]#

Corrects the global phase shift (and optionally magnitude scaling) of reconstructed complex signals to match the references.

The optimal global phase shift and magnitude scaling is computed per batch entry and channel as:

\[\theta = \arg \langle \hat{x}, x \rangle, \quad r = \frac{|\langle \hat{x}, x \rangle|}{\|\hat{x}\|^2},\]

where \(\arg\) denotes the angle of a complex number, \(\langle a, b \rangle = a^\mathrm{H} b\) denotes the complex inner product and \(\|\cdot\|\) denotes the Euclidean norm.

This computation corresponds to the complex-scalar minimizer \(c = r \mathrm{e}^{i \theta}\) of the following program:

\[\min_{c} \|c \cdot \hat{x} - x\|^2,\]

where \(\hat{x}\) is the reconstructed signal and \(x\) is the reference signal.

The correction is then applied to the reconstructed signal per batch entry and channel as:

\[\hat{x} \leftarrow r' \mathrm{e}^{\mathrm{i} \theta} \cdot \hat{x},\]

with \(r' = r\) if correct_magnitude is True and \(r' = 1\) otherwise.

Parameters:
  • x_est (torch.Tensor) – Estimated signals of shape (N, C, ...).

  • x_ref (torch.Tensor) – Reference signals of shape (N, C, ...).

  • correct_magnitude (bool) – If True, also corrects the magnitude scaling in addition to the phase. Default is False.

  • dim (tuple) – Dimensions of the signals over which the inner product is computed. Default is (-2, -1).

  • verbose (bool) – If True, prints the applied phase shift and scale factor. Default is False.

Returns:

The phase-corrected (and optionally magnitude-corrected) signals of the same shape as x_est.

Return type:

Tensor

Examples using correct_global_phase:#

Random phase retrieval and reconstruction methods.

Random phase retrieval and reconstruction methods.

Ptychography phase retrieval

Ptychography phase retrieval