File size: 2,946 Bytes
9f785a9
d487db0
 
 
9f785a9
 
d487db0
9f785a9
 
d487db0
9f785a9
 
d487db0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
title: Cochlear Neurofilament Tracer
emoji: 🧠
colorFrom: indigo
colorTo: purple
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false
license: mit
---

# 🧠 Cochlear Neurofilament Tracer

A HuggingFace app that traces auditory-nerve fibers in confocal z-stacks of the
organ of Corti and quantifies them **per frequency region**, separating
**IHC-innervating** from **OHC-innervating** fibers.

It is an alternative to IMARIS filament tracing that keeps each neuron as a
**single continuous traced element** instead of splitting it into many
threshold-dependent segments.

## Input

- **File type:** Zeiss `.czi` 3D z-stacks. Generic `.tif/.tiff` stacks are also
  accepted for flexibility.
- **Channels:**
  - *Neurofilament* — traces the neuron.
  - *Myo7a* — marks hair cells; used as a reference to separate IHC- vs
    OHC-innervating fibers. IHCs form a single row and OHCs form three adjacent
    rows, so the Myo7a band is used to place the IHC/OHC boundary.
- **Frequency region:** selectable (8/16/22/32/64 kHz), auto-detected from the
  file name when possible.
- Channels are auto-detected from CZI metadata (Alexa-555 → Neurofilament,
  Alexa-405 → Myo7a) but can be reassigned in the UI.

## What it does

1. Segments and **skeletonises the Neurofilament network in 3D** using physical
   voxel spacing (from CZI metadata, or entered for TIFF).
2. Uses the **Myo7a channel** to place an IHC/OHC boundary. This can be set
   manually (ROI 1 vs ROI 2) by moving the boundary slider while viewing the
   Myo7a preview, choosing the split axis, and choosing which side is IHC.
3. Computes, per region (Whole field / IHC / OHC):
   - **Number of fibers** (continuous skeleton components above a minimum length)
   - **Thickness / diameter** (from the 3D distance transform)
   - **Length** (µm, spacing-aware)
   - **Branching** (number of branch points)
   - **Area covered** within the field of view (µm² and % of FOV)

## Output

- A **black-background image** of the traced neurons in **white** (skeletonised
  trace), plus a colour-coded IHC/OHC overlay.
- An **Excel workbook** with all quantification, organized by frequency region,
  with IHC and OHC fibers reported separately (tidy "Per region" sheet plus
  per-metric frequency × region summary sheets).

The **Batch** tab processes several stacks at once (e.g. all frequency regions
of one cochlea) and compiles one Excel workbook plus a ZIP of skeleton images.

## Notes on method

Confocal images of the organ of Corti are dense, so fully separating every
individual axon is inherently ambiguous. This tool traces the network
continuously and reports metrics **per region surrounding the IHCs / OHCs**,
with a human-in-the-loop boundary for reliable IHC vs OHC assignment. The
`sensitivity` control scales the segmentation threshold to capture more or fewer
thin fibers.

## Local run

```bash
pip install -r requirements.txt
python app.py
```