Skip to content

Commit 544b60e

Browse files
Copilotakhanf
andauthored
Use percentile-based axis bounds for linear histogram panel
- lin_xlim: cap at p99_val * 1.05 instead of last non-zero bin - lin_ylim: cap at max count within the visible x range * 1.05 so the distribution body is visible, not dominated by a spike - log and CDF panels keep the existing disp_max bounds Agent-Logs-Url: https://github.com/khanlab/SPIMquant/sessions/7db49e48-7c6c-4c09-b466-650c2ca2aef3 Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
1 parent d489341 commit 544b60e

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

spimquant/workflow/scripts/qc_intensity_histogram.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ def main():
5050
disp_max = float(bin_centers[nonzero_mask][-1]) * 1.05
5151
else:
5252
disp_max = max_range
53-
54-
# Saturation: fraction of voxels in the last histogram bin
5553
sat_fraction = (
5654
float(hist_counts[-1]) / total_voxels * 100 if total_voxels > 0 else 0.0
5755
)
@@ -69,6 +67,16 @@ def main():
6967
else:
7068
mean_val = p50_val = p99_val = 0.0
7169

70+
# Percentile-based display bounds for the linear-scale histogram panel
71+
# X: cap at the 99th percentile value (+ 5 % headroom) to avoid long empty tails
72+
lin_xlim = p99_val * 1.05 if total_voxels > 0 else max_range
73+
# Y: cap at the tallest bar in the visible x range (+ 5 % headroom) so the
74+
# body of the distribution is visible rather than dominated by a background spike
75+
visible = hist_counts[bin_centers <= lin_xlim]
76+
lin_ylim = (
77+
float(visible.max()) * 1.05 if visible.size and visible.max() > 0 else 1.0
78+
)
79+
7280
subject = snakemake.wildcards.subject
7381

7482
fig, axes = plt.subplots(2, 2, figsize=(12, 8))
@@ -84,7 +92,8 @@ def main():
8492
ax.set_xlabel("Intensity")
8593
ax.set_ylabel("Voxel count")
8694
ax.set_title("Linear-scale histogram")
87-
ax.set_xlim(0, disp_max)
95+
ax.set_xlim(0, lin_xlim)
96+
ax.set_ylim(0, lin_ylim)
8897

8998
# Panel 2: log-scale histogram
9099
ax = axes[0, 1]

0 commit comments

Comments
 (0)