TIE reconstruction

Transport of intensity (TIE) based methods of phase reconstruction.

TIE module

class PyLorentz.phase.tie.TIE(tfs, save_dir=None, name=None, sym=False, qc=None, verbose=1)[source]

Bases: BaseTIE

Class for performing Transport of Intensity Equation (TIE) phase reconstruction.

__init__(tfs, save_dir=None, name=None, sym=False, qc=None, verbose=1)[source]

Initialize the TIE object.

Parameters:
  • tfs (ThroughFocalSeries) – Through Focal Series dataset.

  • save_dir (Optional[os.PathLike], optional) – Directory to save results. Default is None.

  • name (Optional[str], optional) – Name for the reconstruction. Default is None.

  • sym (bool, optional) – Whether to symmetrize the images. Default is False.

  • qc (Optional[float], optional) – Tikhonov regularization parameter. Default is None.

  • verbose (int, optional) – Verbosity level. Default is 1.

reconstruct(index=None, name=None, sym=False, pad=False, qc=None, flip=None, save_mode=False, save_dir=None, verbose=1, pbcs=None, overwrite=False)[source]

Perform TIE reconstruction.

Parameters:
  • index (Optional[int], optional) – Index of the image to reconstruct. Default is None.

  • name (Optional[str], optional) – Name for the reconstruction. Default is None.

  • sym (bool, optional) – Whether to symmetrize the images. Default is False.

  • pad (bool | tuple, optional) – Whether to pad the images (useful for edge artifacts). Default is False.

  • qc (Optional[float], optional) – Tikhonov regularization parameter. Default is None.

  • flip (Optional[bool], optional) – Whether to use flip images. Default is None.

  • save_mode (Union[bool, str, List[str]], optional) – Whether and what to save. Default is False.

  • save_dir (Optional[os.PathLike], optional) – Directory to save results. Default is None.

  • verbose (Union[int, bool], optional) – Verbosity level. Default is 1.

  • pbcs (Optional[bool], optional) – Whether to apply periodic boundary conditions. Default is None.

  • overwrite (bool, optional) – Whether to overwrite existing files. Default is False.

Returns:

The TIE instance after reconstruction.

Return type:

TIE

save_results(save_mode=True, save_dir=None, name=None, overwrite=False)[source]

Save the reconstruction results.

Parameters:
  • save_mode (Union[bool, str, List[str]], optional) – Keys to save. Default is True.

  • save_dir (Optional[os.PathLike], optional) – Directory to save results. Default is None.

  • name (Optional[str], optional) – Name for the reconstruction. Default is None.

  • overwrite (bool, optional) – Whether to overwrite existing files. Default is False.

Returns:

The TIE instance.

Return type:

TIE

property recon_defval: float

Get the defocus value used for reconstruction.

Returns:

Defocus value.

Return type:

float

property flip: bool

Get the flip status.

Returns:

Flip status.

Return type:

bool

property phase_E: numpy.ndarray

Get the electrostatic phase shift.

Returns:

Electrostatic phase shift.

Return type:

np.ndarray

visualize(cbar=False, plot_scale=True)[source]

Visualize the phase and induction maps.

Parameters:
  • cbar (bool, optional) – Whether to display a colorbar. Default is False.

  • plot_scale (Union[bool, str], optional) – Whether and what scale to plot. Default is True.

show_phase_E(show_scale=True, **kwargs)[source]

Show the electrostatic phase shift.

Parameters:

show_scale (bool, optional) – Whether to show the scale. Default is True.

SITIE module

class PyLorentz.phase.sitie.SITIE(dd, save_dir=None, name=None, sym=False, qc=None, verbose=1)[source]

Bases: BaseTIE

Class for phase reconstruction using the SITIE method.

__init__(dd, save_dir=None, name=None, sym=False, qc=None, verbose=1)[source]

Initialize the SITIE object.

Parameters:
  • dd (DefocusedDataset) – Defocused dataset.

  • save_dir (Optional[os.PathLike], optional) – Directory to save results. Default is None.

  • name (Optional[str], optional) – Name for the reconstruction. Default is None.

  • sym (bool, optional) – Whether to symmetrize the images. Default is False.

  • qc (Optional[float], optional) – Tikhonov regularization parameter. Default is None.

  • verbose (int, optional) – Verbosity level. Default is 1.

classmethod from_array(image, scale=None, defval=None, beam_energy=None, name=None, sym=False, qc=None, save_dir=None, simulated=False, verbose=1)[source]

Create SITIE object from a numpy array.

Parameters:
  • image (np.ndarray) – Input image array.

  • scale (Union[float, int, None], optional) – Scale factor for the dataset. Default is None.

  • defvals (Optional[List[float]], optional) – List of defocus values. Default is None.

  • beam_energy (Optional[float], optional) – Beam energy for the reconstruction. Default is None.

  • name (Optional[str], optional) – Name for the reconstruction. Default is None.

  • sym (bool, optional) – Whether to symmetrize the images. Default is False.

  • qc (Optional[float], optional) – Tikhonov regularization parameter. Default is None.

  • save_dir (Optional[os.PathLike], optional) – Directory to save results. Default is None.

  • simulated (bool, optional) – Whether the data is simulated. Default is False.

  • verbose (Union[int, bool], optional) – Verbosity level. Default is 1.

Returns:

An instance of the SITIE class.

Return type:

SITIE

reconstruct(index=None, name=None, sym=False, qc=None, save=False, save_dir=None, verbose=None, pbcs=None, overwrite=False)[source]

Perform SITIE reconstruction.

Parameters:
  • index (Optional[int], optional) – Index of the image to reconstruct. Default is None.

  • name (Optional[str], optional) – Name for the reconstruction. Default is None.

  • sym (bool, optional) – Whether to symmetrize the images. Default is False.

  • qc (Optional[float], optional) – Tikhonov regularization parameter. Default is None.

  • save (Union[bool, str, List[str]], optional) – Whether and what to save. Default is False.

  • save_dir (Optional[os.PathLike], optional) – Directory to save results. Default is None.

  • verbose (Union[int, bool], optional) – Verbosity level. Default is 1.

  • pbcs (Optional[bool], optional) – Whether to apply periodic boundary conditions. Default is None.

  • overwrite (bool, optional) – Whether to overwrite existing files. Default is False.

Returns:

The SITIE instance after reconstruction.

Return type:

SITIE

save_results(save_mode=True, save_dir=None, name=None, overwrite=False)[source]

Save the reconstruction results.

Parameters:
  • save_mode (Union[bool, str, List[str]], optional) – Keys to save. Default is True.

  • save_dir (Optional[os.PathLike], optional) – Directory to save results. Default is None.

  • name (Optional[str], optional) – Name for the reconstruction. Default is None.

  • overwrite (bool, optional) – Whether to overwrite existing files. Default is False.

Returns:

The TIE instance.

Return type:

TIE

property recon_defval: float

Get the defocus value used for reconstruction.

Returns:

Defocus value.

Return type:

float

visualize(cbar=False, plot_scale=True)[source]

Visualize the phase and induction maps.

Parameters:
  • cbar (bool, optional) – Whether to display a colorbar. Default is False.

  • plot_scale (Union[bool, str], optional) – Whether and what scale to plot. Default is True.

Returns:

The SITIE instance.

Return type:

SITIE

base_TIE module

PyLorentz.phase.base_tie.warning_on_one_line(message, category, filename, lineno, file=None, line=None)[source]
class PyLorentz.phase.base_tie.BaseTIE(save_dir=None, scale=None, beam_energy=None, name=None, sym=False, qc=None, verbose=1)[source]

Bases: BasePhaseReconstruction

A base class for Transport of Intensity Equation (TIE) reconstruction.

__init__(save_dir=None, scale=None, beam_energy=None, name=None, sym=False, qc=None, verbose=1)[source]

Initialize the BaseTIE object.

Parameters:
  • save_dir (Optional[os.PathLike], optional) – Directory to save results. Default is None.

  • scale (Optional[float], optional) – Scale factor for the dataset. Default is None.

  • beam_energy (Optional[float], optional) – Beam energy for the reconstruction. Default is None.

  • name (Optional[str], optional) – Name for the reconstruction. Default is None.

  • sym (bool, optional) – Whether to symmetrize the images. Default is False.

  • qc (Optional[float], optional) – Tikhonov regularization parameter. Default is None.

  • verbose (Union[int, bool], optional) – Verbosity level. Default is 1.

property sym

Get the symmetrization flag.

property qc

Get the Tikhonov regularization parameter.

property beam_energy

Get the beam energy.