You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/howto/segmentation.md
+45-4Lines changed: 45 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,12 @@ flowchart LR
10
10
B --> C{seg_method}
11
11
C -->|threshold| D[Threshold]
12
12
C -->|otsu+k3i2| E[Multi-Otsu + k-means]
13
-
D --> F[Binary Mask]
14
-
E --> F
15
-
F --> G[Clean: remove edge / small objects]
16
-
G --> H[Segmentation Output]
13
+
C -->|groupotsu+k3i2| F[Group Multi-Otsu]
14
+
D --> G[Binary Mask]
15
+
E --> G
16
+
F --> G
17
+
G --> H[Clean: remove edge / small objects]
18
+
H --> I[Segmentation Output]
17
19
```
18
20
19
21
After segmentation the binary mask is used to compute [field fraction](../reference/outputs.md#field-fraction-map-seg), [object count](../reference/outputs.md#object-count-map-seg), and [per-object region properties](../reference/outputs.md#region-properties-statistics-table-tabular).
@@ -81,6 +83,45 @@ stain_defaults:
81
83
82
84
**Limitations:** Can fail on images with unusual histograms (e.g. very sparse pathology that does not form a distinct peak) or when the background is very noisy.
83
85
86
+
### Group Multi-Otsu (`seg_method: groupotsu+k3i2`)
87
+
88
+
A variant of Multi-Otsu that derives a **single shared threshold from the aggregate histogram of all subjects** rather than computing a threshold independently per image. This is preferred when subjects were acquired with common acquisition settings and you want to ensure consistent, comparable quantification across the cohort.
89
+
90
+
The workflow is a two-step process:
91
+
92
+
**Step 1 — compute group threshold** (run once for the whole cohort):
93
+
94
+
```bash
95
+
spimquant /bids /output participant \
96
+
--targets all_group_otsu \
97
+
--seg_method groupotsu+k3i2
98
+
```
99
+
100
+
This triggers:
101
+
102
+
1. For each subject: compute a percentile-clipped intensity histogram from the bias-field corrected image and save it as an NPZ file.
103
+
2. Aggregate all subject histograms onto a common intensity grid, apply multi-level Otsu thresholding, and save the resulting thresholds as a JSON file in `{output}/group/`.
104
+
105
+
**Step 2 — segment each subject using the group threshold**:
106
+
107
+
```bash
108
+
spimquant /bids /output participant \
109
+
--seg_method groupotsu+k3i2
110
+
```
111
+
112
+
Each subject's binary mask is produced by applying the group-level threshold from the JSON file. A per-subject PNG is also generated showing the group threshold overlaid on the individual histogram, useful for visual quality control.
113
+
114
+
**Config key:**
115
+
116
+
```yaml
117
+
seg_method:
118
+
- groupotsu+k3i2
119
+
```
120
+
121
+
**When to use:** Preferred when a batch of subjects shares the same acquisition protocol and you want consistent thresholding across subjects. Reduces subject-to-subject variability in the segmentation boundary that can occur with per-subject Otsu.
122
+
123
+
**Limitations:** Less adaptive than per-subject Otsu — if staining intensity varies substantially across subjects (e.g. due to different batches of antibody or tissue preparation), a single group threshold may over- or under-segment some subjects.
0 commit comments