FUSE_illu#

from leonardo_toolset import FUSE_illu
class FUSE_illu(require_precropping=True, precropping_params=[], resample_ratio=2, window_size=[5, 59], poly_order=[2, 2], n_epochs=50, require_segmentation=True, device=None)#

Bases: object

Main class for Leonardo-Fuse (along illumination).

This class handles the workflow for fusion in data with dual-sided illumination.

Initialize the FUSE_illu class with training parameters.

Parameters
  • require_precropping (bool) – bool Whether to perform pre-cropping before training. If True, the model will automatically estimate a bounding box warping the foreground region based on which to estimate the fusion boundary.

  • precropping_params (list[int, int, int, int]) – list of int Manually define pre-cropping regions as [x_start, x_end, y_start, y_end]. regions outside will be considered as background and will not be considered for estimating the fusion boundary.

  • resample_ratio (int) – int Downsampling factor when estimating fusion boundaries.

  • window_size (list[int, int]) – list of int The size of the Savitzky-Golay filter window as [z, xy]. z is the window size along the depth (z-axis), and xy is the window size along the x/y plane.

  • poly_order (list[int, int]) – list of int Polynomial order for the Savitzky-Golay filter in [z, xy] directions.

  • n_epochs (int) – int Number of optimization epochs for estimating fusion boundary.

  • require_segmentation (bool) – bool Whether segmentation is required as part of the fusion pipeline.

  • device (str) – str Target computation device, e.g., ‘cuda’ or ‘cpu’. If None, defaults to available GPU.

train(data_path='', top_illu_data=None, bottom_illu_data=None, left_illu_data=None, right_illu_data=None, save_path='', save_folder='', save_separate_results=False, sparse_sample=False, cam_pos='front', camera_position='', display=True)#

Main training workflow for Leonardo-Fuse (along illumination).

This function supports fusion of light sheet data acquired with dual-sided illumination.

Input fields should be populated accordingly:

  • For light sheet systems with top–bottom illumination (in the image space), use top_illu_* and bottom_illu_*.

  • For systems with left–right illumination (in the image space), use left_illu_* and right_illu_*.

Parameters
  • data_path (str) – str, optional Root directory to prepend when input data is provided as a relative path (str). Ignored if inputs are arrays or lists of absolute paths.

  • top_illu_data (Optional[Union[numpy.ndarray, dask.array.core.Array, str]]) – dask.array.Array | np.ndarray | str Top illumination data. Can be: - A 3D array (Dask or NumPy), - A single file path (str), relative to data_path.

  • bottom_illu_data (Optional[Union[numpy.ndarray, dask.array.core.Array, str]]) – dask.array.Array | np.ndarray | str Bottom illumination data. See top_illu_data for supported formats.

  • left_illu_data (Optional[Union[numpy.ndarray, dask.array.core.Array, str]]) – dask.array.Array | np.ndarray | str Left illumination data. See top_illu_data for supported formats.

  • right_illu_data (Optional[Union[numpy.ndarray, dask.array.core.Array, str]]) – dask.array.Array | np.ndarray | str Right illumination data. See top_illu_data for supported formats.

  • save_path (str) – str Root path where output results will be saved.

  • save_folder (str) – str Name of the subfolder under save_path to save output files.

  • save_separate_results (bool) – bool, optional Whether to save the fusion map as float32 files. Set to True only if you plan to run Leonardo-DeStripe-Fuse afterward.

  • sparse_sample – bool, optional Whether the specimen is mainly sparse structures. If True, the fusion algorithm will adjust segmentation behavior.

  • cam_pos (str, optional) – Camera position in the image space. Must be either ‘front’ or ‘back’. If ‘front’, smaller z-indices are closer to the detection objective. If ‘back’, larger z-indices are closer to the detection objective. determines how the z-axis of the volume is interpreted.

  • camera_position (str) – str, optional Camera position string for naming. It is only used for naming output files.

  • display (bool) – bool, optional Whether to visualize intermediate or final results using matplotlib.

Returns

The fused output image.

Return type

np.ndarray

Notes

  • Input format: All input volumes must be in (Z, X, Y) format. Inputs must not contain channel dimensions. If your data includes channels (e.g., shape (Z, X, Y, C) or (T, C, Z, X, Y)), please extract the relevant channel first.

  • File compatibility: .tif files are reliably supported. Some .ome.tif files may cause issues depending on your bioio version. In such cases, please load the file manually and pass a np.ndarray instead.

train_with_boundary(boundary_path, data_path='', top_illu_data=None, bottom_illu_data=None, left_illu_data=None, right_illu_data=None, save_path='', save_separate_results=False, cam_pos='front', camera_position='', display=True)#

Run fusion using a precomputed fusion boundary.

Parameters
  • boundary_path (str) – str Absolute path of the precomputed fusion boundary in .tif file.

  • data_path (str) – str, optional Root directory to prepend when input data is provided as a relative path (str). Ignored if inputs are arrays or absolute paths.

  • top_illu_data (Optional[Union[numpy.ndarray, dask.array.core.Array, str]]) – dask.array.Array | np.ndarray | str Top illumination data.

  • bottom_illu_data (Optional[Union[numpy.ndarray, dask.array.core.Array, str]]) – dask.array.Array | np.ndarray | str Bottom illumination data.

  • left_illu_data (Optional[Union[numpy.ndarray, dask.array.core.Array, str]]) – dask.array.Array | np.ndarray | str Left illumination data.

  • right_illu_data (Optional[Union[numpy.ndarray, dask.array.core.Array, str]]) – dask.array.Array | np.ndarray | str Right illumination data.

  • save_path (str) – str Absolute path where fusion result in .tif will be saved.

  • save_separate_results (bool) – bool, optional Whether to save the fusion map as float32 files. Set to True only if you plan to run Leonardo-DeStripe-Fuse afterward.

  • cam_pos (str, optional) – Camera position in the image space. Must be either ‘front’ or ‘back’. If ‘front’, smaller z-indices are closer to the detection objective. If ‘back’, larger z-indices are closer to the detection objective. determines how the z-axis of the volume is interpreted.

  • camera_position (str) – str, optional Camera position string for naming. It is only used for naming output files.

  • display (bool) – bool, optional Whether to visualize intermediate or final results using matplotlib.

Returns

The fused output image.

Return type

np.ndarray