Skip to main content

A meta plugin for processing timelapse data in napari timepoint by timepoint

Project description

napari-time-slicer

License PyPI Python Version tests codecov Development Status napari hub

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-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:

The workflow can then also be exported as a script. The 'Generate Code' button can be found in the 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 it is possible to setup image processing workflows. 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

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

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

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

napari-time-slicer-0.4.6.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

napari_time_slicer-0.4.6-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file napari-time-slicer-0.4.6.tar.gz.

File metadata

  • Download URL: napari-time-slicer-0.4.6.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for napari-time-slicer-0.4.6.tar.gz
Algorithm Hash digest
SHA256 ba6127be09a5d41be0e5bd98c7142fdd9bb5700c4395c5df1af09bffb1089aa7
MD5 ee1fada08ea0f044c1b60473b5946741
BLAKE2b-256 cf4c532db3172ccafbd78c540a80963f58582a36add9f382cfd44362d36e77da

See more details on using hashes here.

File details

Details for the file napari_time_slicer-0.4.6-py3-none-any.whl.

File metadata

  • Download URL: napari_time_slicer-0.4.6-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for napari_time_slicer-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 99496863961496d5afe7a79d9d7d7b4f8354de8347569def1af4bcefac35084f
MD5 9697db6fa77a764fe1b0689610dfe1cc
BLAKE2b-256 7a0ee059297734450641b2636200f8d46ae24429106e5e5cbaae396317e2c1b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page