Skip to content
This repository was archived by the owner on Jun 24, 2026. It is now read-only.
 
 

Repository files navigation

title Zebrafish Segmentation Web App
emoji 🐟
colorFrom blue
colorTo green
sdk gradio
sdk_version 6.3.0
app_file app.py
pinned false

Project Structure

zebrafish_analysis/
├── core/          — shared analysis package (seg, length, scalebar, models)
├── webapp/        — Gradio frontend
└── slicer_extension/ZebrafishAnalysis/  — 3D Slicer extension

Installation (3D Slicer)

  1. Open 3D Slicer 5.x
  2. Go to Edit → Application Settings → Modules → Additional module paths
  3. Add the path to zebrafish_analysis/slicer_extension/ZebrafishAnalysis/
  4. Restart Slicer
  5. On first run, required Python packages are installed automatically (requires internet access, ~2 min)

Note: The extension downloads deep learning models (~500 MB) from Hugging Face Hub on first use.

Running the Slicer extension

Install 3D Slicer 5.x, open Extension Wizard, point to zebrafish_analysis/slicer_extension/ZebrafishAnalysis/. Dependencies are installed automatically on first load.

Models

All models are hosted on Hugging Face and downloaded automatically on first use:

Model Repository Purpose
Body segmentation (VGG19) markdanielarndt/Zebrafish_Segmentation Fish body mask
Eye segmentation markdanielarndt/Zebrafish_Segmentation Eye region mask
Curvature classifier (ConvNeXt) markdanielarndt/Classification Curvature grade 1–4

🐟 Zebrafish Segmentation Web App

Table of Contents

How to use the Zebrafish Segmentation Web App

Selecting a Model

Before you begin, you can select the model that will analyze the images. The General Model is trained on a broad dataset. Fine-tuned models are optimized for specific imaging setups. In addition, you can choose between a faster model and a more accurate model.

Model selection option

Uploading Images

You can upload images of the zebrafish in two ways:

Method 1: Upload a Folder

You can upload an entire folder containing zebrafish images.

Upload folder option

Select the folder of your choosing from the file dialog:

Select folder

Then click "Upload" to upload the folder. You'll need to confirm the upload by clicking "Upload" again:

Confirm upload

Wait for the images to load and appear:

Images loaded

Method 2: Upload Individual Images

Alternatively, you can upload individual images one by one.

Upload individual images option

Select the images of your choosing and click "Open" to upload them:

Select individual images

Wait for the images to load and appear:

Images loaded

Scale Bar Calibration

Once the images are successfully uploaded, the first one will appear on the screen. The scale bar will be automatically detected and the number of pixels it spans will be displayed.

Scale Bar Automatic Detection

Enter the physical length printed above the bar (e.g. 500) and its unit, then click Apply to compute the µm/px calibration. The image width/height fields below will be filled automatically.

Length Values

If automatic detection has incorrectly identified the scale bar, you can use the Manual Scale Bar Entry option below. The image loads automatically below. Click on it to mark the two endpoints of the scale bar line:

  • 1st click → START (one end, shown in green)
  • 2nd click → END (other end, shown in red)

Manual Scale Bar Entry

After both endpoints are set, enter the physical length below and click Apply Manual Points to fill in the calibration automatically.

Apply Manual Points

You can also skip this step and enter the distances manually.

Selecting Endpoints

After uploading your images, choose which endpoints you want to analyze:

Select endpoints

You can select:

  • Length: Measure the length of the zebrafish (centerline path length in µm)
  • Curvature: Classify the zebrafish into curvature classes (1-4)
    • Class 1: Most severe curvature
    • Class 2: Moderate-severe curvature
    • Class 3: Mild curvature
    • Class 4: Most healthy (minimal curvature)
  • Length/Straight Line Ratio: The ratio between the actual centerline length and the straight-line distance between endpoints. A value close to 1.0 indicates a nearly straight fish, while higher values indicate more curvature. This metric quantifies body curvature independently of fish size.
  • Eye Size: Calculates the eye area in µm² and measures the eye diameter in µm.
  • Edema: ... .
  • Swim Blader: ... .

Run

To start the processing, click the Run button.

Run

Boxplots

After processing, you'll see boxplots visualizing the distribution of the selected endpoints. These boxplots are also included in the Excel file:

Boxplots

The boxplots display:

  • Fish Lengths: Distribution of measured centerline lengths in µm
  • Curvatures: Distribution of curvature classifications (1-4)
  • Length/Straight Line Ratio: Distribution of the length ratio metric, where values closer to 1.0 indicate straighter fish
  • Eye Area: Distribution of calculated eye areas in µm²
  • Eye Diameter: Distribution of measured eye diameters in µm

The ratio visualization helps identify fish with significant body curvature. You can see in the example image that some fish have ratios above 1.0, indicating curved body shapes:

Length/Straight Line Ratio explanation

The cyan line shows the straight-line distance between endpoints, while the actual centerline path (shown in red) is longer due to body curvature. The ratio quantifies this difference.

Segmentation Preview

A gallery displays segmentation overlays for the uploaded images (thumbnails include a short filename label).

Segmentation preview

If automatic detection fails use Manual Point Adjustment tool to manually set head and tail points.

  • Click an image in the gallery above to select it for manual editing
  • Click on the large image below to set HEAD (green) and TAIL (red) points
  • Click 'Apply Manual Points' to recalculate the length

Manual points

Generating a Final Excel

When you're ready, press the Generate Final Excel button.

Generate Final Excel

Below will be a button to download the file.

Download Final Excel

About

Zebrafish analysis — Gradio webapp + 3D Slicer extension

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages