FenestRA: A Napari plugin for LSEC AFM Super-Resolution & Fenestration Analysis.
Project description
FenestRA
Fenestration Resolution & Analysis Pipeline
FenestRA is a custom Napari plugin built for the Advanced LSEC AFM Pipeline. It bridges the gap between interactive Napari features, legacy deep-learning upscale repositories via containerized backends, and state-of-the-art Cellpose instance segmentation.
By combining Deep Learning-based Super Resolution (HAT / SwinIR) with automated morphological analysis, FenestRA drastically simplifies the workflow of extracting robust physical porosity and fenestration morphology metrics directly from raw .jpk.qi-image files.
Features
- Cross-Platform Container Engine: Seamlessly toggle between Docker (Windows / macOS) and Singularity / Apptainer (Linux / HPC) directly from the Napari UI. No code changes needed when switching platforms.
- Hub-and-Spoke Deep Learning Architecture: Run legacy Python 3.8 dependent upscale models (HAT, SwinIR) asynchronously inside a container without freezing your modern Napari GUI.
- Post-DL Image Enhancement: Optional CLAHE contrast equalization and Unsharp Masking applied directly to the Deep Learning output to sharpen fenestration edges before segmentation.
- Native JPK Ingestion: Automatically reads native physical scale (
nm / px) from.jpk.qi-imagefiles using AFMReader. - Synchronized 4-Pane Analysis: Auto-generates a synchronized Napari viewer layout combining Raw, Upsampled, Mask, and Boundary Overlays natively.
- Configurable CPU Fallback: Includes high-fidelity Python-based CLAHE and unsharp masking functions when DL inference isn't required.
- Sub-cellular Quantification: Automatically calculates standard metrics (area, perimeter, equivalent diameter, eccentricity, porosity) with digital-to-physical size translations directly to
.csv. - Batch Analysis: Process an entire folder of
.jpk-qi-imagefiles in one automated run. Produces a single consolidated.xlsxExcel file with metrics from all images, plus individual upsampled TIFFs and Cellpose mask TIFFs.
Installation
1. Requirements
- Python 3.10+
- An NVIDIA GPU with CUDA 12.4 drivers (recommended for DL inference)
- Linux: Apptainer / Singularity
- Windows / macOS: Docker Desktop
2. Create the Host Environment
Create a clean Anaconda environment optimized for Cellpose targeting CUDA 12.4:
conda create -n fenestra-env -c conda-forge python=3.10 numpy=1.26.4
conda activate fenestra-env
# Install base GUI tools, Napari, and core scientific dependencies
pip install "napari[all]" magicgui qtpy scipy scikit-image pandas tifffile "numpy<2" openpyxl
# Install PyTorch mapped explicitly to CUDA 12.4 to ensure GPU hardware acceleration works
pip install --index-url https://download.pytorch.org/whl/cu124 torch==2.4.0 torchvision==0.19.0
# Install Cellpose for fenestration instance segmentation
pip install cellpose
# Install AFMReader for handling raw JPK AFM metadata
pip install git+https://github.com/AFM-SPM/AFMReader.git
3. Install FenestRA
Since FenestRA is now available as a Python package on PyPI, you can install it directly using pip:
pip install napari-fenestra
4. Setup the Deep Learning Backend (Docker vs Singularity)
FenestRA runs its massive deep learning architectures completely independently from the modern Napari UI. You must compile the container engine based on your Operating System:
For Windows & macOS Users (Docker Desktop): Because Apple and Windows systems cannot securely install Singularity, we use Docker.
- Install Docker Desktop on your machine.
- Open a terminal and navigate to this repository's
containers/directory. - Build the backend image (Windows/Mac users do NOT need
sudo):
docker build -t livrvub/dl-upsampling:latest -f Dockerfile ..
(In Napari, select Docker from the Engine dropdown. No file browsing needed!)
For Native Linux Users (Singularity / Apptainer): Linux systems heavily restrict Docker permissions. For ultimate performance and hassle-free paths on Linux, use Apptainer/Singularity.
- Install Apptainer natively on your Linux distribution.
- Open a terminal and build the container using the provided definition recipe:
sudo apptainer build dl_upsampling.sif containers/dl_upsampling.def
(In Napari, select Singularity from the Engine dropdown, and use the ... button to select that .sif file!)
Usage
Single Image Analysis
- Activate your environment:
conda activate fenestra-env - Launch napari:
napari - Navigate to
Plugins > FenestRA Pipelineto open the widget! - Step 1 — Input Data: Load your
*.jpk-qi-imagefile. - Step 2 — Upsampling: Select a method (CLAHE, HAT, or SwinIR). For DL methods, specify the model
.pth, choose your Engine (Docker or Singularity), and optionally enable "Apply Post-DL Sharpening" with adjustable Clip Limit and Unsharp parameters. Hit Run Upsampling. - Step 3 — Segmentation: Configure Cellpose parameters (Diameter, Cellprob Threshold, Flow Threshold). Optionally load a custom Cellpose model. Hit Run Cellpose.
- Step 4 — Layout & Analysis: Click Arrange 4-Pane Grid for a synchronized review of Raw, Upsampled, Mask, and Overlay views. Click Quantify Fenestrations to export your CSV metrics.
Batch Analysis
- Configure your preferred upsampling method, model paths, and Cellpose parameters using the single-image sections above.
- Scroll down to Section 5 — Batch Analysis.
- Select an Input Directory containing your
.jpk-qi-imagefiles. - Select an Output Directory where results will be saved.
- Click Run Batch. The status label will update in real-time showing progress (e.g.,
Processing 3/10: sample.jpk-qi-image). - When complete, the output directory will contain:
batch_results.xlsx— Consolidated Excel file with metrics from all images (withImage_Namecolumn).<image_name>_upsampled.tif— Upsampled TIFF for each input image.<image_name>_mask.tif— Cellpose segmentation mask for each input image.
Changelog
v0.2
- Batch Analysis Module: New Section 5 in the Napari UI for processing entire folders of
.jpk-qi-imagefiles. Outputs a single consolidated.xlsxExcel file with fenestration metrics from all images, plus individual upsampled TIFFs and Cellpose mask TIFFs. - Post-DL Image Enhancement: Added an optional "Apply Post-DL Sharpening" checkbox that applies CLAHE contrast equalization and Unsharp Masking to the Deep Learning output before Cellpose segmentation.
- UI Restructuring: Separated the Clip Limit / Unsharp Radius / Amount sliders into a shared post-processing group that is dynamically visible for both CLAHE and DL workflows.
v0.1
- Cross-Platform Docker Support: Added a
Dockerfilemirroring the Singularity.defenvironment. Users can now toggle between Docker and Singularity engines directly from the Napari UI. - Engine Toggle UI: New "Engine" dropdown in the Upsampling section. Selecting Docker shows a tag input; selecting Singularity shows a
.siffile picker. - Container Recipes: Both
Dockerfileanddl_upsampling.defare now bundled in thecontainers/directory. - Cross-Platform README: Added installation instructions for Windows, macOS, and Linux users.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file napari_fenestra-0.2.2.tar.gz.
File metadata
- Download URL: napari_fenestra-0.2.2.tar.gz
- Upload date:
- Size: 74.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2a67ab54e5920659193f500fe2aadd5411543c2bbad4106a426e337e1cb19c0
|
|
| MD5 |
fa2bc5bdfc160a210642905522ff5999
|
|
| BLAKE2b-256 |
2871493994681c0144958716a17e6a4aa7f4b4213e9e3833c89f18ce422f9998
|
File details
Details for the file napari_fenestra-0.2.2-py3-none-any.whl.
File metadata
- Download URL: napari_fenestra-0.2.2-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be683f7f596eb372af62a063d43417531a7c3bbafa5eb062e7cda32a93429dd7
|
|
| MD5 |
ab5489baeb761c121efbde8ff6003e18
|
|
| BLAKE2b-256 |
436f05a76dd1c29f8e4080d789f9ae2b48167defa4773969f3db3ca343f4b792
|