[ ]:
%matplotlib inline

Tutorial for fusion along detection#

Open In Colab

This tutorial shows how to apply Leonardo-Fuse to integrate light-sheet datasets with dual-sided illumination and dual-sided detection together.

The data used here is available in zenodo. We use volumes “D1_I0.tif”, “D1_I1.tif”, “D2_I0.tif” and “D2_I1.tif” for this tutorial. Here, “I0” and “I1” mean two opposite illumination lenses, while “D0” and “D1” means two opposing detection lenses. Datasets are well-aligned in advance.

Import packages & data#

[ ]:
# in case Leonardo is not installed yet
!pip install leonardo_toolset
Collecting leonardo_toolset
  Downloading leonardo_toolset-0.1.0-py2.py3-none-any.whl.metadata (5.0 kB)
Collecting lsfm-destripe (from leonardo_toolset)
  Downloading lsfm_destripe-0.1.0-py2.py3-none-any.whl.metadata (8.8 kB)
Collecting lsfm-fuse (from leonardo_toolset)
  Downloading lsfm_fuse-0.1.2-py2.py3-none-any.whl.metadata (17 kB)
Requirement already satisfied: scikit-image in /usr/local/lib/python3.10/dist-packages (from lsfm-destripe->leonardo_toolset) (0.24.0)
Requirement already satisfied: torch in /usr/local/lib/python3.10/dist-packages (from lsfm-destripe->leonardo_toolset) (2.5.1+cu121)
Requirement already satisfied: torchvision in /usr/local/lib/python3.10/dist-packages (from lsfm-destripe->leonardo_toolset) (0.20.1+cu121)
Collecting aicsimageio (from lsfm-destripe->leonardo_toolset)
  Downloading aicsimageio-4.14.0-py2.py3-none-any.whl.metadata (20 kB)
Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from lsfm-destripe->leonardo_toolset) (4.66.6)
Requirement already satisfied: matplotlib in /usr/local/lib/python3.10/dist-packages (from lsfm-destripe->leonardo_toolset) (3.8.0)
Collecting antspyx (from lsfm-fuse->leonardo_toolset)
  Downloading antspyx-0.5.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.7 kB)
Collecting SimpleITK (from lsfm-fuse->leonardo_toolset)
  Downloading SimpleITK-2.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (7.9 kB)
Requirement already satisfied: opencv-python in /usr/local/lib/python3.10/dist-packages (from lsfm-fuse->leonardo_toolset) (4.10.0.84)
Requirement already satisfied: colour in /usr/local/lib/python3.10/dist-packages (from lsfm-fuse->leonardo_toolset) (0.1.5)
Collecting open3d (from lsfm-fuse->leonardo_toolset)
  Downloading open3d-0.18.0-cp310-cp310-manylinux_2_27_x86_64.whl.metadata (4.2 kB)
Requirement already satisfied: h5py in /usr/local/lib/python3.10/dist-packages (from lsfm-fuse->leonardo_toolset) (3.12.1)
Requirement already satisfied: dask>=2021.4.1 in /usr/local/lib/python3.10/dist-packages (from dask[array]>=2021.4.1->aicsimageio->lsfm-destripe->leonardo_toolset) (2024.10.0)
Collecting fsspec<2023.9.0,>=2022.8.0 (from aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading fsspec-2023.6.0-py3-none-any.whl.metadata (6.7 kB)
Collecting imagecodecs>=2020.5.30 (from aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading imagecodecs-2024.9.22-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (20 kB)
Collecting lxml<5,>=4.6 (from aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading lxml-4.9.4-cp310-cp310-manylinux_2_28_x86_64.whl.metadata (3.7 kB)
Requirement already satisfied: numpy>=1.21.0 in /usr/local/lib/python3.10/dist-packages (from aicsimageio->lsfm-destripe->leonardo_toolset) (1.26.4)
Collecting ome-types>=0.3.4 (from aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading ome_types-0.5.3-py3-none-any.whl.metadata (11 kB)
Collecting ome-zarr>=0.6.1 (from aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading ome_zarr-0.10.2-py3-none-any.whl.metadata (2.9 kB)
Requirement already satisfied: PyYAML>=6.0 in /usr/local/lib/python3.10/dist-packages (from aicsimageio->lsfm-destripe->leonardo_toolset) (6.0.2)
Requirement already satisfied: wrapt>=1.12 in /usr/local/lib/python3.10/dist-packages (from aicsimageio->lsfm-destripe->leonardo_toolset) (1.17.0)
Collecting resource-backed-dask-array>=0.1.0 (from aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading resource_backed_dask_array-0.1.0-py2.py3-none-any.whl.metadata (6.5 kB)
Collecting tifffile<2023.3.15,>=2021.8.30 (from aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading tifffile-2023.2.28-py3-none-any.whl.metadata (30 kB)
Requirement already satisfied: xarray>=0.16.1 in /usr/local/lib/python3.10/dist-packages (from aicsimageio->lsfm-destripe->leonardo_toolset) (2024.10.0)
Collecting xmlschema (from aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading xmlschema-3.4.3-py3-none-any.whl.metadata (8.3 kB)
Collecting zarr<2.16.0,>=2.6 (from aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading zarr-2.15.0-py3-none-any.whl.metadata (5.4 kB)
Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from antspyx->lsfm-fuse->leonardo_toolset) (2.2.2)
Requirement already satisfied: statsmodels in /usr/local/lib/python3.10/dist-packages (from antspyx->lsfm-fuse->leonardo_toolset) (0.14.4)
Requirement already satisfied: webcolors in /usr/local/lib/python3.10/dist-packages (from antspyx->lsfm-fuse->leonardo_toolset) (24.11.1)
Requirement already satisfied: Pillow in /usr/local/lib/python3.10/dist-packages (from antspyx->lsfm-fuse->leonardo_toolset) (11.0.0)
Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from antspyx->lsfm-fuse->leonardo_toolset) (2.32.3)
Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->lsfm-destripe->leonardo_toolset) (1.3.1)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib->lsfm-destripe->leonardo_toolset) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->lsfm-destripe->leonardo_toolset) (4.55.3)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->lsfm-destripe->leonardo_toolset) (1.4.7)
Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->lsfm-destripe->leonardo_toolset) (24.2)
Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->lsfm-destripe->leonardo_toolset) (3.2.0)
Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib->lsfm-destripe->leonardo_toolset) (2.8.2)
Collecting dash>=2.6.0 (from open3d->lsfm-fuse->leonardo_toolset)
  Downloading dash-2.18.2-py3-none-any.whl.metadata (10 kB)
Requirement already satisfied: werkzeug>=2.2.3 in /usr/local/lib/python3.10/dist-packages (from open3d->lsfm-fuse->leonardo_toolset) (3.1.3)
Requirement already satisfied: nbformat>=5.7.0 in /usr/local/lib/python3.10/dist-packages (from open3d->lsfm-fuse->leonardo_toolset) (5.10.4)
Collecting configargparse (from open3d->lsfm-fuse->leonardo_toolset)
  Downloading ConfigArgParse-1.7-py3-none-any.whl.metadata (23 kB)
Collecting ipywidgets>=8.0.4 (from open3d->lsfm-fuse->leonardo_toolset)
  Downloading ipywidgets-8.1.5-py3-none-any.whl.metadata (2.3 kB)
Collecting addict (from open3d->lsfm-fuse->leonardo_toolset)
  Downloading addict-2.4.0-py3-none-any.whl.metadata (1.0 kB)
Requirement already satisfied: scikit-learn>=0.21 in /usr/local/lib/python3.10/dist-packages (from open3d->lsfm-fuse->leonardo_toolset) (1.5.2)
Collecting pyquaternion (from open3d->lsfm-fuse->leonardo_toolset)
  Downloading pyquaternion-0.9.9-py3-none-any.whl.metadata (1.4 kB)
Requirement already satisfied: scipy>=1.9 in /usr/local/lib/python3.10/dist-packages (from scikit-image->lsfm-destripe->leonardo_toolset) (1.13.1)
Requirement already satisfied: networkx>=2.8 in /usr/local/lib/python3.10/dist-packages (from scikit-image->lsfm-destripe->leonardo_toolset) (3.4.2)
Requirement already satisfied: imageio>=2.33 in /usr/local/lib/python3.10/dist-packages (from scikit-image->lsfm-destripe->leonardo_toolset) (2.36.1)
Requirement already satisfied: lazy-loader>=0.4 in /usr/local/lib/python3.10/dist-packages (from scikit-image->lsfm-destripe->leonardo_toolset) (0.4)
Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch->lsfm-destripe->leonardo_toolset) (3.16.1)
Requirement already satisfied: typing-extensions>=4.8.0 in /usr/local/lib/python3.10/dist-packages (from torch->lsfm-destripe->leonardo_toolset) (4.12.2)
Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch->lsfm-destripe->leonardo_toolset) (3.1.4)
Requirement already satisfied: sympy==1.13.1 in /usr/local/lib/python3.10/dist-packages (from torch->lsfm-destripe->leonardo_toolset) (1.13.1)
Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.10/dist-packages (from sympy==1.13.1->torch->lsfm-destripe->leonardo_toolset) (1.3.0)
Requirement already satisfied: Flask<3.1,>=1.0.4 in /usr/local/lib/python3.10/dist-packages (from dash>=2.6.0->open3d->lsfm-fuse->leonardo_toolset) (3.0.3)
Collecting werkzeug>=2.2.3 (from open3d->lsfm-fuse->leonardo_toolset)
  Downloading werkzeug-3.0.6-py3-none-any.whl.metadata (3.7 kB)
Requirement already satisfied: plotly>=5.0.0 in /usr/local/lib/python3.10/dist-packages (from dash>=2.6.0->open3d->lsfm-fuse->leonardo_toolset) (5.24.1)
Collecting dash-html-components==2.0.0 (from dash>=2.6.0->open3d->lsfm-fuse->leonardo_toolset)
  Downloading dash_html_components-2.0.0-py3-none-any.whl.metadata (3.8 kB)
Collecting dash-core-components==2.0.0 (from dash>=2.6.0->open3d->lsfm-fuse->leonardo_toolset)
  Downloading dash_core_components-2.0.0-py3-none-any.whl.metadata (2.9 kB)
Collecting dash-table==5.0.0 (from dash>=2.6.0->open3d->lsfm-fuse->leonardo_toolset)
  Downloading dash_table-5.0.0-py3-none-any.whl.metadata (2.4 kB)
Requirement already satisfied: importlib-metadata in /usr/local/lib/python3.10/dist-packages (from dash>=2.6.0->open3d->lsfm-fuse->leonardo_toolset) (8.5.0)
Collecting retrying (from dash>=2.6.0->open3d->lsfm-fuse->leonardo_toolset)
  Downloading retrying-1.3.4-py3-none-any.whl.metadata (6.9 kB)
Requirement already satisfied: nest-asyncio in /usr/local/lib/python3.10/dist-packages (from dash>=2.6.0->open3d->lsfm-fuse->leonardo_toolset) (1.6.0)
Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from dash>=2.6.0->open3d->lsfm-fuse->leonardo_toolset) (75.1.0)
Requirement already satisfied: click>=8.1 in /usr/local/lib/python3.10/dist-packages (from dask>=2021.4.1->dask[array]>=2021.4.1->aicsimageio->lsfm-destripe->leonardo_toolset) (8.1.7)
Requirement already satisfied: cloudpickle>=3.0.0 in /usr/local/lib/python3.10/dist-packages (from dask>=2021.4.1->dask[array]>=2021.4.1->aicsimageio->lsfm-destripe->leonardo_toolset) (3.1.0)
Requirement already satisfied: partd>=1.4.0 in /usr/local/lib/python3.10/dist-packages (from dask>=2021.4.1->dask[array]>=2021.4.1->aicsimageio->lsfm-destripe->leonardo_toolset) (1.4.2)
Requirement already satisfied: toolz>=0.10.0 in /usr/local/lib/python3.10/dist-packages (from dask>=2021.4.1->dask[array]>=2021.4.1->aicsimageio->lsfm-destripe->leonardo_toolset) (0.12.1)
Collecting comm>=0.1.3 (from ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset)
  Downloading comm-0.2.2-py3-none-any.whl.metadata (3.7 kB)
Requirement already satisfied: ipython>=6.1.0 in /usr/local/lib/python3.10/dist-packages (from ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset) (7.34.0)
Requirement already satisfied: traitlets>=4.3.1 in /usr/local/lib/python3.10/dist-packages (from ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset) (5.7.1)
Collecting widgetsnbextension~=4.0.12 (from ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset)
  Downloading widgetsnbextension-4.0.13-py3-none-any.whl.metadata (1.6 kB)
Requirement already satisfied: jupyterlab-widgets~=3.0.12 in /usr/local/lib/python3.10/dist-packages (from ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset) (3.0.13)
Requirement already satisfied: fastjsonschema>=2.15 in /usr/local/lib/python3.10/dist-packages (from nbformat>=5.7.0->open3d->lsfm-fuse->leonardo_toolset) (2.21.1)
Requirement already satisfied: jsonschema>=2.6 in /usr/local/lib/python3.10/dist-packages (from nbformat>=5.7.0->open3d->lsfm-fuse->leonardo_toolset) (4.23.0)
Requirement already satisfied: jupyter-core!=5.0.*,>=4.12 in /usr/local/lib/python3.10/dist-packages (from nbformat>=5.7.0->open3d->lsfm-fuse->leonardo_toolset) (5.7.2)
Requirement already satisfied: pydantic!=2.0,!=2.1,!=2.2,!=2.3,>=1.10.16 in /usr/local/lib/python3.10/dist-packages (from ome-types>=0.3.4->aicsimageio->lsfm-destripe->leonardo_toolset) (2.10.3)
Collecting pydantic-compat>=0.1.0 (from ome-types>=0.3.4->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading pydantic_compat-0.1.2-py3-none-any.whl.metadata (8.4 kB)
Collecting xsdata<24.4,>=23.6 (from ome-types>=0.3.4->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading xsdata-24.3.1-py3-none-any.whl.metadata (6.3 kB)
Collecting distributed (from ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading distributed-2024.12.1-py3-none-any.whl.metadata (3.3 kB)
Requirement already satisfied: aiohttp<4 in /usr/local/lib/python3.10/dist-packages (from ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset) (3.11.10)
Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->antspyx->lsfm-fuse->leonardo_toolset) (2024.2)
Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.10/dist-packages (from pandas->antspyx->lsfm-fuse->leonardo_toolset) (2024.2)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.7->matplotlib->lsfm-destripe->leonardo_toolset) (1.17.0)
Requirement already satisfied: joblib>=1.2.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=0.21->open3d->lsfm-fuse->leonardo_toolset) (1.4.2)
Requirement already satisfied: threadpoolctl>=3.1.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=0.21->open3d->lsfm-fuse->leonardo_toolset) (3.5.0)
Requirement already satisfied: MarkupSafe>=2.1.1 in /usr/local/lib/python3.10/dist-packages (from werkzeug>=2.2.3->open3d->lsfm-fuse->leonardo_toolset) (3.0.2)
Collecting asciitree (from zarr<2.16.0,>=2.6->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading asciitree-0.3.3.tar.gz (4.0 kB)
  Preparing metadata (setup.py) ... done
Collecting fasteners (from zarr<2.16.0,>=2.6->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading fasteners-0.19-py3-none-any.whl.metadata (4.9 kB)
Collecting numcodecs>=0.10.0 (from zarr<2.16.0,>=2.6->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading numcodecs-0.13.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.9 kB)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->antspyx->lsfm-fuse->leonardo_toolset) (3.4.0)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->antspyx->lsfm-fuse->leonardo_toolset) (3.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->antspyx->lsfm-fuse->leonardo_toolset) (2.2.3)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->antspyx->lsfm-fuse->leonardo_toolset) (2024.8.30)
Requirement already satisfied: patsy>=0.5.6 in /usr/local/lib/python3.10/dist-packages (from statsmodels->antspyx->lsfm-fuse->leonardo_toolset) (1.0.1)
Collecting elementpath<5.0.0,>=4.4.0 (from xmlschema->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading elementpath-4.6.0-py3-none-any.whl.metadata (7.0 kB)
Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset) (2.4.4)
Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset) (1.3.2)
Requirement already satisfied: async-timeout<6.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset) (4.0.3)
Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset) (24.2.0)
Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset) (1.5.0)
Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset) (6.1.0)
Requirement already satisfied: propcache>=0.2.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset) (0.2.1)
Requirement already satisfied: yarl<2.0,>=1.17.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset) (1.18.3)
Requirement already satisfied: itsdangerous>=2.1.2 in /usr/local/lib/python3.10/dist-packages (from Flask<3.1,>=1.0.4->dash>=2.6.0->open3d->lsfm-fuse->leonardo_toolset) (2.2.0)
Requirement already satisfied: blinker>=1.6.2 in /usr/local/lib/python3.10/dist-packages (from Flask<3.1,>=1.0.4->dash>=2.6.0->open3d->lsfm-fuse->leonardo_toolset) (1.9.0)
Collecting s3fs (from fsspec[s3]!=2021.07.0,>=0.8->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading s3fs-2024.10.0-py3-none-any.whl.metadata (1.7 kB)
Requirement already satisfied: zipp>=3.20 in /usr/local/lib/python3.10/dist-packages (from importlib-metadata->dash>=2.6.0->open3d->lsfm-fuse->leonardo_toolset) (3.21.0)
Collecting jedi>=0.16 (from ipython>=6.1.0->ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset)
  Downloading jedi-0.19.2-py2.py3-none-any.whl.metadata (22 kB)
Requirement already satisfied: decorator in /usr/local/lib/python3.10/dist-packages (from ipython>=6.1.0->ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset) (4.4.2)
Requirement already satisfied: pickleshare in /usr/local/lib/python3.10/dist-packages (from ipython>=6.1.0->ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset) (0.7.5)
Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from ipython>=6.1.0->ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset) (3.0.48)
Requirement already satisfied: pygments in /usr/local/lib/python3.10/dist-packages (from ipython>=6.1.0->ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset) (2.18.0)
Requirement already satisfied: backcall in /usr/local/lib/python3.10/dist-packages (from ipython>=6.1.0->ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset) (0.2.0)
Requirement already satisfied: matplotlib-inline in /usr/local/lib/python3.10/dist-packages (from ipython>=6.1.0->ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset) (0.1.7)
Requirement already satisfied: pexpect>4.3 in /usr/local/lib/python3.10/dist-packages (from ipython>=6.1.0->ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset) (4.9.0)
Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=2.6->nbformat>=5.7.0->open3d->lsfm-fuse->leonardo_toolset) (2024.10.1)
Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=2.6->nbformat>=5.7.0->open3d->lsfm-fuse->leonardo_toolset) (0.35.1)
Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.10/dist-packages (from jsonschema>=2.6->nbformat>=5.7.0->open3d->lsfm-fuse->leonardo_toolset) (0.22.3)
Requirement already satisfied: platformdirs>=2.5 in /usr/local/lib/python3.10/dist-packages (from jupyter-core!=5.0.*,>=4.12->nbformat>=5.7.0->open3d->lsfm-fuse->leonardo_toolset) (4.3.6)
Requirement already satisfied: locket in /usr/local/lib/python3.10/dist-packages (from partd>=1.4.0->dask>=2021.4.1->dask[array]>=2021.4.1->aicsimageio->lsfm-destripe->leonardo_toolset) (1.0.0)
Requirement already satisfied: tenacity>=6.2.0 in /usr/local/lib/python3.10/dist-packages (from plotly>=5.0.0->dash>=2.6.0->open3d->lsfm-fuse->leonardo_toolset) (9.0.0)
Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic!=2.0,!=2.1,!=2.2,!=2.3,>=1.10.16->ome-types>=0.3.4->aicsimageio->lsfm-destripe->leonardo_toolset) (0.7.0)
Requirement already satisfied: pydantic-core==2.27.1 in /usr/local/lib/python3.10/dist-packages (from pydantic!=2.0,!=2.1,!=2.2,!=2.3,>=1.10.16->ome-types>=0.3.4->aicsimageio->lsfm-destripe->leonardo_toolset) (2.27.1)
INFO: pip is looking at multiple versions of distributed to determine which version is compatible with other requirements. This could take a while.
Collecting distributed (from ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading distributed-2024.12.0-py3-none-any.whl.metadata (3.3 kB)
  Downloading distributed-2024.11.2-py3-none-any.whl.metadata (3.3 kB)
  Downloading distributed-2024.11.1-py3-none-any.whl.metadata (3.3 kB)
  Downloading distributed-2024.11.0-py3-none-any.whl.metadata (3.3 kB)
  Downloading distributed-2024.10.0-py3-none-any.whl.metadata (3.3 kB)
Requirement already satisfied: msgpack>=1.0.2 in /usr/local/lib/python3.10/dist-packages (from distributed->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset) (1.1.0)
Requirement already satisfied: psutil>=5.8.0 in /usr/local/lib/python3.10/dist-packages (from distributed->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset) (5.9.5)
Collecting sortedcontainers>=2.0.5 (from distributed->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading sortedcontainers-2.4.0-py2.py3-none-any.whl.metadata (10 kB)
Collecting tblib>=1.6.0 (from distributed->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading tblib-3.0.0-py3-none-any.whl.metadata (25 kB)
Requirement already satisfied: tornado>=6.2.0 in /usr/local/lib/python3.10/dist-packages (from distributed->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset) (6.3.3)
Collecting zict>=3.0.0 (from distributed->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading zict-3.0.0-py2.py3-none-any.whl.metadata (899 bytes)
Requirement already satisfied: parso<0.9.0,>=0.8.4 in /usr/local/lib/python3.10/dist-packages (from jedi>=0.16->ipython>=6.1.0->ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset) (0.8.4)
Requirement already satisfied: ptyprocess>=0.5 in /usr/local/lib/python3.10/dist-packages (from pexpect>4.3->ipython>=6.1.0->ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset) (0.7.0)
Requirement already satisfied: wcwidth in /usr/local/lib/python3.10/dist-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=6.1.0->ipywidgets>=8.0.4->open3d->lsfm-fuse->leonardo_toolset) (0.2.13)
Collecting aiobotocore<3.0.0,>=2.5.4 (from s3fs->fsspec[s3]!=2021.07.0,>=0.8->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading aiobotocore-2.16.0-py3-none-any.whl.metadata (23 kB)
INFO: pip is looking at multiple versions of s3fs to determine which version is compatible with other requirements. This could take a while.
Collecting s3fs (from fsspec[s3]!=2021.07.0,>=0.8->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading s3fs-2024.9.0-py3-none-any.whl.metadata (1.6 kB)
  Downloading s3fs-2024.6.1-py3-none-any.whl.metadata (1.6 kB)
  Downloading s3fs-2024.6.0-py3-none-any.whl.metadata (1.6 kB)
  Downloading s3fs-2024.5.0-py3-none-any.whl.metadata (1.6 kB)
  Downloading s3fs-2024.3.1-py3-none-any.whl.metadata (1.6 kB)
  Downloading s3fs-2024.3.0-py3-none-any.whl.metadata (1.6 kB)
  Downloading s3fs-2024.2.0-py3-none-any.whl.metadata (1.6 kB)
INFO: pip is still looking at multiple versions of s3fs to determine which version is compatible with other requirements. This could take a while.
  Downloading s3fs-2023.12.2-py3-none-any.whl.metadata (1.6 kB)
  Downloading s3fs-2023.12.1-py3-none-any.whl.metadata (1.6 kB)
  Downloading s3fs-2023.10.0-py3-none-any.whl.metadata (1.6 kB)
Collecting aiobotocore~=2.7.0 (from s3fs->fsspec[s3]!=2021.07.0,>=0.8->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading aiobotocore-2.7.0-py3-none-any.whl.metadata (20 kB)
Collecting s3fs (from fsspec[s3]!=2021.07.0,>=0.8->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading s3fs-2023.9.2-py3-none-any.whl.metadata (1.6 kB)
Collecting aiobotocore~=2.5.4 (from s3fs->fsspec[s3]!=2021.07.0,>=0.8->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading aiobotocore-2.5.4-py3-none-any.whl.metadata (19 kB)
Collecting s3fs (from fsspec[s3]!=2021.07.0,>=0.8->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading s3fs-2023.9.1-py3-none-any.whl.metadata (1.6 kB)
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. See https://pip.pypa.io/warnings/backtracking for guidance. If you want to abort this run, press Ctrl + C.
  Downloading s3fs-2023.9.0-py3-none-any.whl.metadata (1.6 kB)
  Downloading s3fs-2023.6.0-py3-none-any.whl.metadata (1.6 kB)
Collecting botocore<1.31.18,>=1.31.17 (from aiobotocore~=2.5.4->s3fs->fsspec[s3]!=2021.07.0,>=0.8->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading botocore-1.31.17-py3-none-any.whl.metadata (5.9 kB)
Collecting aioitertools<1.0.0,>=0.5.1 (from aiobotocore~=2.5.4->s3fs->fsspec[s3]!=2021.07.0,>=0.8->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading aioitertools-0.12.0-py3-none-any.whl.metadata (3.8 kB)
Collecting jmespath<2.0.0,>=0.7.1 (from botocore<1.31.18,>=1.31.17->aiobotocore~=2.5.4->s3fs->fsspec[s3]!=2021.07.0,>=0.8->ome-zarr>=0.6.1->aicsimageio->lsfm-destripe->leonardo_toolset)
  Downloading jmespath-1.0.1-py3-none-any.whl.metadata (7.6 kB)
Collecting urllib3<3,>=1.21.1 (from requests->antspyx->lsfm-fuse->leonardo_toolset)
  Downloading urllib3-1.26.20-py2.py3-none-any.whl.metadata (50 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 50.1/50.1 kB 4.2 MB/s eta 0:00:00
Downloading leonardo_toolset-0.1.0-py2.py3-none-any.whl (6.0 kB)
Downloading lsfm_destripe-0.1.0-py2.py3-none-any.whl (21 kB)
Downloading lsfm_fuse-0.1.2-py2.py3-none-any.whl (50 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 50.5/50.5 kB 4.7 MB/s eta 0:00:00
Downloading aicsimageio-4.14.0-py2.py3-none-any.whl (138 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 138.7/138.7 kB 13.1 MB/s eta 0:00:00
Downloading antspyx-0.5.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 22.2/22.2 MB 88.4 MB/s eta 0:00:00
Downloading open3d-0.18.0-cp310-cp310-manylinux_2_27_x86_64.whl (399.7 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 399.7/399.7 MB 2.8 MB/s eta 0:00:00
Downloading SimpleITK-2.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (52.4 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 52.4/52.4 MB 13.0 MB/s eta 0:00:00
Downloading dash-2.18.2-py3-none-any.whl (7.8 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.8/7.8 MB 115.0 MB/s eta 0:00:00
Downloading dash_core_components-2.0.0-py3-none-any.whl (3.8 kB)
Downloading dash_html_components-2.0.0-py3-none-any.whl (4.1 kB)
Downloading dash_table-5.0.0-py3-none-any.whl (3.9 kB)
Downloading fsspec-2023.6.0-py3-none-any.whl (163 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 163.8/163.8 kB 17.2 MB/s eta 0:00:00
Downloading imagecodecs-2024.9.22-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (43.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 43.3/43.3 MB 14.9 MB/s eta 0:00:00
Downloading ipywidgets-8.1.5-py3-none-any.whl (139 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 139.8/139.8 kB 14.4 MB/s eta 0:00:00
Downloading lxml-4.9.4-cp310-cp310-manylinux_2_28_x86_64.whl (7.9 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.9/7.9 MB 121.3 MB/s eta 0:00:00
Downloading ome_types-0.5.3-py3-none-any.whl (248 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 248.4/248.4 kB 23.3 MB/s eta 0:00:00
Downloading ome_zarr-0.10.2-py3-none-any.whl (37 kB)
Downloading resource_backed_dask_array-0.1.0-py2.py3-none-any.whl (8.0 kB)
Downloading tifffile-2023.2.28-py3-none-any.whl (216 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 216.4/216.4 kB 15.2 MB/s eta 0:00:00
Downloading werkzeug-3.0.6-py3-none-any.whl (227 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 228.0/228.0 kB 21.3 MB/s eta 0:00:00
Downloading zarr-2.15.0-py3-none-any.whl (206 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 206.1/206.1 kB 19.7 MB/s eta 0:00:00
Downloading addict-2.4.0-py3-none-any.whl (3.8 kB)
Downloading ConfigArgParse-1.7-py3-none-any.whl (25 kB)
Downloading pyquaternion-0.9.9-py3-none-any.whl (14 kB)
Downloading xmlschema-3.4.3-py3-none-any.whl (417 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 417.8/417.8 kB 32.2 MB/s eta 0:00:00
Downloading comm-0.2.2-py3-none-any.whl (7.2 kB)
Downloading elementpath-4.6.0-py3-none-any.whl (239 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 239.8/239.8 kB 21.1 MB/s eta 0:00:00
Downloading numcodecs-0.13.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.6 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.6/8.6 MB 85.7 MB/s eta 0:00:00
Downloading pydantic_compat-0.1.2-py3-none-any.whl (13 kB)
Downloading widgetsnbextension-4.0.13-py3-none-any.whl (2.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.3/2.3 MB 63.4 MB/s eta 0:00:00
Downloading xsdata-24.3.1-py3-none-any.whl (224 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 224.1/224.1 kB 19.5 MB/s eta 0:00:00
Downloading distributed-2024.10.0-py3-none-any.whl (1.0 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.0/1.0 MB 52.7 MB/s eta 0:00:00
Downloading fasteners-0.19-py3-none-any.whl (18 kB)
Downloading retrying-1.3.4-py3-none-any.whl (11 kB)
Downloading jedi-0.19.2-py2.py3-none-any.whl (1.6 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.6/1.6 MB 60.9 MB/s eta 0:00:00
Downloading sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)
Downloading tblib-3.0.0-py3-none-any.whl (12 kB)
Downloading zict-3.0.0-py2.py3-none-any.whl (43 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 43.3/43.3 kB 3.9 MB/s eta 0:00:00
Downloading s3fs-2023.6.0-py3-none-any.whl (28 kB)
Downloading aiobotocore-2.5.4-py3-none-any.whl (73 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 73.4/73.4 kB 7.2 MB/s eta 0:00:00
Downloading aioitertools-0.12.0-py3-none-any.whl (24 kB)
Downloading botocore-1.31.17-py3-none-any.whl (11.1 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 11.1/11.1 MB 26.5 MB/s eta 0:00:00
Downloading urllib3-1.26.20-py2.py3-none-any.whl (144 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 144.2/144.2 kB 12.6 MB/s eta 0:00:00
Downloading jmespath-1.0.1-py3-none-any.whl (20 kB)
Building wheels for collected packages: asciitree
  Building wheel for asciitree (setup.py) ... done
  Created wheel for asciitree: filename=asciitree-0.3.3-py3-none-any.whl size=5034 sha256=d4e75f233d2011fb0cd427e83cb797dcfc3c67477aeaceac658287b0324cbcc3
  Stored in directory: /root/.cache/pip/wheels/7f/4e/be/1171b40f43b918087657ec57cf3b81fa1a2e027d8755baa184
Successfully built asciitree
Installing collected packages: sortedcontainers, SimpleITK, dash-table, dash-html-components, dash-core-components, asciitree, addict, zict, xsdata, widgetsnbextension, werkzeug, urllib3, tifffile, tblib, retrying, pyquaternion, numcodecs, lxml, jmespath, jedi, imagecodecs, fsspec, fasteners, elementpath, configargparse, comm, aioitertools, zarr, xmlschema, botocore, pydantic-compat, ipywidgets, distributed, dash, resource-backed-dask-array, ome-types, antspyx, aiobotocore, s3fs, open3d, ome-zarr, aicsimageio, lsfm-fuse, lsfm-destripe, leonardo_toolset
  Attempting uninstall: widgetsnbextension
    Found existing installation: widgetsnbextension 3.6.10
    Uninstalling widgetsnbextension-3.6.10:
      Successfully uninstalled widgetsnbextension-3.6.10
  Attempting uninstall: werkzeug
    Found existing installation: Werkzeug 3.1.3
    Uninstalling Werkzeug-3.1.3:
      Successfully uninstalled Werkzeug-3.1.3
  Attempting uninstall: urllib3
    Found existing installation: urllib3 2.2.3
    Uninstalling urllib3-2.2.3:
      Successfully uninstalled urllib3-2.2.3
  Attempting uninstall: tifffile
    Found existing installation: tifffile 2024.12.12
    Uninstalling tifffile-2024.12.12:
      Successfully uninstalled tifffile-2024.12.12
  Attempting uninstall: lxml
    Found existing installation: lxml 5.3.0
    Uninstalling lxml-5.3.0:
      Successfully uninstalled lxml-5.3.0
  Attempting uninstall: fsspec
    Found existing installation: fsspec 2024.10.0
    Uninstalling fsspec-2024.10.0:
      Successfully uninstalled fsspec-2024.10.0
  Attempting uninstall: ipywidgets
    Found existing installation: ipywidgets 7.7.1
    Uninstalling ipywidgets-7.7.1:
      Successfully uninstalled ipywidgets-7.7.1
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
gcsfs 2024.10.0 requires fsspec==2024.10.0, but you have fsspec 2023.6.0 which is incompatible.
Successfully installed SimpleITK-2.4.0 addict-2.4.0 aicsimageio-4.14.0 aiobotocore-2.5.4 aioitertools-0.12.0 antspyx-0.5.4 asciitree-0.3.3 botocore-1.31.17 comm-0.2.2 configargparse-1.7 dash-2.18.2 dash-core-components-2.0.0 dash-html-components-2.0.0 dash-table-5.0.0 distributed-2024.10.0 elementpath-4.6.0 fasteners-0.19 fsspec-2023.6.0 imagecodecs-2024.9.22 ipywidgets-8.1.5 jedi-0.19.2 jmespath-1.0.1 leonardo_toolset-0.1.0 lsfm-destripe-0.1.0 lsfm-fuse-0.1.2 lxml-4.9.4 numcodecs-0.13.1 ome-types-0.5.3 ome-zarr-0.10.2 open3d-0.18.0 pydantic-compat-0.1.2 pyquaternion-0.9.9 resource-backed-dask-array-0.1.0 retrying-1.3.4 s3fs-2023.6.0 sortedcontainers-2.4.0 tblib-3.0.0 tifffile-2023.2.28 urllib3-1.26.20 werkzeug-3.0.6 widgetsnbextension-4.0.13 xmlschema-3.4.3 xsdata-24.3.1 zarr-2.15.0 zict-3.0.0
[1]:
# load sample dataset
import pooch
from pathlib import Path
import tifffile

data_path = "./"

source_part1 = pooch.retrieve(
    url="https://zenodo.org/records/14215090/files/D1_I0.tif",
    known_hash="md5:ef10aa423ffc5175cd44284206794ec5",
    fname="D1_I0.tif",
    path=data_path / Path("download"),
)

source_part2 = pooch.retrieve(
    url="https://zenodo.org/records/14215090/files/D1_I1.tif",
    known_hash="md5:b3d68aea26ce0b1e26324f2f588207e0",
    fname="D1_I1.tif",
    path=data_path / Path("download"),
)

source_part3 = pooch.retrieve(
    url="https://zenodo.org/records/14215090/files/D2_I0.tif",
    known_hash="md5:83ad8c084f3e8f6d5753ee05a4378bdd",
    fname="D2_I0.tif",
    path=data_path / Path("download"),
)

source_part4 = pooch.retrieve(
    url="https://zenodo.org/records/14215090/files/D2_I1.tif",
    known_hash="md5:859a680fad7f86b61636a04d1971e787",
    fname="D2_I1.tif",
    path=data_path / Path("download"),
)

X_D1_I0 = tifffile.imread(source_part1)
X_D1_I1 = tifffile.imread(source_part2)
X_D2_I0 = tifffile.imread(source_part3)
X_D2_I1 = tifffile.imread(source_part4)

Start fusion#

First, let’s visualize the maximum intensity projection of the four datasets to figure out the orientation of the system:

[2]:
import matplotlib.pyplot as plt
import scipy

fig, (ax1, ax2, ax3, ax4) = plt.subplots(1, 4, dpi=150)
ax1.imshow(X_D1_I0.max(0), vmax = 2500)
ax1.set_title("MIP of X_D1_I0 in xy", fontsize=8, pad=1)
ax1.axis("off")
ax2.imshow(X_D1_I1.max(0), vmax = 2500)
ax2.set_title("MIP of X_D1_I1 in xy", fontsize=8, pad=1)
ax2.axis("off")
ax3.imshow(X_D2_I0.max(0), vmax = 2500)
ax3.set_title("MIP of X_D2_I0 in xy", fontsize=8, pad=1)
ax3.axis("off")
ax4.imshow(X_D2_I1.max(0), vmax = 2500)
ax4.set_title("MIP of X_D2_I1 in xy", fontsize=8, pad=1)
ax4.axis("off")
plt.show()

fig, (ax1, ax2, ax3, ax4) = plt.subplots(1, 4, dpi=150)
ax1.imshow(scipy.ndimage.zoom(X_D1_I0.max(1), (2.5, 0.65)), vmax = 2500)
ax1.set_title("MIP of X_D1_I0 in xz", fontsize=8, pad=1)
ax1.axis("off")
ax2.imshow(scipy.ndimage.zoom(X_D1_I1.max(1), (2.5, 0.65)), vmax = 2500)
ax2.set_title("MIP of X_D1_I1 in xz", fontsize=8, pad=1)
ax2.axis("off")
ax3.imshow(scipy.ndimage.zoom(X_D2_I0.max(1), (2.5, 0.65)), vmax = 2500)
ax3.set_title("MIP of X_D2_I0 in xz", fontsize=8, pad=1)
ax3.axis("off")
ax4.imshow(scipy.ndimage.zoom(X_D2_I1.max(1), (2.5, 0.65)), vmax = 2500)
ax4.set_title("MIP of X_D2_I1 in xz", fontsize=8, pad=1)
ax4.axis("off")
plt.show()
../../_images/tutorials_notebook_Leonardo_Fuse_(along_detection)_9_0.png
../../_images/tutorials_notebook_Leonardo_Fuse_(along_detection)_9_1.png

We can observe that:

  • the four datasets stand for:

    • X_D1_I0: illuminated from the top (in the image space) + recorded using ventral camera;

    • X_D1_I1: illuminated from the bottom (in the image space) + recorded using ventral camera;

    • X_D2_I0: illuminated from the bottom (in the image space) + recorded using dorsal camera;

    • X_D2_I1: illuminated from the top (in the image space) + recorded using dorsal camera;

  • two datasets recorded using dorsal camera, i.e., “D2”, need to be flipped vertically to be mapped into the same space as datasets recorded via ventral camera.

Next, we can initialize a FUSE_det object. Here, we initilize FUSE_det using default parameters. A more advanced list of available arguments can be found in section API reference

[3]:
from leonardo_toolset import FUSE_det

model = FUSE_det()
[Leonardo-Fuse] Backend: PyTorch | Device: cuda
[Leonardo-Fuse] Backend: PyTorch | Device: cuda
[Leonardo-Fuse] Backend: PyTorch | Device: cuda

Finally, we start fusion by calling train function. Four datasets are feded as top_illu_ventral_det_data, bottom_illu_ventral_det_data, top_illu_dorsal_det_data and bottom_illu_dorsal_det_data, respectively, corresponding to their illumination orientation and camera position. Since the datasets are well aligned alread, registration is not needed. Additionally, since we observed flipping vertically in the image space is required for stacks with dorsal camera in advance, require_flipping_along_illu_for_dorsaldet need to be True. The fusion result, together with a few intermidiate results, will be saved in folder save_folder under path save_path.

[4]:
# start fusion
save_path = "./"
save_folder = "fuse_det_result"

out = model.train(require_registration = False,
                  require_flipping_along_illu_for_dorsaldet = True,
                  require_flipping_along_det_for_dorsaldet = False,
                  top_illu_ventral_det_data = X_D1_I0,
                  bottom_illu_ventral_det_data = X_D1_I1,
                  top_illu_dorsal_det_data = X_D2_I1,
                  bottom_illu_dorsal_det_data = X_D2_I0,
                  save_path = save_path,
                  save_folder = save_folder,
                  )
Cannot skip dual-illu fusion for ventral det...
Cannot skip dual-illu fusion for dorsal det...

Fusion along illumination for ventral camera...
Read in...

Localize sample...
           startX    endX startY    endY         maxv
top             0    1024      0    1024  3454.000244
bottom          0    1024      0    1024  2523.999512
in summary    0.0  1024.0    0.0  1024.0  3454.000244
../../_images/tutorials_notebook_Leonardo_Fuse_(along_detection)_13_1.png

Calculate volumetric measurements...
top/left view: minimum intensity = 57.0, maximum intensity = 2537.0, OTSU threshold = 149.0
bottom/right view: minimum intensity = 61.0, maximum intensity = 2049.0, OTSU threshold = 144.0

Extract features...
NSCT: 100%|██████████| 250/250 [00:10<00:00, 24.59it/s]

Segment sample...
watershed (125): 100%|██████████| 250/250 [00:09<00:00, 25.18it/s]
refine pair-wise segmentation result: 100%|██████████| 250/250 [00:06<00:00, 39.98it/s]
refine along z: 100%|██████████| 2704/2704 [00:02<00:00, 1128.37it/s]

Dual-illumination fusion...
to GPU...
No.049 iteration EM: maximum changes = 1.0
Stitching...
fusion: 100%|██████████| 250/250 [00:14<00:00, 17.68it/s]
../../_images/tutorials_notebook_Leonardo_Fuse_(along_detection)_13_8.png
Save...

Fusion along illumination for dorsal camera...
Read in...

Localize sample...
           startX    endX startY    endY         maxv
top             0    1024      0    1024  3473.999756
bottom          0    1024      0    1024  5689.999023
in summary    0.0  1024.0    0.0  1024.0  5689.999023
../../_images/tutorials_notebook_Leonardo_Fuse_(along_detection)_13_10.png

Calculate volumetric measurements...
top/left view: minimum intensity = 56.0, maximum intensity = 2865.0, OTSU threshold = 148.0
bottom/right view: minimum intensity = 55.0, maximum intensity = 4530.0, OTSU threshold = 151.0

Extract features...
NSCT: 100%|██████████| 250/250 [00:09<00:00, 26.32it/s]

Segment sample...
watershed (77): 100%|██████████| 250/250 [00:11<00:00, 22.23it/s]
refine pair-wise segmentation result: 100%|██████████| 250/250 [00:06<00:00, 36.49it/s]
refine along z: 100%|██████████| 2704/2704 [00:03<00:00, 750.24it/s]

Dual-illumination fusion...
to GPU...
No.049 iteration EM: maximum changes = 1.0
Stitching...
fusion: 100%|██████████| 250/250 [00:14<00:00, 17.50it/s]
../../_images/tutorials_notebook_Leonardo_Fuse_(along_detection)_13_17.png
Save...

Localize sample...
read in...
           startX    endX startY    endY         maxv
ventral         0    1024      0    1024  5689.999023
dorsal          0    1024      0    1024  5689.999023
in summary    0.0  1024.0    0.0  1024.0  5689.999023
../../_images/tutorials_notebook_Leonardo_Fuse_(along_detection)_13_19.png
watershed: 100%|██████████| 250/250 [00:06<00:00, 37.63it/s]

For top/left Illu...
read in...
NSCT: 100%|██████████| 250/250 [00:09<00:00, 26.33it/s]
to GPU...
No.049 iteration EM: maximum changes = 1.0

For bottom/right Illu...
read in...
NSCT: 100%|██████████| 250/250 [00:09<00:00, 25.47it/s]
to GPU...
No.049 iteration EM: maximum changes = 1.0

Stitching...
read in...
intergrate fusion decision: 100%|██████████| 250/250 [00:15<00:00, 16.01it/s]
refine along z: 100%|██████████| 4761/4761 [00:04<00:00, 1057.26it/s]
fusion: 100%|██████████| 250/250 [00:50<00:00,  4.96it/s]
../../_images/tutorials_notebook_Leonardo_Fuse_(along_detection)_13_27.png
Save...

Note 1: inputs with file names provided#

In reality, to facilitate batch processing, users can also feed in data-to-be-fused without reading them into the memory. To do so, please save the data-to-be-fused in such structure:

data_path
    ├─ X_D1_I0.tif
    ├─ X_D1_I1.tif
    ├─ X_D2_I1.tif
    ├─ X_D2_I0.tif

and call the train function as follows:

out = model.train(data_path = data_path,
                  require_registration = False,
                  require_flipping_along_illu_for_dorsaldet = True,
                  require_flipping_along_det_for_dorsaldet = False,
                  top_illu_ventral_det_data = "X_D1_I0.tif",
                  bottom_illu_ventral_det_data = "X_D1_I1.tif",
                  top_illu_dorsal_det_data = "X_D2_I1.tif",
                  bottom_illu_dorsal_det_data = "X_D2_I0.tif",
                  save_path = save_path,
                  save_folder = save_folder,
                  )

Note 2: fuse datasets with left/right illumination orientations#

Depends on the system, the illumination orientation in then image space can also from left or right. In this way, input datasets should be called by left_illu_ventral_det_data, right_illu_ventral_det_data, left_illu_dorsal_det_data and right_illu_dorsal_det_data:

out = model.train(require_registration = False,
                  require_flipping_along_illu_for_dorsaldet = True,
                  require_flipping_along_det_for_dorsaldet = False,
                  left_illu_ventral_det_data = X_D1_I0,  # suppose X_D1_I0 is illuminated from the left
                  right_illu_ventral_det_data = X_D1_I1, # suppose X_D1_I1 is illuminated from the right
                  left_illu_dorsal_det_data = X_D2_I1, # suppose X_D2_I1 is illuminated from the left
                  right_illu_dorsal_det_data = X_D2_I0, # suppose X_D2_I0 is illuminated from the right
                  save_path = save_path,
                  save_folder = save_folder,
                  )

Note 3: intergrate with registration workflow#

In reality, the dorsal camera can be mimicked by rotating the specimen 180 degree, which eases sample mounting. Nevertheless, it requires the registration of the volumes imaged after rotation to those captured before rotation. In princple, we recommend that users of Leonardo-Fuse manually register the input stacks before-hand. Still, we offer automatic registration in FUSE_det, which can be enabled as following:

out = model.train(require_registration = True,
                  require_flipping_along_det_for_dorsaldet = True,
                  z_spacing = ...,
                  xy_spacing = ...,
                  ...
                  )

where require_flipping_along_det_for_dorsaldet is used in case the two datasets recorded after rotation is flipped along z, z_spacing and xy_spacing are axial and lateral resolution to be used for registration.

Note 4: fuse dual-side detection only#

Sometimes, in some special light-sheet based systems, for example Balze, the dual-sided illumination is fused on-the-fly. Thus, FUSE_det is only to fuse two datasets with opposing detecting orientations:

out = model.train(ventral_det_data = ...,
                  dorsal_det_data = ...,
                  left_right = ...,
                  ...
                  )

where ventral_det_data and dorsal_det_data are arguments for input datsets recorded using ventral camera or dorsal camera, respectively (could also be before/after rotation). left_right is a boolean arguments to say whether, in the image space, the illumination orientation is from left and right, or top and bottom.

Note 5: fuse extremely large datasets#

Since light-sheet microscopy is especially helpful to image extremely large specimen, Leonardo offers solution to fuse extremely huge datasets. The key idea is to train the fusion algorithm in a downsampled space, and then apply it to the datasets with full resolution:

out = model.train(ventral_det_data = ...,
                  dorsal_det_data = ...,
                  left_right = ...,
                  xy_downsample_ratio = .., # the downsampling ratio along xy to trainthe low-resolution fusion model
                  z_downsample_ratio = .., # the downsampling ratio along z to trainthe low-resolution fusion model
                  )

for now, it only supports to fuse extremely large datasets acquired using Balze system, i.e., with illumination fused on-the-fly.