nanopyx.methods.esrrf_3d.eSRRF3D_workflow

  1from ..workflow import Workflow
  2from ...core.transform._le_esrrf3d import eSRRF3D as eSRRF3D_ST
  3from ...core.transform.mpcorrector import macro_pixel_corrector
  4
  5import numpy as np
  6
  7
  8def eSRRF3D(
  9    img,
 10    magnification_xy=2,
 11    magnification_z=2,
 12    radius: float = 1.5,
 13    PSF_ratio: float = 2.8,
 14    voxel_ratio: float = 4.0,
 15    sensitivity: float = 1,
 16    frames_per_timepoint: int = 0,
 17    mode: str = "average",
 18    doIntensityWeighting: bool = True,
 19    macro_pixel_correction: bool = True,
 20    _force_run_type=None,
 21):
 22    """
 23    Perform eSRRF3D analysis on an image.
 24
 25    Args:
 26        img (numpy.ndarray): The input image for eSRRF3D analysis.
 27        magnification_xy (int, optional): Magnification factor in XY plane (default is 2).
 28        magnification_z (int, optional): Magnification factor in Z plane (default is 2).
 29        radius (float, optional): Radius parameter for eSRRF3D analysis (default is 1.5).
 30        PSF_ratio (float, optional): Ratio of PSF shape as Z/XY for eSRRF3D analysis (default is 2.8).
 31        voxel_ratio (float, optional): Ratio of voxel size in XY to Z direction (default is 4.0).
 32        frames_per_timepoint (int, optional): Number of frames per timepoint (default is 0, which means all frames are used).
 33        sensitivity (float, optional): Sensitivity parameter for eSRRF3D analysis (default is 1).
 34        mode (str, optional): Time projection mode (default is "average").
 35        doIntensityWeighting (bool, optional): Enable intensity weighting (default is True).
 36        macro_pixel_correction (bool, optional): Enable macro pixel correction (default is True).
 37        _force_run_type (str, optional): Force a specific run type for the analysis (default is None).
 38
 39    Returns:
 40        numpy.ndarray: The result of eSRRF3D analysis, typically representing the localizations.
 41
 42    Example:
 43        result = eSRRF3D(image, magnification_xy=2, magnification_z=2, radius=1.5, sensitivity=1, doIntensityWeighting=True)
 44
 45    Note:
 46        - eSRRF3D (enhanced Super-Resolution Radial Fluctuations 3D) is a method for super-resolution localization microscopy in three dimensions.
 47        - This function sets up a workflow to perform eSRRF3D analysis on the input image.
 48
 49    See Also:
 50        - eSRRF3D_ST: The eSRRF3D step that performs the actual analysis.
 51        - Workflow: The class used to define and run analysis workflows.
 52
 53    """
 54
 55    if frames_per_timepoint == 0:
 56        frames_per_timepoint = img.shape[0]
 57    elif frames_per_timepoint > img.shape[0]:
 58        frames_per_timepoint = img.shape[0]
 59
 60    number_of_timepoints = img.shape[0] // frames_per_timepoint
 61    if img.shape[0] % frames_per_timepoint != 0:
 62        number_of_timepoints += 1
 63
 64    output_array = np.zeros(
 65        (
 66            number_of_timepoints,
 67            img.shape[1] * magnification_z,
 68            img.shape[2] * magnification_xy,
 69            img.shape[3] * magnification_xy,
 70        ),
 71        dtype=np.float32,
 72    )
 73
 74    for i in range(number_of_timepoints):
 75        _eSRRF3D = Workflow(
 76            (
 77                eSRRF3D_ST(verbose=False),
 78                (
 79                    img[
 80                        frames_per_timepoint
 81                        * i : frames_per_timepoint
 82                        * (i + 1)
 83                    ],
 84                ),
 85                {
 86                    "magnification_xy": magnification_xy,
 87                    "magnification_z": magnification_z,
 88                    "radius": radius,
 89                    "PSF_ratio": PSF_ratio,
 90                    "voxel_ratio": voxel_ratio,
 91                    "sensitivity": sensitivity,
 92                    "mode": mode,
 93                    "doIntensityWeighting": doIntensityWeighting,
 94                },
 95            )
 96        )
 97        if macro_pixel_correction:
 98            output_array[i] = macro_pixel_corrector(
 99                _eSRRF3D.calculate(_force_run_type=_force_run_type)[0],
100                magnification=magnification_xy,
101            )
102        else:
103            output_array[i] = _eSRRF3D.calculate(
104                _force_run_type=_force_run_type
105            )[0]
106
107    return output_array.astype(np.float32)
def eSRRF3D( img, magnification_xy=2, magnification_z=2, radius: float = 1.5, PSF_ratio: float = 2.8, voxel_ratio: float = 4.0, sensitivity: float = 1, frames_per_timepoint: int = 0, mode: str = 'average', doIntensityWeighting: bool = True, macro_pixel_correction: bool = True, _force_run_type=None):
  9def eSRRF3D(
 10    img,
 11    magnification_xy=2,
 12    magnification_z=2,
 13    radius: float = 1.5,
 14    PSF_ratio: float = 2.8,
 15    voxel_ratio: float = 4.0,
 16    sensitivity: float = 1,
 17    frames_per_timepoint: int = 0,
 18    mode: str = "average",
 19    doIntensityWeighting: bool = True,
 20    macro_pixel_correction: bool = True,
 21    _force_run_type=None,
 22):
 23    """
 24    Perform eSRRF3D analysis on an image.
 25
 26    Args:
 27        img (numpy.ndarray): The input image for eSRRF3D analysis.
 28        magnification_xy (int, optional): Magnification factor in XY plane (default is 2).
 29        magnification_z (int, optional): Magnification factor in Z plane (default is 2).
 30        radius (float, optional): Radius parameter for eSRRF3D analysis (default is 1.5).
 31        PSF_ratio (float, optional): Ratio of PSF shape as Z/XY for eSRRF3D analysis (default is 2.8).
 32        voxel_ratio (float, optional): Ratio of voxel size in XY to Z direction (default is 4.0).
 33        frames_per_timepoint (int, optional): Number of frames per timepoint (default is 0, which means all frames are used).
 34        sensitivity (float, optional): Sensitivity parameter for eSRRF3D analysis (default is 1).
 35        mode (str, optional): Time projection mode (default is "average").
 36        doIntensityWeighting (bool, optional): Enable intensity weighting (default is True).
 37        macro_pixel_correction (bool, optional): Enable macro pixel correction (default is True).
 38        _force_run_type (str, optional): Force a specific run type for the analysis (default is None).
 39
 40    Returns:
 41        numpy.ndarray: The result of eSRRF3D analysis, typically representing the localizations.
 42
 43    Example:
 44        result = eSRRF3D(image, magnification_xy=2, magnification_z=2, radius=1.5, sensitivity=1, doIntensityWeighting=True)
 45
 46    Note:
 47        - eSRRF3D (enhanced Super-Resolution Radial Fluctuations 3D) is a method for super-resolution localization microscopy in three dimensions.
 48        - This function sets up a workflow to perform eSRRF3D analysis on the input image.
 49
 50    See Also:
 51        - eSRRF3D_ST: The eSRRF3D step that performs the actual analysis.
 52        - Workflow: The class used to define and run analysis workflows.
 53
 54    """
 55
 56    if frames_per_timepoint == 0:
 57        frames_per_timepoint = img.shape[0]
 58    elif frames_per_timepoint > img.shape[0]:
 59        frames_per_timepoint = img.shape[0]
 60
 61    number_of_timepoints = img.shape[0] // frames_per_timepoint
 62    if img.shape[0] % frames_per_timepoint != 0:
 63        number_of_timepoints += 1
 64
 65    output_array = np.zeros(
 66        (
 67            number_of_timepoints,
 68            img.shape[1] * magnification_z,
 69            img.shape[2] * magnification_xy,
 70            img.shape[3] * magnification_xy,
 71        ),
 72        dtype=np.float32,
 73    )
 74
 75    for i in range(number_of_timepoints):
 76        _eSRRF3D = Workflow(
 77            (
 78                eSRRF3D_ST(verbose=False),
 79                (
 80                    img[
 81                        frames_per_timepoint
 82                        * i : frames_per_timepoint
 83                        * (i + 1)
 84                    ],
 85                ),
 86                {
 87                    "magnification_xy": magnification_xy,
 88                    "magnification_z": magnification_z,
 89                    "radius": radius,
 90                    "PSF_ratio": PSF_ratio,
 91                    "voxel_ratio": voxel_ratio,
 92                    "sensitivity": sensitivity,
 93                    "mode": mode,
 94                    "doIntensityWeighting": doIntensityWeighting,
 95                },
 96            )
 97        )
 98        if macro_pixel_correction:
 99            output_array[i] = macro_pixel_corrector(
100                _eSRRF3D.calculate(_force_run_type=_force_run_type)[0],
101                magnification=magnification_xy,
102            )
103        else:
104            output_array[i] = _eSRRF3D.calculate(
105                _force_run_type=_force_run_type
106            )[0]
107
108    return output_array.astype(np.float32)

Perform eSRRF3D analysis on an image.

Args: img (numpy.ndarray): The input image for eSRRF3D analysis. magnification_xy (int, optional): Magnification factor in XY plane (default is 2). magnification_z (int, optional): Magnification factor in Z plane (default is 2). radius (float, optional): Radius parameter for eSRRF3D analysis (default is 1.5). PSF_ratio (float, optional): Ratio of PSF shape as Z/XY for eSRRF3D analysis (default is 2.8). voxel_ratio (float, optional): Ratio of voxel size in XY to Z direction (default is 4.0). frames_per_timepoint (int, optional): Number of frames per timepoint (default is 0, which means all frames are used). sensitivity (float, optional): Sensitivity parameter for eSRRF3D analysis (default is 1). mode (str, optional): Time projection mode (default is "average"). doIntensityWeighting (bool, optional): Enable intensity weighting (default is True). macro_pixel_correction (bool, optional): Enable macro pixel correction (default is True). _force_run_type (str, optional): Force a specific run type for the analysis (default is None).

Returns: numpy.ndarray: The result of eSRRF3D analysis, typically representing the localizations.

Example: result = eSRRF3D(image, magnification_xy=2, magnification_z=2, radius=1.5, sensitivity=1, doIntensityWeighting=True)

Note: - eSRRF3D (enhanced Super-Resolution Radial Fluctuations 3D) is a method for super-resolution localization microscopy in three dimensions. - This function sets up a workflow to perform eSRRF3D analysis on the input image.

See Also: - eSRRF3D_ST: The eSRRF3D step that performs the actual analysis. - Workflow: The class used to define and run analysis workflows.