napari-time-slicer


Namenapari-time-slicer JSON
Version 0.5.0 PyPI version JSON
download
home_pagehttps://github.com/haesleinhuepf/napari-time-slicer
SummaryA meta plugin for processing timelapse data in napari timepoint by timepoint
upload_time2023-11-12 15:27:13
maintainer
docs_urlNone
authorRobert Haase
requires_python>=3.8
licenseBSD-3-Clause
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # napari-time-slicer

[![License](https://img.shields.io/pypi/l/napari-time-slicer.svg?color=green)](https://github.com/haesleinhuepf/napari-time-slicer/raw/main/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/napari-time-slicer.svg?color=green)](https://pypi.org/project/napari-time-slicer)
[![Python Version](https://img.shields.io/pypi/pyversions/napari-time-slicer.svg?color=green)](https://python.org)
[![tests](https://github.com/haesleinhuepf/napari-time-slicer/workflows/tests/badge.svg)](https://github.com/haesleinhuepf/napari-time-slicer/actions)
[![codecov](https://codecov.io/gh/haesleinhuepf/napari-time-slicer/branch/main/graph/badge.svg)](https://codecov.io/gh/haesleinhuepf/napari-time-slicer)
[![Development Status](https://img.shields.io/pypi/status/napari-time-slicer.svg)](https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha)
[![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/napari-time-slicer)](https://napari-hub.org/plugins/napari-time-slicer)

A meta plugin for processing timelapse data timepoint by timepoint. It 
enables a list of napari plugins to process 2D+t or 3D+t data step by step when the user goes 
through the timelapse. Currently, these plugins are using `napari-time-slicer`:
* [napari-segment-blobs-and-things-with-membranes](https://www.napari-hub.org/plugins/napari-segment-blobs-and-things-with-membranes)
* [napari-cupy-image-processing](https://www.napari-hub.org/plugins/napari-cupy-image-processing)
* [napari-pyclesperanto-assistant](https://www.napari-hub.org/plugins/napari-pyclesperanto-assistant)
* [napari-accelerated-pixel-and-object-classification](https://www.napari-hub.org/plugins/napari-accelerated-pixel-and-object-classification)
* [napari-simpleitk-image-processing](https://www.napari-hub.org/plugins/napari-simpleitk-image-processing)
* [napari-stress](https://www.napari-hub.org/plugins/napari-stress)
* [napari-process-points-and-surfaces](https://www.napari-hub.org/plugins/napari-process-points-and-surfaces)

`napari-time-slicer` enables inter-plugin communication, e.g. allowing to combine the plugins listed above in 
one image processing workflow for segmenting a timelapse dataset:

![](https://github.com/haesleinhuepf/napari-time-slicer/raw/main/images/screencast1.gif)

The workflow can then also be exported as a script. The 'Generate Code' button can be found in the [Workflow Inspector](https://www.napari-hub.org/plugins/napari-workflow-inspector)


If you want to convert a 3D dataset into a 2D + time dataset, use the 
menu `Tools > Utilities > Convert 3D stack to 2D timelapse (time-slicer)`. It will turn the 3D dataset to a 4D datset
where the Z-dimension (index 1) has only 1 element, which will in napari be displayed with a time-slider. Note: It is 
recommended to remove the original 3D dataset after this conversion.

## Working with large on-the-fly processed datasets

Using the [napari-assistant](https://www.napari-hub.org/plugins/napari-assistant) complex image processing workflows on timelapse datasets can be setup. 
In combination with the time-slicer it is possible to process time-lapse data that is larger than available computer memory.
In case the workflow only consists of images and label-images and out-of-memory issues arise, consider storing intermediate results on disk following this procedure: 
After setting up the workflow and testing it on a couple of selected frames, store the entire processed timelapse dataset to disk 
using the menu `Tools > Utilities > Convert to file-backed timelapse data (time-slicer)`. It will open this dialog, where you can select 
![img.png](https://github.com/haesleinhuepf/napari-time-slicer/raw/main/images/convert_to_file_backed_timelapse.png)

It is recommended to enter a folder location in the text field. 
If not provided, a temporary folder will be created, typically in the User's temp folder in the home directory. 
The user is responsible for emptying this folder from time to time.
The data stored in this folder can also be loaded into napari using its `File > Open Folder...` menu.

Executing this operation can take time as every timepoint of the timelapse is computed. 
Afterwards, there will be another layer available in napari, which is typically faster to navigate through. 
Consider removing the layer(s) that were only needed to determine the new file-backed layer.

![img.png](https://github.com/haesleinhuepf/napari-time-slicer/raw/main/images/new_file_backed_layer.png)

## Usage for plugin developers

Plugins which implement the `napari_experimental_provide_function` hook can make use of the `@time_slicer`. At the moment,
only functions which take `napari.types.ImageData`, `napari.types.LabelsData` and basic python types such as `int` 
and `float` are supported. If you annotate such a function with `@time_slicer` it will internally convert any 4D dataset
to a 3D dataset according to the timepoint currently selected in napari. Furthermore, when the napari user changes the
current timepoint or the input data of the function changes, a re-computation is invoked. Thus, it is recommended to 
only use the `time_slicer` for functions which can provide [almost] real-time performance. Another constraint is that 
these annotated functions have to have a `viewer` parameter. This is necessary to read the current timepoint from the 
viewer when invoking the re-computions.

Example
```python
import napari
from napari_time_slicer import time_slicer

@time_slicer
def threshold_otsu(image:napari.types.ImageData, viewer: napari.Viewer = None) -> napari.types.LabelsData:
    # ...
```

You can see a full implementations of this concept in the napari plugins listed above.

If you want to combine slicing in time and processing z-stack images slice-by-slice, you can use the `@slice_by_slice` annotation.
Make sure, to insert it after `@time_slicer` as shown below and implemented in [napari-pillow-image-processing](https://github.com/haesleinhuepf/napari-pillow-image-processing/blob/4d846b226739843124953f16059241d917cde8e1/src/napari_pillow_image_processing/__init__.py#L151)

```python
from napari_time_slicer import slice_by_slice

@time_slicer
@slice_by_slice
def blur_2d(image:napari.types.ImageData, sigma:float = 1, viewer: napari.Viewer = None) -> napari.types.LabelsData:
    # ...
```

----------------------------------

This [napari] plugin was generated with [Cookiecutter] using [@napari]'s [cookiecutter-napari-plugin] template.

## Installation

You can install `napari-time-slicer` via [pip]:

    pip install napari-time-slicer



To install latest development version :

    pip install git+https://github.com/haesleinhuepf/napari-time-slicer.git


## Contributing

Contributions are very welcome. Tests can be run with [tox], please ensure
the coverage at least stays the same before you submit a pull request.

## License

Distributed under the terms of the [BSD-3] license,
"napari-time-slicer" is free and open source software

## Issues

If you encounter any problems, please [file an issue] along with a detailed description.

[napari]: https://github.com/napari/napari
[Cookiecutter]: https://github.com/audreyr/cookiecutter
[@napari]: https://github.com/napari
[MIT]: http://opensource.org/licenses/MIT
[BSD-3]: http://opensource.org/licenses/BSD-3-Clause
[GNU GPL v3.0]: http://www.gnu.org/licenses/gpl-3.0.txt
[GNU LGPL v3.0]: http://www.gnu.org/licenses/lgpl-3.0.txt
[Apache Software License 2.0]: http://www.apache.org/licenses/LICENSE-2.0
[Mozilla Public License 2.0]: https://www.mozilla.org/media/MPL/2.0/index.txt
[cookiecutter-napari-plugin]: https://github.com/napari/cookiecutter-napari-plugin

[file an issue]: https://github.com/haesleinhuepf/napari-time-slicer/issues

[napari]: https://github.com/napari/napari
[tox]: https://tox.readthedocs.io/en/latest/
[pip]: https://pypi.org/project/pip/
[PyPI]: https://pypi.org/

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/haesleinhuepf/napari-time-slicer",
    "name": "napari-time-slicer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Robert Haase",
    "author_email": "robert.haase@tu-dresden.de",
    "download_url": "https://files.pythonhosted.org/packages/f0/7e/4bc75a41176ba66cdefb0b1ccb861e676f2c9cc3427ee1572f748d2905fc/napari-time-slicer-0.5.0.tar.gz",
    "platform": null,
    "description": "# napari-time-slicer\r\n\r\n[![License](https://img.shields.io/pypi/l/napari-time-slicer.svg?color=green)](https://github.com/haesleinhuepf/napari-time-slicer/raw/main/LICENSE)\r\n[![PyPI](https://img.shields.io/pypi/v/napari-time-slicer.svg?color=green)](https://pypi.org/project/napari-time-slicer)\r\n[![Python Version](https://img.shields.io/pypi/pyversions/napari-time-slicer.svg?color=green)](https://python.org)\r\n[![tests](https://github.com/haesleinhuepf/napari-time-slicer/workflows/tests/badge.svg)](https://github.com/haesleinhuepf/napari-time-slicer/actions)\r\n[![codecov](https://codecov.io/gh/haesleinhuepf/napari-time-slicer/branch/main/graph/badge.svg)](https://codecov.io/gh/haesleinhuepf/napari-time-slicer)\r\n[![Development Status](https://img.shields.io/pypi/status/napari-time-slicer.svg)](https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha)\r\n[![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/napari-time-slicer)](https://napari-hub.org/plugins/napari-time-slicer)\r\n\r\nA meta plugin for processing timelapse data timepoint by timepoint. It \r\nenables a list of napari plugins to process 2D+t or 3D+t data step by step when the user goes \r\nthrough the timelapse. Currently, these plugins are using `napari-time-slicer`:\r\n* [napari-segment-blobs-and-things-with-membranes](https://www.napari-hub.org/plugins/napari-segment-blobs-and-things-with-membranes)\r\n* [napari-cupy-image-processing](https://www.napari-hub.org/plugins/napari-cupy-image-processing)\r\n* [napari-pyclesperanto-assistant](https://www.napari-hub.org/plugins/napari-pyclesperanto-assistant)\r\n* [napari-accelerated-pixel-and-object-classification](https://www.napari-hub.org/plugins/napari-accelerated-pixel-and-object-classification)\r\n* [napari-simpleitk-image-processing](https://www.napari-hub.org/plugins/napari-simpleitk-image-processing)\r\n* [napari-stress](https://www.napari-hub.org/plugins/napari-stress)\r\n* [napari-process-points-and-surfaces](https://www.napari-hub.org/plugins/napari-process-points-and-surfaces)\r\n\r\n`napari-time-slicer` enables inter-plugin communication, e.g. allowing to combine the plugins listed above in \r\none image processing workflow for segmenting a timelapse dataset:\r\n\r\n![](https://github.com/haesleinhuepf/napari-time-slicer/raw/main/images/screencast1.gif)\r\n\r\nThe workflow can then also be exported as a script. The 'Generate Code' button can be found in the [Workflow Inspector](https://www.napari-hub.org/plugins/napari-workflow-inspector)\r\n\r\n\r\nIf you want to convert a 3D dataset into a 2D + time dataset, use the \r\nmenu `Tools > Utilities > Convert 3D stack to 2D timelapse (time-slicer)`. It will turn the 3D dataset to a 4D datset\r\nwhere the Z-dimension (index 1) has only 1 element, which will in napari be displayed with a time-slider. Note: It is \r\nrecommended to remove the original 3D dataset after this conversion.\r\n\r\n## Working with large on-the-fly processed datasets\r\n\r\nUsing the [napari-assistant](https://www.napari-hub.org/plugins/napari-assistant) complex image processing workflows on timelapse datasets can be setup. \r\nIn combination with the time-slicer it is possible to process time-lapse data that is larger than available computer memory.\r\nIn case the workflow only consists of images and label-images and out-of-memory issues arise, consider storing intermediate results on disk following this procedure: \r\nAfter setting up the workflow and testing it on a couple of selected frames, store the entire processed timelapse dataset to disk \r\nusing the menu `Tools > Utilities > Convert to file-backed timelapse data (time-slicer)`. It will open this dialog, where you can select \r\n![img.png](https://github.com/haesleinhuepf/napari-time-slicer/raw/main/images/convert_to_file_backed_timelapse.png)\r\n\r\nIt is recommended to enter a folder location in the text field. \r\nIf not provided, a temporary folder will be created, typically in the User's temp folder in the home directory. \r\nThe user is responsible for emptying this folder from time to time.\r\nThe data stored in this folder can also be loaded into napari using its `File > Open Folder...` menu.\r\n\r\nExecuting this operation can take time as every timepoint of the timelapse is computed. \r\nAfterwards, there will be another layer available in napari, which is typically faster to navigate through. \r\nConsider removing the layer(s) that were only needed to determine the new file-backed layer.\r\n\r\n![img.png](https://github.com/haesleinhuepf/napari-time-slicer/raw/main/images/new_file_backed_layer.png)\r\n\r\n## Usage for plugin developers\r\n\r\nPlugins which implement the `napari_experimental_provide_function` hook can make use of the `@time_slicer`. At the moment,\r\nonly functions which take `napari.types.ImageData`, `napari.types.LabelsData` and basic python types such as `int` \r\nand `float` are supported. If you annotate such a function with `@time_slicer` it will internally convert any 4D dataset\r\nto a 3D dataset according to the timepoint currently selected in napari. Furthermore, when the napari user changes the\r\ncurrent timepoint or the input data of the function changes, a re-computation is invoked. Thus, it is recommended to \r\nonly use the `time_slicer` for functions which can provide [almost] real-time performance. Another constraint is that \r\nthese annotated functions have to have a `viewer` parameter. This is necessary to read the current timepoint from the \r\nviewer when invoking the re-computions.\r\n\r\nExample\r\n```python\r\nimport napari\r\nfrom napari_time_slicer import time_slicer\r\n\r\n@time_slicer\r\ndef threshold_otsu(image:napari.types.ImageData, viewer: napari.Viewer = None) -> napari.types.LabelsData:\r\n    # ...\r\n```\r\n\r\nYou can see a full implementations of this concept in the napari plugins listed above.\r\n\r\nIf you want to combine slicing in time and processing z-stack images slice-by-slice, you can use the `@slice_by_slice` annotation.\r\nMake sure, to insert it after `@time_slicer` as shown below and implemented in [napari-pillow-image-processing](https://github.com/haesleinhuepf/napari-pillow-image-processing/blob/4d846b226739843124953f16059241d917cde8e1/src/napari_pillow_image_processing/__init__.py#L151)\r\n\r\n```python\r\nfrom napari_time_slicer import slice_by_slice\r\n\r\n@time_slicer\r\n@slice_by_slice\r\ndef blur_2d(image:napari.types.ImageData, sigma:float = 1, viewer: napari.Viewer = None) -> napari.types.LabelsData:\r\n    # ...\r\n```\r\n\r\n----------------------------------\r\n\r\nThis [napari] plugin was generated with [Cookiecutter] using [@napari]'s [cookiecutter-napari-plugin] template.\r\n\r\n## Installation\r\n\r\nYou can install `napari-time-slicer` via [pip]:\r\n\r\n    pip install napari-time-slicer\r\n\r\n\r\n\r\nTo install latest development version :\r\n\r\n    pip install git+https://github.com/haesleinhuepf/napari-time-slicer.git\r\n\r\n\r\n## Contributing\r\n\r\nContributions are very welcome. Tests can be run with [tox], please ensure\r\nthe coverage at least stays the same before you submit a pull request.\r\n\r\n## License\r\n\r\nDistributed under the terms of the [BSD-3] license,\r\n\"napari-time-slicer\" is free and open source software\r\n\r\n## Issues\r\n\r\nIf you encounter any problems, please [file an issue] along with a detailed description.\r\n\r\n[napari]: https://github.com/napari/napari\r\n[Cookiecutter]: https://github.com/audreyr/cookiecutter\r\n[@napari]: https://github.com/napari\r\n[MIT]: http://opensource.org/licenses/MIT\r\n[BSD-3]: http://opensource.org/licenses/BSD-3-Clause\r\n[GNU GPL v3.0]: http://www.gnu.org/licenses/gpl-3.0.txt\r\n[GNU LGPL v3.0]: http://www.gnu.org/licenses/lgpl-3.0.txt\r\n[Apache Software License 2.0]: http://www.apache.org/licenses/LICENSE-2.0\r\n[Mozilla Public License 2.0]: https://www.mozilla.org/media/MPL/2.0/index.txt\r\n[cookiecutter-napari-plugin]: https://github.com/napari/cookiecutter-napari-plugin\r\n\r\n[file an issue]: https://github.com/haesleinhuepf/napari-time-slicer/issues\r\n\r\n[napari]: https://github.com/napari/napari\r\n[tox]: https://tox.readthedocs.io/en/latest/\r\n[pip]: https://pypi.org/project/pip/\r\n[PyPI]: https://pypi.org/\r\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "A meta plugin for processing timelapse data in napari timepoint by timepoint",
    "version": "0.5.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/haesleinhuepf/napari-time-slicer/issues",
        "Documentation": "https://github.com/haesleinhuepf/napari-time-slicer#README.md",
        "Homepage": "https://github.com/haesleinhuepf/napari-time-slicer",
        "Source Code": "https://github.com/haesleinhuepf/napari-time-slicer",
        "User Support": "https://github.com/haesleinhuepf/napari-time-slicer/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5e70f4cec1bbd3b7256336979ff13bc4401382e52d4ff67a68c1e7e65125cf5f",
                "md5": "7008d641339f536e42ffc3f943ce5af8",
                "sha256": "6c7f53f762cb3410da097be43ba47b4f4213e89930a3ade3ec1c7c1beb9d605f"
            },
            "downloads": -1,
            "filename": "napari_time_slicer-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7008d641339f536e42ffc3f943ce5af8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 10749,
            "upload_time": "2023-11-12T15:27:12",
            "upload_time_iso_8601": "2023-11-12T15:27:12.042517Z",
            "url": "https://files.pythonhosted.org/packages/5e/70/f4cec1bbd3b7256336979ff13bc4401382e52d4ff67a68c1e7e65125cf5f/napari_time_slicer-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f07e4bc75a41176ba66cdefb0b1ccb861e676f2c9cc3427ee1572f748d2905fc",
                "md5": "27b8f42fa1ec8062cbbd92c27c343c02",
                "sha256": "950d3b35d9f1657178201da73de56d038e9bf4e257cf120882081f2707f1e074"
            },
            "downloads": -1,
            "filename": "napari-time-slicer-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "27b8f42fa1ec8062cbbd92c27c343c02",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 12531,
            "upload_time": "2023-11-12T15:27:13",
            "upload_time_iso_8601": "2023-11-12T15:27:13.847549Z",
            "url": "https://files.pythonhosted.org/packages/f0/7e/4bc75a41176ba66cdefb0b1ccb861e676f2c9cc3427ee1572f748d2905fc/napari-time-slicer-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-12 15:27:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "haesleinhuepf",
    "github_project": "napari-time-slicer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "napari-time-slicer"
}
        
Elapsed time: 0.16151s