Package: napari-time-slicer
napari-time-slicerA 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 usingnapari-time-slicer:napari-segment-blobs-and-things-with-membranesnapari-cupy-image-processingnapari-pyclesperanto-assistantnapari-accelerated-pixel-and-object-classificationnapari-simpleitk-image-processingnapari-stressnapari-process-points-and-surfacesnapari-time-slicerenables 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 theWorkflow InspectorIf you want to convert a 3D dataset into a 2D + time dataset, use the
menuTools > 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 datasetsUsing thenapari-assistantcomplex 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 menuTools > Utilities > Convert to file-backed timelapse data (time-slicer). It will open this dialog, where you can selectIt 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 itsFile > 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.Usage for plugin developersPlugins which implement thenapari_experimental_provide_functionhook can make use of the@time_slicer. At the moment,
only functions which takenapari.types.ImageData,napari.types.LabelsDataand basic python types such asintandfloatare supported. If you annotate such a function with@time_slicerit 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 thetime_slicerfor functions which can provide [almost] real-time performance. Another constraint is that
these annotated functions have to have aviewerparameter. This is necessary to read the current timepoint from the
viewer when invoking the re-computions.Exampleimportnaparifromnapari_time_slicerimporttime_slicer@time_slicerdefthreshold_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_sliceannotation.
Make sure, to insert it after@time_sliceras shown below and implemented innapari-pillow-image-processingfromnapari_time_slicerimportslice_by_slice@time_slicer@slice_by_slicedefblur_2d(image:napari.types.ImageData,sigma:float=1,viewer:napari.Viewer=None)->napari.types.LabelsData:# ...Thisnapariplugin was generated withCookiecutterusing@napari'scookiecutter-napari-plugintemplate.InstallationYou can installnapari-time-slicerviapip:pip install napari-time-slicerTo install latest development version :pip install git+https://github.com/haesleinhuepf/napari-time-slicer.gitContributingContributions are very welcome. Tests can be run withtox, please ensure
the coverage at least stays the same before you submit a pull request.LicenseDistributed under the terms of theBSD-3license,
"napari-time-slicer" is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.