Reconstruction module#

Reconstruction of surfaces from point clouds.

This module contains functions to reconstruct, refine, and resample surfaces from point clouds. The surfaces can be reconstructed from point clouds using the marching cubes algorithm. The surfaces can be refined by tracing the surface and fitting patches to the traced surface. The surfaces can be resampled by fitting patches to the surface and resampling the surface according to the fitted patches.

napari_stress.reconstruction.fit_patches(point_cloud: napari.types.PointsData, search_radius: float = 2) napari.types.PointsData#

Fit a quadratic surface to each point’s neighborhood in a point cloud and adjust the point positions to the fitted surface.

Parameters:
  • point_cloud (np.ndarray) – A numpy array with shape (n_points, 3), where each row represents a point with coordinates [Z, Y, X].

  • search_radius (float or np.ndarray) – The radius around each point to search for neighbors. Can be a single value or a numpy array with the same length as point_cloud. Default is 2.

Returns:

fitted_point_cloud – The point cloud with points adjusted to the fitted quadratic surface.

Return type:

np.ndarray

napari_stress.reconstruction.iterative_curvature_adaptive_patch_fitting(point_cloud: napari.types.PointsData, n_iterations: int = 3, minimum_neighbors: int = 6, minimum_search_radius: int = 1) napari.types.PointsData#
napari_stress.reconstruction.reconstruct_droplet(image: ImageData, voxelsize: ndarray = None, target_voxelsize: float = 1.0, smoothing_sigma: float = 1.0, n_smoothing_iterations: int = 10, n_points: int = 256, n_tracing_iterations: int = 1, resampling_length: float = 5, fit_type: str = 'fancy', edge_type: str = 'interior', trace_length: float = 10, remove_outliers: bool = True, outlier_tolerance: float = 1.5, sampling_distance: float = 0.5, interpolation_method: str = 'cubic', return_intermediate_results: bool = False) List[LayerDataTuple]#

Reconstruct droplet surface from points layer.

Parameters:
  • image (ImageData) – Image data.

  • voxelsize (np.ndarray, optional) – Voxel size of image. The default is None.

  • target_voxelsize (float, optional) – Target voxel size for reconstruction. The default is 1.0.

  • smoothing_sigma (float, optional) – Sigma for gaussian smoothing. The default is 1.0.

  • n_smoothing_iterations (int, optional) – Number of smoothing iterations. The default is 10.

  • n_points (int, optional) – Number of points to be sampled. The default is 256.

  • n_tracing_iterations (int, optional) – Number of tracing iterations. The default is 1.

  • resampling_length (float, optional) – Distance between sampled point locations. The default is 5. Choose smaller values for more accurate reconstruction.

  • fit_type (str, optional) – Type of fit to be used. The default is “fancy”. Can also be “quick”.

  • edge_type (str, optional) – Type of edge to be used. The default is “interior”. Can also be “surface”.

  • trace_length (float, optional) – Length of traces along which to measure intensity. The default is 10.

  • remove_outliers (bool, optional) – Whether to remove outliers. The default is True.

  • outlier_tolerance (float, optional) – Tolerance for outlier removal. The default is 1.5.

  • sampling_distance (float, optional) – Distance between points sampled on traces. The default is 0.5.

  • interpolation_method (str, optional) – Interpolation method to be used. The default is “cubic”. Can also be “linear”. “cubic” is more accurate but slower.

  • use_dask (bool, optional) – Whether to use dask for parallelization. The default is False.

  • return_intermediate_results (bool, optional) – Whether to return intermediate results. The default is False.

Returns:

List of napari layers:
  • rescaled image: image rescaled to target voxel size

  • label image: connected components of rescaled image

  • points first guess: points sampled on fibonacci grid

  • traced points: points after tracing

  • trace vectors: vectors along which intensity was measured

  • droplet center: center of droplet

Return type:

List[LayerDataTuple]

napari_stress.reconstruction.reconstruct_surface_from_quadrature_points(points: PointsData) SurfaceData#

Reconstruct the surface for a given set of quadrature points.

Parameters:

n_quadrature_points (int) – Number of used quadrature points

Returns:

Sphere_Triangulation_Array – DESCRIPTION.

Return type:

TYPE

napari_stress.reconstruction.resample_pointcloud(points: napari.types.PointsData, sampling_length: float = 5) napari.types.PointsData#

Resampe a spherical-like pointcloud on fibonacci grid.

Parameters:
  • points (PointsData)

  • sampling_length (float, optional) – Distance between sampled point locations. The default is 5.

Returns:

resampled_points

Return type:

TYPE

napari_stress.reconstruction.trace_refinement_of_surface(intensity_image: ImageData, points: PointsData, selected_fit_type: fit_types = fit_types.fancy_edge_fit, selected_edge: edge_functions = edge_functions.interior, trace_length: float = 10.0, sampling_distance: float = 0.5, remove_outliers: bool = True, outlier_tolerance: float = 1.5, interpolation_method: interpolation_types = interpolation_types.cubic) List[LayerDataTuple]#

Generate intensity profiles along traces.

This function receives an intensity image and a pointcloud with points on the surface of an object in the intensity image. It assumes that the pointcloud corresponds to the vertices on a surface around that object.

As a first step, the function calculates normals on the surface and multiplies the length of this vector with trace_length. The intensity of the input image is then sampled along this vector perpendicular to the surface with a distance of sampling distance between each point along the normal vector.

The location of the object’s surface is then determined by fitting a selected function to the intensity profile along the prolonged normal vector.

Parameters:
  • intensity_image (ImageData) – Intensity image

  • points (PointsData) – Pointcloud with points on the surface of the object

  • selected_fit_type (fit_types, optional) – Type of fit to use for determining the surface location, by default fit_types.fancy_edge_fit

  • selected_edge (edge_functions, optional) – Type of edge to detect, by default edge_functions.interior

  • trace_length (float, optional) – Length of the normal vector, by default 10.0

  • sampling_distance (float, optional) – Distance between each point along the normal vector, by default 0.5

  • remove_outliers (bool, optional) – Whether to remove outliers from the intensity profile, by default True

  • outlier_tolerance (float, optional) – Tolerance for outlier removal, by default 1.5

  • interpolation_method (interpolation_types, optional) – Interpolation method to use for sampling the intensity image, by default interpolation_types.cubic

Returns:

List of napari layer data tuples

Return type:

List[LayerDataTuple]