Skip to content

Commit 649254f

Browse files
Copilotdfeen87
andauthored
Stage 5: regenerate regime-segmentation figure with higher visual clarity
Agent-Logs-Url: https://github.com/dfeen87/Cell-DNA-Dynamics/sessions/c335aa5b-9359-48ba-9e03-5dc145cd7be4 Co-authored-by: dfeen87 <158860247+dfeen87@users.noreply.github.com>
1 parent 62fa316 commit 649254f

4 files changed

Lines changed: 25 additions & 8 deletions

File tree

163 KB
Loading
Binary file not shown.
-21.2 KB
Loading

src/stage5_regime_transitions/generate_figures.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
- ΔΦ(t) overlaid as a single curve
1515
1616
Reproducibility settings:
17-
seed = 0, DPI = 150, figure sizes as specified per figure below.
17+
seed = 0, DPI = 300 (manuscript) / 150 (debug), figure sizes as specified per figure below.
1818
"""
1919

2020
from __future__ import annotations
@@ -44,7 +44,8 @@
4444

4545
# ── Reproducibility ──────────────────────────────────────────────────────────
4646
SEED = 0
47-
DPI = 150
47+
DPI = 300 # manuscript / high-quality – raised from 150 for print clarity
48+
DPI_DEBUG = 150 # debug / quick-inspect output
4849
np.random.seed(SEED)
4950

5051
# ── Consistent regime colour palette (Stage 2 / Stage 3 compatible) ──────────
@@ -54,7 +55,7 @@
5455
"instability": "#F44336", # red
5556
"recovery": "#4CAF50", # green
5657
}
57-
REGIME_ALPHA = 0.15 # polished (manuscript) – slightly softer than original
58+
REGIME_ALPHA = 0.13 # polished (manuscript) – reduced ~13% to avoid washout
5859
REGIME_ALPHA_UNPOLISHED = 0.18 # original value, kept for debug reproducibility
5960

6061
# Minimum contiguous-block length (samples) for a transition marker to be shown
@@ -135,6 +136,7 @@ def plot_regime_segmentation(
135136
out_path: str,
136137
*,
137138
polished: bool = True,
139+
extra_out_paths: list[str] | None = None,
138140
) -> None:
139141
"""Plot broad regime bands with ΔΦ(t) overlaid and transition markers.
140142
@@ -146,17 +148,21 @@ def plot_regime_segmentation(
146148
transition lines, and suppression of short-lived transition markers.
147149
When *False* (debug output) the original visual parameters are used.
148150
Neither mode alters the underlying segmentation logic or thresholds.
151+
extra_out_paths : list of str, optional
152+
Additional output paths (e.g. PDF, SVG) to save alongside ``out_path``.
149153
"""
150154
intervals = regime_shading_intervals(regime_labels)
151155
transitions = extract_transition_events(regime_labels)
152156

153157
# ── Visual parameters ─────────────────────────────────────────────────────
154158
if polished:
155-
regime_alpha = REGIME_ALPHA # 0.15slightly softer bands
156-
curve_lw = 1.5 # thicker ΔΦ(t) for readability
159+
regime_alpha = REGIME_ALPHA # 0.13reduced to avoid washout
160+
curve_lw = 1.8 # +0.3 thicker ΔΦ(t) for readability
157161
trans_color = "#9E9E9E" # lighter gray
158162
trans_lw = 0.6 # slightly thinner
159163
trans_alpha = 0.45
164+
curve_aa = False # crisp, no anti-alias blur at 300 DPI
165+
trans_aa = False
160166
# Suppress transition markers for short-lived blocks (visual clutter).
161167
major_starts = {
162168
iv.start
@@ -170,6 +176,8 @@ def plot_regime_segmentation(
170176
trans_color = "#616161"
171177
trans_lw = 0.8
172178
trans_alpha = 0.6
179+
curve_aa = True
180+
trans_aa = True
173181
visible_transitions = transitions
174182

175183
fig, ax = plt.subplots(figsize=(14, 5))
@@ -195,6 +203,7 @@ def plot_regime_segmentation(
195203
linewidth=trans_lw,
196204
linestyle="--",
197205
alpha=trans_alpha,
206+
antialiased=trans_aa,
198207
zorder=3,
199208
)
200209

@@ -203,6 +212,7 @@ def plot_regime_segmentation(
203212
t, delta_phi,
204213
color="#212121",
205214
linewidth=curve_lw,
215+
antialiased=curve_aa,
206216
zorder=4,
207217
label=r"$\Delta\Phi(t)$",
208218
)
@@ -248,9 +258,13 @@ def plot_regime_segmentation(
248258
ax.grid(True, linestyle="--", linewidth=0.4, alpha=0.4)
249259

250260
fig.tight_layout()
251-
fig.savefig(out_path, dpi=DPI, bbox_inches="tight")
252-
plt.close(fig)
261+
save_dpi = DPI if polished else DPI_DEBUG
262+
fig.savefig(out_path, dpi=save_dpi, bbox_inches="tight")
253263
print(f"Saved: {out_path}")
264+
for extra_path in (extra_out_paths or []):
265+
fig.savefig(extra_path, bbox_inches="tight")
266+
print(f"Saved: {extra_path}")
267+
plt.close(fig)
254268

255269

256270
# ── Entry point ───────────────────────────────────────────────────────────────
@@ -288,12 +302,15 @@ def main() -> None:
288302
)
289303

290304
# ── 6. Plot regime segmentation – polished (manuscript) ───────────────────
305+
_ms_png = os.path.join(_MANUSCRIPT_DIR, "regime_segmentation.png")
306+
_ms_pdf = os.path.join(_MANUSCRIPT_DIR, "regime_segmentation.pdf")
291307
plot_regime_segmentation(
292308
t,
293309
delta_phi,
294310
regime_labels=regime_result.labels,
295-
out_path=os.path.join(_MANUSCRIPT_DIR, "regime_segmentation.png"),
311+
out_path=_ms_png,
296312
polished=True,
313+
extra_out_paths=[_ms_pdf],
297314
)
298315

299316

0 commit comments

Comments
 (0)