FLIMKit

Plugins / FLIMKit-ZStack-Explorer · edit on GitHub

flimkit-zstack-explorer

3D intensity and FLIM volume explorer for FLIMKit z-stacks. Takes a z-stack you've already loaded or fitted in FLIMKit, stacks its per-slice intensity and lifetime maps into (Z, Y, X) volumes, saves them as an OME-Zarr store, and opens a popout 3D viewer with the two volumes side by side.

What it does

Install

pip install 'flimkit-zstack-explorer[gui]'

Quote it — in zsh (macOS's default shell), an unquoted [gui] is a glob pattern and the command fails with "no matches found" without installing anything.

[gui] adds PyVista, which does the actual 3D rendering. Without it, the volume-building and OME-Zarr saving still work, but the viewer step will tell you it's missing and how to install it.

Install it into the same Python environment FLIMKit itself runs from — a separate environment or a different python/pip on your PATH will install cleanly but leave FLIMKit unable to see it. Verify with:

python -c "import flimkit_zstack_explorer, pyvista; print('ok')"

run from the same terminal you launch FLIMKit from.

FLIMKit discovers this through the flimkit.plugins entry point, so there's nothing else to wire up. On start it appears under Tools.

From code

from flimkit_zstack_explorer import build_zstack_volumes, save_ome_zarr, load_ome_zarr

# app is FLIMKit's running App instance, with a z-stack loaded in its
# FOV preview panel
intensity_stack, lifetime_stack = build_zstack_volumes(app)
save_ome_zarr('volume.zarr', intensity_stack, lifetime_stack,
              voxel_size_um=(2.0, 0.5, 0.5))

intensity_stack, lifetime_stack = load_ome_zarr('volume.zarr')

To view a store outside FLIMKit:

python -m flimkit_zstack_explorer.viewer --zarr volume.zarr

Why a separate process for the viewer

FLIMKit's UI is Tkinter; PyVista's is VTK. Running VTK's render loop on a background thread inside a Tkinter process is unreliable, especially on macOS, where GUI toolkits generally expect to own the main thread. Building the volume and saving to disk happens inside FLIMKit; the popout viewer is a plain python -m flimkit_zstack_explorer.viewer subprocess reading the saved store, so it gets its own main thread and doesn't touch Tkinter at all.

Development

pip install -e .[gui,test]
pytest

tests/test_volumes.py exercises the z-stack-to-array logic against a fake FOV preview panel, so it runs without Tkinter or a real FLIMKit install. tests/test_zarr_io.py round-trips real arrays through zarr/ome-zarr.