pyAPIC package

pyAPIC public API.

class pyAPIC.Case(data: ImagingData, params: ReconParams, _result: dict | None = None)[source]

Bases: object

Encapsulates a reconstruction case: data, parameters, and results.

data: ImagingData
classmethod from_mat(mat_path: str, params: ReconParams, downsample: int = 1) Case[source]

Create a Case by loading imaging data from a .mat file and assigning parameters.

Parameters:
  • mat_path (str) – Path to the .mat file (HDF5 based).

  • params (ReconParams) – Reconstruction parameters.

  • downsample (int) – Factor to subsample the LED stack.

Returns:

Initialized Case object (results empty until run()).

Return type:

Case

params: ReconParams
plot()[source]

Generate result plot for this case.

plot_E_stack(ncols: int = 5) None[source]

Plot the LED stack as a grid of images.

Parameters:

ncols (int) – Number of columns in the grid.

plot_input(ncols: int = 5) None[source]

Plot the initial intensity stack as a grid of images.

Parameters:

ncols (int) – Number of columns in the grid.

property result: dict

Retrieve reconstruction outputs. Raises if run() has not been called.

run() None[source]

Execute the reconstruction algorithm. Populates self._result.

save(path: str) None[source]

Save the result dict to disk (e.g., pickle or HDF5).

Parameters:

path (str) – File path to save results.

class pyAPIC.ImagingData(I_low: ndarray, illum_px: ndarray, system_na_px: float, pixel_size: float | None = None, magnification: float | None = None, illum_na: ndarray | None = None, system_na: float | None = None, wavelength: float | None = None)[source]

Bases: object

Container for imaging data and acquisition parameters.

I_low: ndarray
property dpix_c: float | None
property freqXY_calib: ndarray
illum_na: ndarray | None = None
illum_px: ndarray
property mag: float | None
magnification: float | None = None
property na_cal: float | None
property na_calib: ndarray | None
property na_rp_cal: float
pixel_size: float | None = None
system_na: float | None = None
system_na_px: float
wavelength: float | None = None
class pyAPIC.ReconParams(reconstruct_aberration: bool = False, stitch_method: str = 'average')[source]

Bases: object

Parameters for phase reconstruction.

reconstruct_aberration

Whether to perform aberration reconstruction.

Type:

bool

stitch_method

Method used to stitch the Fourier patches (“average” or “nearest”).

Type:

str

reconstruct_aberration: bool = False
stitch_method: str = 'average'
pyAPIC.load_mat(path: str, downsample: int = 1) ImagingData[source]

Load imaging data and calibration parameters from a MATLAB .mat file (v7.3/HDF5).

Parameters:
  • path (str) – Path to the .mat file.

  • downsample (int) – Factor by which to subsample the image stack along the illumination axis.

Returns:

Populated dataclass.

Return type:

ImagingData

pyAPIC.to_pixel_coords(angles: ndarray, *, system_na_px: float, system_na: float | None = None, center: ndarray, wavelength: float | None = None, units: str = 'na', na_cal: float | None = None) ndarray[source]

Convert illumination angles to the illum_px pixel coordinates.

Parameters:
  • angles – Array of illumination angles of shape (2, N).

  • system_na_px – System numerical aperture expressed in pixel units.

  • system_na – System numerical aperture (unitless). na_cal may be used as an alias for backward compatibility.

  • center – Image center (y, x).

  • wavelength – Illumination wavelength. Required when units='na'.

  • units – Either 'na' for n sin(    heta) or 'freq' for spatial frequency units.