{"name":"napari-flopa","display_name":"FLOPA","visibility":"public","icon":null,"categories":[],"schema_version":"0.3.0","on_activate":null,"on_deactivate":null,"contributions":{"commands":[{"id":"napari-flopa.make_flim_widget","title":"Open FLIM Analysis","python_name":"napari_flopa.ui.main_widget:FlimWidget","short_title":null,"category":null,"icon":null,"enablement":null},{"id":"napari-flopa.read_ptu","title":"Read PTU file or scan config","python_name":"napari_flopa.ui.reader:napari_get_reader","short_title":null,"category":null,"icon":null,"enablement":null}],"readers":[{"command":"napari-flopa.read_ptu","filename_patterns":["*.ptu","*.json"],"accepts_directories":false}],"writers":null,"widgets":[{"command":"napari-flopa.make_flim_widget","display_name":"FLIM Analysis","autogenerate":false,"default_dock_area":"right","tabify":false}],"sample_data":null,"themes":null,"menus":{},"submenus":null,"keybindings":null,"configurations":{}},"package_metadata":{"metadata_version":"2.4","name":"napari-flopa","version":"0.1.2","dynamic":["license-file"],"platform":null,"supported_platform":null,"summary":"Flim (fluorescence lifetime) image data opening, processing and analysis","description":"# napari-flopa\n\n[![License MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)\n[![npe2](https://img.shields.io/badge/plugin-npe2-blue)](https://napari.org/stable/plugins/index.html)\n[![PyPI](https://img.shields.io/pypi/v/napari-flopa.svg?color=green)](https://pypi.org/project/napari-flopa)\n[![Python Version](https://img.shields.io/pypi/pyversions/napari-flopa.svg?color=green)](https://python.org)\n\n\n> **Work in progress** — the plugin is functional but under active development. Expect breaking changes between versions.\n\nA [napari] plugin for opening, processing and analysing FLIM (Fluorescence Lifetime Imaging Microscopy) data from `.ptu` files.\n\n## Feature panels\n\n- **File**\n  - read a `.ptu`, display its header, reconstruct it into an xarray dataset (photon count, mean arrival time, phasor, TCSPC histogram)\n  - supports multi-frame, multi-sequence (with line accumulation) and multi-detector data\n  - bidirectional scans with an **Alignment wizard** for the line-marker delays\n  - scan config with value provenance, saved/loaded as JSON\n  - marker statistics\n  - optional ROI mask to reconstruct only part of the field\n  - **Drag and drop** — a `.ptu` or scan-config `.json` dropped onto napari opens in the File tab\n- **Trace**\n  - photon-count time trace per detector over a chosen time window and bin width, with line/frame marker overlays\n- **FLIM View** (bottom dock)\n  - intensity and lifetime display with histogram contrast sliders (Auto-once, Auto-live, Min-Max), smoothing\n  - frame/sequence/detector selection or summing\n  - lifetime *Calibrated* by the IRF delay from the phasor calibration\n  - intensity, lifetime and combined masks as Labels layers\n  - FLIM RGB composite\n  - export to TIFF/PNG\n- **Phasor**\n  - per-object or per-pixel phasor plot as scatter, intensity-weighted scatter or density (square or hex bins), smoothing\n  - color by a Labels layer or use it as a filter\n  - calibration from a reference lifetime or a custom factor\n- **Decay**\n  - TCSPC decay curves with frame/sequence/detector aggregation, per-detector toggles, normalisation and log scale\n- **Batch**\n  - process a folder (or selected files, opt. with sub-folders and label masks) with a shared scan config and calibration\n  - export of images (FLIM RGB, intensity, lifetime), phasor tables per object or per pixel and decay tables (raw or normalised), per file or merged\n- **Analyzer**\n  - explore phasor CSV tables (from Phasor or Batch)\n  - color by any column\n  - per-group density contours, mean/median and covariance ellipses\n  - calibration\n  - compute phase and modulation lifetimes\n  - compute 2- and 3-component fractions\n  - clustering (K-means, hierarchical; Gaussian mixture, DBSCAN, HDBSCAN with scikit-learn)\n  - row filtering, regex grouping and column combining in **Data tools**\n\n## Screenshots\n\n<table>\n  <tr>\n    <td width=\"50%\" align=\"center\"><a href=\"docs/images/file_config.png\"><img src=\"docs/images/file_config.png\" alt=\"File: header and scan configuration\"></a><br><sub>File: ptu reading, header and scan configuration</sub></td>\n    <td width=\"50%\" align=\"center\"><a href=\"docs/images/trace.png\"><img src=\"docs/images/trace.png\" alt=\"Trace: photon-count time trace with marker overlays\"></a><br><sub>Trace: photon-count time trace with marker overlays</sub></td>\n  </tr>\n  <tr>\n    <td width=\"50%\" align=\"center\"><a href=\"docs/images/rgb_flim.png\"><img src=\"docs/images/rgb_flim.png\" alt=\"FLIM View: calibrated lifetime over intensity\"></a><br><sub>FLIM View: lifetime over intensity visualization</sub></td>\n    <td width=\"50%\" align=\"center\"><a href=\"docs/images/batch_panel.png\"><img src=\"docs/images/batch_panel.png\" alt=\"Batch: scan configuration and export passes\"></a><br><sub>Batch: batch processing with configurable outputs</sub></td>\n  </tr>\n  <tr>\n    <td width=\"50%\" align=\"center\"><a href=\"docs/images/object_phasor.png\"><img src=\"docs/images/object_phasor.png\" alt=\"Phasor per object, colored by a Labels layer\"></a><br><sub>Phasor: per object, colored by a Labels layer</sub></td>\n    <td width=\"50%\" align=\"center\"><a href=\"docs/images/masked_phasor.png\"><img src=\"docs/images/masked_phasor.png\" alt=\"Phasor per pixel as density, filtered by a mask\"></a><br><sub>Phasor: per pixel (here density color-coded & filtered by a mask)</sub></td>\n  </tr>\n  <tr>\n    <td width=\"50%\" align=\"center\"><a href=\"docs/images/analyzer2.png\"><img src=\"docs/images/analyzer2.png\" alt=\"Analyzer: two detectors as groups, with mean, median and 2σ ellipses\"></a><br><sub>Analyzer: tabular phasor data visualization</sub></td>\n    <td width=\"50%\" align=\"center\"><a href=\"docs/images/analyzer1.png\"><img src=\"docs/images/analyzer1.png\" alt=\"Analyzer: 3-component fractions, colored by f3, mean per label\"></a><br><sub>Analyzer: mono-exponential lifetime component fractions</sub></td>\n\n  </tr>\n</table>\n\n## Requirements\n\n- Python ≥ 3.11\n- [napari] with a Qt backend\n\n## Installation\n\n**From PyPI - options**\n\n>```bash\n>pip install \"napari-flopa[all]\"           # plugin + napari + Qt\n> ```\n>```bash\n>pip install napari-flopa                  # plugin only, install into an existing napari\n>```\n>```bash\n>pip install \"napari-flopa[cluster]\"       # plugin only + scikit-learn\n>```\n> The `cluster` extra adds scikit-learn for the Analyzer's Gaussian mixture, DBSCAN and\n>HDBSCAN clustering (K-means and hierarchical work without it).\n\n**From source**\n\n>```bash\n>git clone https://github.com/cockovaz/napari-flopa\n>cd napari-flopa\n>pip install -e \".[all]\"      # editable install, napari + Qt included\n>```\n\n\n**Full install instructions**\n\nIt is recommended to use virtual environment. See examples below.\n\n>uv\n>\n>```bash\n>uv venv --python 3.11 .venv\n>source .venv/bin/activate        # Windows: .venv\\Scripts\\activate\n>uv pip install \"napari-flopa[all]\"\n>```\n\n> conda\n>\n>```bash\n>conda create -n flopa python=3.11\n>conda activate flopa\n>pip install \"napari-flopa[all]\"\n>```\n\n>pixi\n>\n>```bash\n>pixi init flopa\n>cd flopa\n>pixi add python=3.11\n>pixi add --pypi \"napari-flopa[all]\"\n>```\n\n\n\n## Getting started\n\n1. **Open the plugin**\n\n   Start napari and choose **Plugins → FLOPA → FLIM Analysis**.\n\n2. **Load a file**\n\n   In the **File** tab, click **Load Demo** for the bundled demo dataset, or **Read PTU…** for your own — or drop a `.ptu` onto the napari window.\n\n   > Note: the colored dot beside each field says where its value came from - file metadata, a default, an estimate, or your own edit.\n\n3. **Set the scan geometry**\n\n   Frames, lines, pixels, sequences and accumulations must match how the image was actually acquired, because the raw file is a stream of photon and marker events with no image shape of its own. The header contains some information, fill in the rest. **Demo dataset** is loaded with the correct configuration set up.\n\n   **Marker Stats** inspects the marker events and suggests dimensions. For bidirectional scans, the **Alignment wizard** estimates the line-marker delays.\n\n4. **Reconstruct**\n\n   Pick what to compute under **Output**. Optionally pick an **ROI Mask** (a Labels layer or a mask file) to keep only the photons inside it.\n\n   - *Intensity* — photon-count image only, the fastest\n   - *Int. + τ* — adds the mean arrival time (lifetime) image\n   - *All* — adds phasor coordinates per pixel and the global TCSPC decay (enables the **Phasor** and **Decay** tabs)\n\n5. **Look at the result**\n\n   The **FLIM View** dock opens at the bottom, with a histogram for Intensity and one for Lifetime. Each has two sliders: the **cyan** one sets the display contrast, the **red** one a threshold range. **→ Generate Int./Lt. Mask** turns that range into a napari Labels layer. Once a calibration is enabled in the Phasor tab, **Calibrated** shows the lifetime with the IRF delay subtracted (negative values are wrapped around by one period).\n\n   Intensity, lifetime and the FLIM RGB composite can be exported from here.\n\n6. **Analyze**\n\n   - **Phasor** plots g/s per object or per pixel — apply a calibration factor, pick a Labels layer to color by object or to restrict the plot to a region.\n   - **Decay** plots the global TCSPC curves per slice. **FLIM View** shows only decay of slice configuration currently shown in FLIM View.\n\n7. **Reuse the settings**\n\n   Use the **Batch** tab to run a whole folder of `.ptu` files with identical settings. Or export multiple slices of a single file. Each export pass picks frames, sequences and detectors as an index, `*` (all, one output per value) or `a` (aggregate).\n\n\n## Data model\n\nReading and reconstructing `.ptu` files is done by **[tttrkit]** (imported as\n`tttrkit.ptuio`), a separate package developed alongside this plugin. It is a\nnormal dependency and is installed automatically — see [tttrkit] for the raw\nTTTR parsing, scan reconstruction and phasor maths that sit underneath the GUI.\n\nReconstruction produces a single `xarray.Dataset` holding up to five variables.\n\nFour of them are images and share the dimensions\n`(frame, sequence, line, pixel, channel)`: `photon_count`, `mean_arrival_time`,\n`phasor_g` and `phasor_s`. Here `line` and `pixel` are the spatial axes and\n`channel` is the detector axis.\n\nThe fifth, `tcspc_histogram`, is the global decay: its\ndimensions are `(frame, channel, tcspc_channel)` with no spatial axes.\n\n\n\n## Roadmap\n\nPlanned updates:\n\n- **Interactive phasor** — lasso a region of the plot and paint the matching pixels\n  back into the image as a napari Labels layer\n- **Decay fitting** — extract lifetimes from the TCSPC curves\n- **Region-wise decay** — curves per mask and per object, not only per frame/detector\n- **Wider import support** — `.ptu` from further scanning systems, and other formats\n  (`.sdt`, …)\n\n\n\n## License\n\nDistributed under the terms of the [MIT] license.\n`napari-flopa` is free and open source software.\n\n## Issues\n\nIf you encounter any problems, please [file an issue] along with a detailed description.\n\n[napari]: https://github.com/napari/napari\n[tttrkit]: https://github.com/panekdal/tttrkit\n[MIT]: http://opensource.org/licenses/MIT\n[file an issue]: https://github.com/cockovaz/napari-flopa/issues\n[issues]: https://github.com/cockovaz/napari-flopa/issues\n[pip]: https://pypi.org/project/pip/\n","description_content_type":"text/markdown","keywords":null,"home_page":null,"download_url":null,"author":null,"author_email":"Zuzana Cockova <cockovaz@natur.cuni.cz>","maintainer":null,"maintainer_email":null,"license":"The MIT License (MIT)\n\nCopyright (c) 2025 Zuzana Cockova\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","classifier":["Development Status :: 3 - Alpha","Framework :: napari","Intended Audience :: Science/Research","License :: OSI Approved :: MIT License","Operating System :: OS Independent","Programming Language :: Python","Programming Language :: Python :: 3","Programming Language :: Python :: 3 :: Only","Programming Language :: Python :: 3.11","Programming Language :: Python :: 3.12","Programming Language :: Python :: 3.13","Topic :: Scientific/Engineering :: Image Processing"],"requires_dist":["numpy","qtpy","xarray","scipy","matplotlib>3.6","superqt","tttrkit","napari[all]; extra == \"all\"","scikit-learn>=1.3; extra == \"cluster\""],"requires_python":">=3.11","requires_external":null,"project_url":["Homepage, https://github.com/cockovaz/napari-flopa","Bug Tracker, https://github.com/cockovaz/napari-flopa/issues","Source Code, https://github.com/cockovaz/napari-flopa"],"provides_extra":["all","cluster"],"provides_dist":null,"obsoletes_dist":null},"npe1_shim":false}