FocusISM_lib

FitFingerprint(sub_img, p0=[1, 1], Ndet=5)[source]
class Selector(img)[source]

Bases: object

line_select_callback(eclick, erelease)[source]
select()[source]
fingerprint_model(xdata, A, sigma, BKG=0)[source]
focusISM(img, sigma_B_bound=None, threshold=0, apr=True, calibration='manual', sum_results=True, parallelize=True)[source]

Focus-ISM algorithm to remove out-of-focus background

Parameters:
  • img (np.array (Nx x Ny x Nch)) – ISM dataset

  • sigma_B_bound (float) – lower limit of the background std, in units of in-focus std

  • threshold (int) – Minimum number of photons per pixel required to start the analysis. Pixels below the threshold are assigned to the background.

  • apr (bool) – If True, the ISM dataset is reassigned with APR before applying focus-ISM. This step is facultative only for high-power STED data.

  • calibration (str or np.array(Nx x Ny x Nch)) – if ‘manual’ the user is requested to select a region of the input dataset. If np.array(Nx x Ny x Nch), the calibration dataset is used to calculate the in-focus fingerprint

  • sum_results (bool) – If true, the results are summed along the Nch dimension

  • parallelize (bool) – If True, the algorithm is CPU-parallelized using the ‘threading’ backend. If False, a progress bar is displayed. Default is True.

Returns:

  • signal (np.array (Nx x Ny) or np.array (Nx x Ny x Nch)) – Focus-ISM reconstruction of the in-focus signal

  • background (np.array (Nx x Ny) or np.array (Nx x Ny x Nch)) – Focus-ISM reconstruction of the out-of-focus signal,

  • ism (np.array (Nx x Ny) or np.array (Nx x Ny x Nch)) – APR reconstruction

gaussian(x, y, x0, y0, A, sigma)[source]
gaussian_model(xdata, sigma_A, B, sigma_B)[source]
pixel_fit_1(F, sigma_A, sigma_B, threshold=0)[source]

It fits the input micro-image to the sum of two Gaussian functions. The in-focus curve has fixed mean (the center of the micro-image) and standard deviation (sigma_A). The out-of-focus curve has fixed mean (the center of the micro-image) and fixed standard deviation (sigma_B).

Parameters:
  • F (np.ndarray) – Micro-image array.

  • sigma_A (float) – Standard deviation of the in-focus Gaussian function (units of pixels).

  • sigma_B (float) – Standard deviation of the ou-of-focus Gaussian function (units of pixels).

  • threshold (int, optional) – Minimum number of photons per pixel required to start the analysis. Pixels below the threshold are assigned to the background.. The default is 0.

Returns:

  • bkg (TYPE) – Background micro-image.

  • sig (TYPE) – In-focus micro-image.

  • sigma_B (TYPE) – Fitted sigma_B value. If the fit was unsuccesful or the treshold criterium is not satisfied, a 0 is returned.

  • R2 (TYPE) – Goodness of fit value (R-squared).

pixel_fit_2(F, sigma_A, sigma_B_bound=None, threshold=0)[source]

It fits the input micro-image to the sum of two Gaussian functions. The in-focus curve has fixed mean (the center of the micro-image) and standard deviation (sigma_A). The out-of-focus curve has fixed mean (the center of the micro-image) and free standard deviation (sigma_B), with a lower bound sigma_B_bound.

Parameters:
  • F (np.ndarray) – Micro-image array.

  • sigma_A (float) – Standard deviation of the in-focus Gaussian function (units of pixels).

  • sigma_B_bound (float, optional) – Lower limit of the background std, in units of in-focus std. The default is None.

  • threshold (int, optional) – Minimum number of photons per pixel required to start the analysis. Pixels below the threshold are assigned to the background.. The default is 0.

Returns:

  • bkg (TYPE) – Background micro-image.

  • sig (TYPE) – In-focus micro-image.

  • sigma_B (TYPE) – Fitted sigma_B value. If the fit was unsuccesful or the treshold criterium is not satisfied, a 0 is returned.

  • R2 (TYPE) – Goodness of fit value (R-squared).