multiview-stitcher


Namemultiview-stitcher JSON
Version 0.1.17 PyPI version JSON
download
home_pagehttps://github.com/multiview-stitcher/multiview-stitcher
SummaryRegistration and fusion of large imaging datasets in 2D and 3D.
upload_time2024-09-19 11:19:58
maintainerNone
docs_urlNone
authorMarvin Albert
requires_python>=3.9
licenseBSD-3-Clause
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![License {{cookiecutter.license}}](https://img.shields.io/pypi/l/multiview-stitcher.svg?color=green)](https://github.com/multiview-stitcher/multiview-stitcher/raw/main/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/multiview-stitcher.svg?color=green)](https://pypi.org/project/multiview-stitcher)
[![Python Version](https://img.shields.io/pypi/pyversions/multiview-stitcher.svg?color=green)](https://python.org)
[![tests](https://github.com/multiview-stitcher/multiview-stitcher/actions/workflows/test_and_deploy.yml/badge.svg)](https://github.com/multiview-stitcher/multiview-stitcher/actions)
[![DOI](https://zenodo.org/badge/697999800.svg)](https://zenodo.org/doi/10.5281/zenodo.13151252)


# multiview-stitcher

<!--
[![License BSD-3](https://img.shields.io/pypi/l/multiview-stitcher.svg?color=green)](https://github.com/multiview-stitcher/multiview-stitcher/raw/main/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/multiview-stitcher.svg?color=green)](https://pypi.org/project/multiview-stitcher)
[![Python Version](https://img.shields.io/pypi/pyversions/multiview-stitcher.svg?color=green)](https://python.org)
[![tests](https://github.com/multiview-stitcher/multiview-stitcher/workflows/tests/badge.svg)](https://github.com/multiview-stitcher/multiview-stitcher/actions)
[![codecov](https://codecov.io/gh/multiview-stitcher/multiview-stitcher/branch/main/graph/badge.svg)](https://codecov.io/gh/multiview-stitcher/multiview-stitcher)
-->

[`multiview-stitcher`](https://github.com/multiview-stitcher/multiview-sticher) is an open-source modular toolbox for distributed and tiled stitching of 2-3D image data in python. It is a collection of algorithms (under development) to **register** and **fuse** small and large datasets from **multi-positioning** and **multi-view** light sheet microscopy, as well as **other modalities** such as correlative cryo-EM datasets.

For visualization, the associated [`napari-stitcher`](https://github.com/multiview-stitcher/napari-stitcher) provides visualization functionality using the Napari viewer, including a standalone widget.

With a focus on interoperability and integration with existing tools and the ecosystem, the package intends to integrate as tightly as possible with the [NGFF specification](https://github.com/ome/ngff).

It leverages [`xarray`](https://github.com/xarray) in combination with [`spatial-image`](https://github.com/spatial-data) and [`multiscale-spatial-image`](https://github.com/spatial-image/multiscale-spatial-image) for image handling and [`dask`](https://github.com/dask) and [`dask-image`](https://github.com/dask-image) for chunked and distributed image processing.

## Quickstart

### Notebooks

Check out the [example notebooks](https://github.com/multiview-stitcher/multiview-stitcher/tree/main/notebooks).

### Napari plugin

There's an associated napari plugin: [napari-stitcher](https://github.com/multiview-stitcher/napari-stitcher).

![](https://github.com/multiview-stitcher/napari-stitcher/blob/dc6b571049c971709eb41064930be9b880d806f4/misc-data/20230929_screenshot.png)

Image data by [Arthur Michaut](https://research.pasteur.fr/fr/member/arthur-michaut/) @ [Jérôme Gros Lab](https://research.pasteur.fr/fr/team/dynamic-regulation-of-morphogenesis/) @ Institut Pasteur.

### Code example

These code snippets walk you through a small stitching workflow consisting of
1) Preparing the input image data and metadata (tile positions, spacing, channels)
2) Registering the tiles
3) Stitching / fusing the tiles

#### 1) Prepare data for stitching


```python
import numpy as np
from multiview_stitcher import msi_utils
from multiview_stitcher import spatial_image_utils as si_utils

# input data (can be any numpy compatible array: numpy, dask, cupy, etc.)
tile_arrays = [np.random.randint(0, 100, (2, 10, 100, 100)) for _ in range(3)]

# indicate the tile offsets and spacing
tile_translations = [
    {"z": 2.5, "y": -10, "x": 30},
    {"z": 2.5, "y": 30, "x": 10},
    {"z": 2.5, "y": 30, "x": 50},
]
spacing = {"z": 2, "y": 0.5, "x": 0.5}

channels = ["DAPI", "GFP"]

# build input for stitching
msims = []
for tile_array, tile_translation in zip(tile_arrays, tile_translations):
    sim = si_utils.get_sim_from_array(
        tile_array,
        dims=["c", "z", "y", "x"],
        scale=spacing,
        translation=tile_translation,
        transform_key="stage_metadata",
        c_coords=channels,
    )
    msims.append(msi_utils.get_msim_from_sim(sim, scale_factors=[]))

# plot the tile configuration
# from multiview_stitcher import vis_utils
# fig, ax = vis_utils.plot_positions(msims, transform_key='stage_metadata', use_positional_colors=False)
```

![Visualization of input tile configuration](docs/images/tile_configuration.png)

#### 2) Register the tiles

```python
from dask.diagnostics import ProgressBar
from multiview_stitcher import registration

with ProgressBar():
    params = registration.register(
        msims,
        reg_channel="DAPI",  # channel to use for registration
        transform_key="stage_metadata",
        new_transform_key="translation_registered",
    )

# plot the tile configuration after registration
# vis_utils.plot_positions(msims, transform_key='translation_registered', use_positional_colors=False)
```

#### 3) Stitch / fuse the tiles
```python
from multiview_stitcher import fusion

fused_sim = fusion.fuse(
    [msi_utils.get_sim_from_msim(msim) for msim in msims],
    transform_key="translation_registered",
)

# get fused array as a dask array
fused_sim.data

# get fused array as a numpy array
fused_sim.data.compute()
```

----------------------------------
## Installation

You can install `multiview-stitcher` via `pip` from PyPI:

    pip install multiview-stitcher

or from the source code in this github repository:

    pip install git+https://github.com/multiview-stitcher/multiview-stitcher.git

## Stitching in the browser

`multiview-stitcher` can run without installation in your browser.

### Try it out

- open [JupyterLite](https://jupyter.org/try-jupyter/lab/) in a private browser window
- upload this notebook into the jupyter lab window: [notebooks/stitching_in_the_browser.ipynb](https://github.com/multiview-stitcher/multiview-stitcher/tree/main/notebooks/stitching_in_the_browser.ipynb)
- upload files to stitch into a 'data' folder in the jupyter lab window
- follow the notebook

#### Limitations
- stitching will run with a single thread
- while the code runs locally, your local file system is not directly accessible from within the browser environment

## Work in progress

WARNING: THIS IS WORK IN PROGRESS. `multiview-stitcher` is being developed in the open and has not reached a stable release yet. The API is subject to change.

## Previous work

`multiview-stitcher` improves and replaces [MVRegFUS](https://github.com/m-albert/MVRegFus).

## Issues

If you encounter any problems, please [file an issue](https://github.com/multiview-stitcher/multiview-stitcher/issues) along with a detailed description.

## Contributing

Contributions are welcome.

## License

Distributed under the terms of the BSD-3 license,
"multiview-stitcher" is free and open source software.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/multiview-stitcher/multiview-stitcher",
    "name": "multiview-stitcher",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Marvin Albert",
    "author_email": "marvin.albert@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/67/c8/e9a2c6b231b94e0ca8ea623dba507af52d6b5db85c79d1eb45f8b8d0f561/multiview_stitcher-0.1.17.tar.gz",
    "platform": null,
    "description": "[![License {{cookiecutter.license}}](https://img.shields.io/pypi/l/multiview-stitcher.svg?color=green)](https://github.com/multiview-stitcher/multiview-stitcher/raw/main/LICENSE)\n[![PyPI](https://img.shields.io/pypi/v/multiview-stitcher.svg?color=green)](https://pypi.org/project/multiview-stitcher)\n[![Python Version](https://img.shields.io/pypi/pyversions/multiview-stitcher.svg?color=green)](https://python.org)\n[![tests](https://github.com/multiview-stitcher/multiview-stitcher/actions/workflows/test_and_deploy.yml/badge.svg)](https://github.com/multiview-stitcher/multiview-stitcher/actions)\n[![DOI](https://zenodo.org/badge/697999800.svg)](https://zenodo.org/doi/10.5281/zenodo.13151252)\n\n\n# multiview-stitcher\n\n<!--\n[![License BSD-3](https://img.shields.io/pypi/l/multiview-stitcher.svg?color=green)](https://github.com/multiview-stitcher/multiview-stitcher/raw/main/LICENSE)\n[![PyPI](https://img.shields.io/pypi/v/multiview-stitcher.svg?color=green)](https://pypi.org/project/multiview-stitcher)\n[![Python Version](https://img.shields.io/pypi/pyversions/multiview-stitcher.svg?color=green)](https://python.org)\n[![tests](https://github.com/multiview-stitcher/multiview-stitcher/workflows/tests/badge.svg)](https://github.com/multiview-stitcher/multiview-stitcher/actions)\n[![codecov](https://codecov.io/gh/multiview-stitcher/multiview-stitcher/branch/main/graph/badge.svg)](https://codecov.io/gh/multiview-stitcher/multiview-stitcher)\n-->\n\n[`multiview-stitcher`](https://github.com/multiview-stitcher/multiview-sticher) is an open-source modular toolbox for distributed and tiled stitching of 2-3D image data in python. It is a collection of algorithms (under development) to **register** and **fuse** small and large datasets from **multi-positioning** and **multi-view** light sheet microscopy, as well as **other modalities** such as correlative cryo-EM datasets.\n\nFor visualization, the associated [`napari-stitcher`](https://github.com/multiview-stitcher/napari-stitcher) provides visualization functionality using the Napari viewer, including a standalone widget.\n\nWith a focus on interoperability and integration with existing tools and the ecosystem, the package intends to integrate as tightly as possible with the [NGFF specification](https://github.com/ome/ngff).\n\nIt leverages [`xarray`](https://github.com/xarray) in combination with [`spatial-image`](https://github.com/spatial-data) and [`multiscale-spatial-image`](https://github.com/spatial-image/multiscale-spatial-image) for image handling and [`dask`](https://github.com/dask) and [`dask-image`](https://github.com/dask-image) for chunked and distributed image processing.\n\n## Quickstart\n\n### Notebooks\n\nCheck out the [example notebooks](https://github.com/multiview-stitcher/multiview-stitcher/tree/main/notebooks).\n\n### Napari plugin\n\nThere's an associated napari plugin: [napari-stitcher](https://github.com/multiview-stitcher/napari-stitcher).\n\n![](https://github.com/multiview-stitcher/napari-stitcher/blob/dc6b571049c971709eb41064930be9b880d806f4/misc-data/20230929_screenshot.png)\n\nImage data by [Arthur Michaut](https://research.pasteur.fr/fr/member/arthur-michaut/) @ [J\u00e9r\u00f4me Gros Lab](https://research.pasteur.fr/fr/team/dynamic-regulation-of-morphogenesis/) @ Institut Pasteur.\n\n### Code example\n\nThese code snippets walk you through a small stitching workflow consisting of\n1) Preparing the input image data and metadata (tile positions, spacing, channels)\n2) Registering the tiles\n3) Stitching / fusing the tiles\n\n#### 1) Prepare data for stitching\n\n\n```python\nimport numpy as np\nfrom multiview_stitcher import msi_utils\nfrom multiview_stitcher import spatial_image_utils as si_utils\n\n# input data (can be any numpy compatible array: numpy, dask, cupy, etc.)\ntile_arrays = [np.random.randint(0, 100, (2, 10, 100, 100)) for _ in range(3)]\n\n# indicate the tile offsets and spacing\ntile_translations = [\n    {\"z\": 2.5, \"y\": -10, \"x\": 30},\n    {\"z\": 2.5, \"y\": 30, \"x\": 10},\n    {\"z\": 2.5, \"y\": 30, \"x\": 50},\n]\nspacing = {\"z\": 2, \"y\": 0.5, \"x\": 0.5}\n\nchannels = [\"DAPI\", \"GFP\"]\n\n# build input for stitching\nmsims = []\nfor tile_array, tile_translation in zip(tile_arrays, tile_translations):\n    sim = si_utils.get_sim_from_array(\n        tile_array,\n        dims=[\"c\", \"z\", \"y\", \"x\"],\n        scale=spacing,\n        translation=tile_translation,\n        transform_key=\"stage_metadata\",\n        c_coords=channels,\n    )\n    msims.append(msi_utils.get_msim_from_sim(sim, scale_factors=[]))\n\n# plot the tile configuration\n# from multiview_stitcher import vis_utils\n# fig, ax = vis_utils.plot_positions(msims, transform_key='stage_metadata', use_positional_colors=False)\n```\n\n![Visualization of input tile configuration](docs/images/tile_configuration.png)\n\n#### 2) Register the tiles\n\n```python\nfrom dask.diagnostics import ProgressBar\nfrom multiview_stitcher import registration\n\nwith ProgressBar():\n    params = registration.register(\n        msims,\n        reg_channel=\"DAPI\",  # channel to use for registration\n        transform_key=\"stage_metadata\",\n        new_transform_key=\"translation_registered\",\n    )\n\n# plot the tile configuration after registration\n# vis_utils.plot_positions(msims, transform_key='translation_registered', use_positional_colors=False)\n```\n\n#### 3) Stitch / fuse the tiles\n```python\nfrom multiview_stitcher import fusion\n\nfused_sim = fusion.fuse(\n    [msi_utils.get_sim_from_msim(msim) for msim in msims],\n    transform_key=\"translation_registered\",\n)\n\n# get fused array as a dask array\nfused_sim.data\n\n# get fused array as a numpy array\nfused_sim.data.compute()\n```\n\n----------------------------------\n## Installation\n\nYou can install `multiview-stitcher` via `pip` from PyPI:\n\n    pip install multiview-stitcher\n\nor from the source code in this github repository:\n\n    pip install git+https://github.com/multiview-stitcher/multiview-stitcher.git\n\n## Stitching in the browser\n\n`multiview-stitcher` can run without installation in your browser.\n\n### Try it out\n\n- open [JupyterLite](https://jupyter.org/try-jupyter/lab/) in a private browser window\n- upload this notebook into the jupyter lab window: [notebooks/stitching_in_the_browser.ipynb](https://github.com/multiview-stitcher/multiview-stitcher/tree/main/notebooks/stitching_in_the_browser.ipynb)\n- upload files to stitch into a 'data' folder in the jupyter lab window\n- follow the notebook\n\n#### Limitations\n- stitching will run with a single thread\n- while the code runs locally, your local file system is not directly accessible from within the browser environment\n\n## Work in progress\n\nWARNING: THIS IS WORK IN PROGRESS. `multiview-stitcher` is being developed in the open and has not reached a stable release yet. The API is subject to change.\n\n## Previous work\n\n`multiview-stitcher` improves and replaces [MVRegFUS](https://github.com/m-albert/MVRegFus).\n\n## Issues\n\nIf you encounter any problems, please [file an issue](https://github.com/multiview-stitcher/multiview-stitcher/issues) along with a detailed description.\n\n## Contributing\n\nContributions are welcome.\n\n## License\n\nDistributed under the terms of the BSD-3 license,\n\"multiview-stitcher\" is free and open source software.\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Registration and fusion of large imaging datasets in 2D and 3D.",
    "version": "0.1.17",
    "project_urls": {
        "Bug Tracker": "https://github.com/multiview-stitcher/multiview-stitcher/issues",
        "Documentation": "https://github.com/multiview-stitcher/multiview-stitcher#README.md",
        "Homepage": "https://github.com/multiview-stitcher/multiview-stitcher",
        "Source Code": "https://github.com/multiview-stitcher/multiview-stitcher",
        "User Support": "https://github.com/multiview-stitcher/multiview-stitcher/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c7b3c074c348529a1e85842a1beb456e448eb66f48285ee9a998b2deee368ce0",
                "md5": "974404d705af26d2d1fde3d412370a24",
                "sha256": "25d961cf788fb814c1685daf0238f5efc8f0fc74f4493b9fbf9063e646bbbee3"
            },
            "downloads": -1,
            "filename": "multiview_stitcher-0.1.17-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "974404d705af26d2d1fde3d412370a24",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 2062974,
            "upload_time": "2024-09-19T11:19:56",
            "upload_time_iso_8601": "2024-09-19T11:19:56.214474Z",
            "url": "https://files.pythonhosted.org/packages/c7/b3/c074c348529a1e85842a1beb456e448eb66f48285ee9a998b2deee368ce0/multiview_stitcher-0.1.17-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "67c8e9a2c6b231b94e0ca8ea623dba507af52d6b5db85c79d1eb45f8b8d0f561",
                "md5": "70cc24ba772ffaaead91c66af9df31d6",
                "sha256": "49bdfa95f034813fd7860aa71b2e4da7fdf52df607e9d556ef2144636620468a"
            },
            "downloads": -1,
            "filename": "multiview_stitcher-0.1.17.tar.gz",
            "has_sig": false,
            "md5_digest": "70cc24ba772ffaaead91c66af9df31d6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 4122565,
            "upload_time": "2024-09-19T11:19:58",
            "upload_time_iso_8601": "2024-09-19T11:19:58.144077Z",
            "url": "https://files.pythonhosted.org/packages/67/c8/e9a2c6b231b94e0ca8ea623dba507af52d6b5db85c79d1eb45f8b8d0f561/multiview_stitcher-0.1.17.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-19 11:19:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "multiview-stitcher",
    "github_project": "multiview-stitcher",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "multiview-stitcher"
}
        
Elapsed time: 0.52419s