Napari Phasors

A simple plugin to use phasor analysis

  • Bruno Pannunzio, Marcelo Leomil Zoccoler, Bruno Schuty, Leonel Malacrida

License BSD-3 PyPI Python Version tests codecov napari hub DOI

A comprehensive plugin for phasor analysis in napari. Based on the phasorpy library.

Jump to Intallation


Usage

napari-phasors is a comprehensive plugin that provides a complete workflow for phasor analysis in napari. It includes widgets for reading various FLIM and hyperspectral file formats, performing phasor analysis on multiple layers simultaneously, calibration, component analysis, FRET analysis, filtering, phasor selections (manual, circular cursor, and automatic clustering), and exporting results.

Sample Data

Two sample datasets for FLIM are provided, along with their corresponding calibration images. Additionally, a paramecium image is included as sample data for hyperspectral analysis.

sample_data

Phasor Analysis

Plot FLIM Data

FLIM phasor data can be plotted as a 2D histogram or scatter plot in the "Phasor Plot" widget. The colormap, the number of bins and the scale of the colors can be customized.

phasors_flim

Plot Hyperspectral Data

Hyperspectral phasor data can also be plotted as a 2D histogram or scatter plot and visualized in the full universal circle. The 'Universal Semi-Circle/Full Polar Plot' in the "Plot Settings" tab must be unchecked.

phasors_hyperspectral

Multiple-Layer Selection and Simultaneous Analysis

Multiple image layers containing phasor data can be selected simultaneously from the layer dropdown in the "Phasor Plot" widget. All layers can be selected or deselected at once using the "All" and "None" controls. When more than one layer is selected, their phasor coordinates are merged and displayed together in the phasor plot, enabling direct comparison and joint analysis. A primary layer can be designated from the same dropdown to drive plot settings and analysis parameters (such as calibration, frequency, filter settings, and component locations) for all selected layers. All analyses are then applied to every selected layer at once.

multiple_layers

Phasor Calibration

FLIM images can be calibrated using a reference image acquired under the same experimental parameters in the "Calibration" tab of the "Phasor Plot" widget. This reference image should consist of a homogeneous solution of a fluorophore with a known fluorescence lifetime and the laser frequency used in the experiment. This ensures accuracy and consistency in lifetime measurements.

calibration

Filtering and Thresholding

Apply various filters and thresholds to your phasor data to enhance analysis quality in the "Filter" tab on the "Phasor Plot" widget. You can filter phasor coordinates using the median or wavelet filter.

filter_threshold

Mask

You can create a mask using either a shapes layer or a labels layer in napari. Once the mask is created, select it from the mask combobox in the "Phasor Plot" widget. Only the pixels inside the selected mask will be plotted in the phasor space and included in subsequent analyses. This allows you to focus your analysis on specific regions of interest within your data.

mask

Copy Settings and Analysis

You can quickly copy plot settings and analysis parameters, such as calibration, frequency, filter settings, and component locations, from another layer or from an OME-TIF file previously exported with the napari-phasors plugin. This feature streamlines the workflow by allowing you to reuse established configurations, ensuring consistency and saving time when analyzing multiple datasets.

copy_settings

Phasor Selections

The "Selection" tab of the "Phasor Plot" widget offers three modes for identifying regions of interest in the phasor plot and mapping the corresponding pixels back to the intensity image.

Circular Cursor Selection

Define one or more circular cursors on the phasor plot to select regions of interest. Each cursor can be positioned and resized interactively by dragging it on the plot, or by entering coordinates directly in the table. A separate labels layer is created for each cursor, color-coded for easy identification. Statistics for each cursor region are displayed in the table.

circular_cursors

Automatic Clustering

Automatically segment the phasor plot into clusters using Gaussian Mixture Models (GMM). The number of clusters can be specified, and the resulting clusters are displayed as ellipses on the phasor plot. Each cluster is assigned a color that can be customized, and the corresponding pixels are highlighted in a labels layer. Cluster statistics are shown in the table.

automatic_clustering

Manual Selection

Draw free-form selections directly on the phasor plot using different shape tools available at the top of the plot. The selection ID can be managed from the "Selection" tab, allowing multiple independent selections to be stored and toggled. NOTE: Manual selections are not stored when exporting in OME-TIF format.

selections

Component Analysis

Perform multi-component analysis to identify and separate different fluorescent species in your sample. This feature allows you to decompose complex phasor distributions into individual components with distinct lifetimes. Multi-component analysis can be done in the "Components" tab of the "Phasor Plot" widget, either by projection to a line between components (only two component analysis), or by component fitting 'n' number of components based on the available harmonics. For more than three component analysis, the location of the components in higher harmonics must be provided.

components

Apparent or Normal Lifetime Analysis

A FLIM image can be colormapped according to the phase or modulation apparent lifetime, as well as the normal lifetime in the "Lifetime" tab of the "Phasor Plot" widget. A histogram is also created for visualization of the distribution of apparent lifetimes of the FLIM image.

lifetimes

FRET Analysis

Analyze Förster Resonance Energy Transfer (FRET) trajectories and efficiencies in the "FRET" tab of the "Phasor Plot" widget. The lifetime of the donor and the location of the background in the phasor plot can be obtained automatically from another layer.

fret

Phasor Custom Import

Supported file formats (.tif, .ptu, .sdt, .fbd, .lsm, .ome.tif) can be imported and converted to phasor space using the "Phasor Custom Import" widget. Depending on the file format, you can specify additional options such as harmonics, channels, and frames. The signal can then be visualized according to the selected parameters for each file.

custom_import

Data Export

The average intensity image and phasor coordinates can be exported as OME-TIF files, which are compatible with both napari-phasors and PhasorPy. Alternatively, you can export the phasor coordinates and selections as a CSV file using the "Export Phasor" widget. Analysis results—such as lifetime, FRET efficiency, and component fractions—can also be exported to CSV. Additionally, the colormapped image layer can be exported with or without its associated colorbar.

export_phasors

Installation

You can install napari-phasors via pip. Follow these steps from a terminal.

We recommend using miniforge whenever possible. Click here to choose the right download option for your OS. If you do not use miniforge, but rather Anaconda or Miniconda, replace the mamba term whenever you see it below with conda.

Create a conda environment with napari by typing :

mamba create -y -n napari-phasors-env napari pyqt python=3.12

Activate the environment :

mamba activate napari-phasors-env

Install napari-phasors via pip :

pip install napari-phasors

Alternatively, install latest development version with :

pip install git+https://github.com/napari-phasors/napari-phasors.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.

Pre-commit Hooks

This project uses pre-commit to run black and isort automatically on every commit. To set it up:

pip install pre-commit
pre-commit install

From now on, every git commit will auto-format your code before the commit goes through. You can also run the hooks manually on all files:

pre-commit run --all-files

Ruff

The project also has a ruff configuration in pyproject.toml. Ruff is not enforced in pre-commit yet because the existing codebase has ~280 pre-existing warnings that would block commits on unrelated files. You can run it manually to check your changes:

ruff check src/napari_phasors/ --config pyproject.toml

Once the legacy warnings are cleaned up, ruff will be added to the pre-commit hooks. Incremental lint fixes in PRs are welcome.

License

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

Please cite doi: https://doi.org/10.5281/zenodo.14647626 if napari-phasors contributes to a project that leads to a publication.

Issues

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

Version:

  • 0.4.1

Last updated:

  • 2026-03-04

First released:

  • 2024-11-22

License:

  • Copyright (c) 2024, Marcelo L....

Supported data:

  • Information not submitted

Save extension:

Python versions supported:

    Operating system:

    • Information not submitted

    Requirements:

    • phasorpy>=0.8
    • qtpy
    • biaplotter>=0.4.2
    • fbdfile
    • sdtfile
    • ptufile
    • tifffile
    • pandas
    • pyqt5
    • pawflim
    • tox; extra == "testing"
    • pytest; extra == "testing"
    • pytest-cov; extra == "testing"
    • pytest-qt; extra == "testing"
    • napari; extra == "testing"
    • qtpy; extra == "testing"
    • scikit-image; extra == "testing"
    • biaplotter>=0.4.2; extra == "testing"
    • PyQt5; extra == "testing"
    • pandas; extra == "testing"
    • black; extra == "testing"
    • isort; extra == "testing"
    • ruff; extra == "testing"
    • pre-commit; extra == "testing"
    • phasorpy>=0.8; extra == "testing"
    • tifffile; extra == "testing"
    • fbdfile; extra == "testing"
    • sdtfile; extra == "testing"
    • ptufile; extra == "testing"
    • pawflim; extra == "testing"
    Website by the napari team, original design by CZI. Go to napari main website.