Files
CADx-4/config/ceus.yaml
T
iomgaa 2753ea7721 feat(build): 资料库装入全量 CEUS 结果;补 CEUS 定量使用说明
- config/build.yaml 的 ceus_run 指向全量运行 runs/ceus/20261016-090325-1de88a5-dirty;
  test_committed_config_is_valid 随之改为断言指向 runs/ceus/ 下跑完的运行目录。
- config/ceus.yaml 配准门槛注释注明全量运行复算的分布相同。
- 新增 research-wiki/guides/CEUS定量.md(已过一轮硕士生阅读);装配两个库.md 补上 CEUS 运行与
  交付包的三条核对、finished.json;结构.md 行数表按当前代码更新。
- WORK_LOG 记任务书 02 完成情况。

来源:任务书 02 第四阶段。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 09:49:53 -04:00

223 lines
17 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CEUS 定量的配置,给 scripts/ceus_quant.py 用。
#
# 分四段:paths(位置)、align_check(配准目视核对的出图,scripts/ceus_align_review.py 用)、
# segment(分割设置,任务书 02 第二阶段加)、ceus(算法参数)。
# ceus 段的字段定义和校验在 src/cadx/ceus/_config.py,segment 段在 src/cadx/segment/_config.py;
# paths、align_check 两段和最外层由 scripts/ceus_quant.py 定义。路径都相对仓库根目录。
# 每个字段必填,可以没有的值写 null。
#
# ceus 段的数值逐个照抄旧项目 config/ceus_roi_default.yaml,没有改动(待定问题/02:参数何时冻结)。
# 注释里的出处:
# - 「出自旧项目」:旧 yaml 注释原样引用的来源。其中 findings 指旧项目
# research-wiki/findings/2026-06-16-roi-tic-config-parameter-reference.md(伙伴参考组件
# references/ROI/ 那套参数的原始口径),§2A 指「删键即静默退化、yaml 值与代码默认不同」的那批;
# design/00NN 指旧项目 research-wiki/design/;《临床口径契约》在 Linear,抄本可能过期。
# - 「旧项目工程侧定的,无出处」:旧 yaml 没给来源的值。
paths:
delivery_dir: data/交付包_20260908_40例 # 交付包位置,相对仓库根目录
runs_root: runs/ceus # 每次运行一个子目录,只追加不删
work_root: work # 可删掉重算的中间文件(分割缓存)
align_runs_root: runs/ceus_align # 配准目视核对,每次出图一个子目录,只追加不删
# 配准目视核对的结果表(scripts/ceus_align_review.py score 写出的 review.csv)。ceus_quant 按视频
# SHA-256 查它,文件不存在就报错停下。2026-10-16 这次核对:10 张阴性对照两位判读者都判「没对齐」,
# 30 例真实病例两人都判「对齐」
align_review: runs/ceus_align/20261016-064728-00ebbff-dirty/review.csv
align_check: # 配准目视核对的出图(任务书 02「配准的目视核对」)。本仓库新加
seed: 20261016 # 挑阴性对照、定错开方向和编号用的随机数种子。本仓库新加,取任务日期,无其他含义
control_count: 10 # 阴性对照约 10 例。出自任务书 02「配准的目视核对」第 1 步
control_shift_px: [15, 30] # 对照故意错开的距离(像素,欧氏长度)区间,方向随机。出自同上
segment: # 分割设置,字段定义在 src/cadx/segment/_config.py。出自旧项目 debugs/medsam2_local_track.py
medsam2_dir: reference/MedSAM2 # MedSAM2 代码,提交号从它的 .git 读。旧脚本是远程 /home/wangwenhan/MedSAM2
checkpoint: models/MedSAM2_latest.pt # 权重。旧脚本是 MedSAM2/checkpoints/MedSAM2_latest.pt
sam2_config: configs/sam2.1_hiera_t512.yaml # 模型配置的 Hydra 名(相对 sam2 包)。照旧脚本 DEFAULT_MEDSAM2_CFG
device: cuda # 照旧脚本 DEFAULT_DEVICE
offload_video_to_cpu: false # 照旧脚本:t1_local_debug.py 调它时没开这个开关
offload_state_to_cpu: false # 同上
ceus:
config_version: "4" # 参数口径版本号,由人改。出自旧项目:Lognormal-v2 参数口径(design/0044)
# cv2 进程级随机数的种子,每例第 4–9 步开头设一次(第 5 步暗区的 kmeans 候选用 k-means++ 随机选初始
# 中心)。不设时同一例的结果取决于同一进程里前面跑过几次 kmeans。本仓库为可复现新加(AGENTS.md
# 「可复现」),旧项目未设种子
random_seed: 0
views: # 出自旧项目:findings §3.1 视图切分
layout: horizontal_split # 屏幕左右各一半。出自旧项目 findings §3.1
split_sample_frames: 25 # 找分屏线只用均匀抽的 25 帧。旧 debug 脚本写死的数,旧项目工程侧定的,无出处
split_search_band: [0.35, 0.65] # 只在宽度的这一段里找分屏线。旧 detect_split_x 的参数默认值,旧项目工程侧定的,无出处
# 两半配准(第 1 步):每段视频单独估左半到右半的平移(任务书 02 第一阶段第 1 条)。整段是本仓库
# 新加的,旧项目用写死的锚点、没有这一步。取值依据 2026-10-16 在 8 段真实视频(覆盖 5 种帧宽)上的
# 只读实测和同日 34 例的差值分布,见各行
registration:
sample_frames: 30 # 均匀抽 30 帧求时间平均和标准差。本仓库新加,2026-10-16 实测取的,无外部出处
top_ignore_ratio: 0.0834 # 顶部信息栏,与 prompt_source.ignore_regions 那条文字带同高。本仓库新加,依据 2026-10-16 实测
# 时间标准差高于 4(8 位灰度)算扇形区:静止的文字、色标、刻度标准差近 0。本仓库新加,依据
# 2026-10-16 实测
fan_std_threshold: 4.0
fan_open_kernel: 5 # 本仓库新加,依据 2026-10-16 实测
mark_dilate: 3 # 绿框紫圈像素外扩 3 像素再修补。本仓库新加,依据 2026-10-16 实测
blur_sigma: 2.0 # 本仓库新加,依据 2026-10-16 实测
# 搜索范围:|dx| ≤ 0.5 × 左半宽、|dy| ≤ 0.15 × 左半高。8 段实测水平错位 −10 到 +182 像素
# (最大约 0.38 倍半宽)、竖直 0–5 像素。本仓库新加,依据 2026-10-16 实测
search_x_ratio: 0.5
search_y_ratio: 0.15
template_grid: [4, 4] # 本仓库新加,依据 2026-10-16 实测(3 块时有视频两块误配,改多块取中位数)
template_size_ratio: 0.15 # 本仓库新加,依据 2026-10-16 实测
template_min_patches: 3 # 本仓库新加,无外部出处
# 两种方法估计各分量之差的最大值的门槛(像素)。依据:2026-10-16 在交付包检查全部通过的 34 例中
# 走完第 1 步的 29 例上,两种方法差值最小 0、25% 分位 1、中位 2、75% 分位 2、90% 分位 5、
# 95% 分位 6.2、最大 13;15 高于观测最大值,远低于唯一明显错配的 66。参数与门槛在同一批视频上
# 调出,没有独立验证集;全量运行 runs/ceus/20261016-090325-1de88a5-dirty 的 29 例复算结果相同。
# 负责人 2026-10-16 定
max_disagreement_px: 15
prompt_source: # 出自旧项目:findings §3.2 绿框检测
type: color_polygon # 出自旧项目 findings §3.2
hsv_lower: [35, 60, 60] # 出自旧项目 findings §3.2
hsv_upper: [90, 255, 255] # 出自旧项目 findings §3.2
ignore_regions: [[0.0, 0.0, 1.0, 0.0834]] # 抹掉顶部约 8.34% 的文字带。出自旧项目 findings §3.2
min_area: 10000 # 外接框面积 w×h(findings §2D)。出自旧项目 findings §3.2
pan_source: # 紫圈检测(待定问题/08)。出自旧项目 design/0030 决策四;旧 yaml 注明全部是占位、待真实素材标定
type: color_polygon # 旧项目工程侧定的,无出处
hsv_lower: [125, 60, 60] # 占位,待标定。出自旧项目 design/0030 决策四
hsv_upper: [165, 255, 255] # 占位,待标定。出自旧项目 design/0030 决策四
ignore_regions: [[0.0, 0.0, 1.0, 0.0834]] # 占位,同绿框那条顶部文字带。出自旧项目 design/0030 决策四
min_area: 2000 # 占位,待标定。出自旧项目 design/0030 决策四
min_detected_frame_fraction: 0.9 # 占位,待标定。出自旧项目 design/0030 决策四
keyframes: # 提示帧选择(不是第 8 步的关键帧)。出自旧项目:findings §3.3
change_metric: mask_iou # 出自旧项目 findings §3.3
iou_threshold: 0.92 # 出自旧项目 findings §3.3
min_gap_frames: 1 # 出自旧项目 findings §3.3
smoothing: # 出自旧项目:findings §3.6 轮廓分辨率与时间平滑
contour_points: 64 # 出自旧项目 findings §3.6
temporal_window: 15 # 须奇数。出自旧项目 findings §3.6
roi_shape: # 最终轮廓与绿框的融合(待定问题/01)。出自旧项目:findings §3.7
source: prompt_prior # findings §2A:非代码默认 medsam2。出自旧项目 findings §3.7
keyframe_shape_strength: 1.0 # 出自旧项目 findings §3.7
propagation_shape_strength: 0.75 # 出自旧项目 findings §3.7
min_area_ratio_to_prompt: 0.70 # 须 < max。出自旧项目 findings §3.7
max_area_ratio_to_prompt: 1.25 # 出自旧项目 findings §3.7
interior_dark_region: # 暗区识别。出自旧项目:findings §3.8
enabled: true # findings §2A:非代码默认 false。出自旧项目 findings §3.8
analysis_view: source # findings §2A:非代码默认 target。出自旧项目 findings §3.8
exclude_prompt_color: true # findings §2A:非代码默认 false。出自旧项目 findings §3.8
threshold_method: auto_ensemble # findings §2A:非代码默认 otsu。出自旧项目 findings §3.8
candidate_methods: [otsu, adaptive, percentile, kmeans, clahe_otsu] # 出自旧项目 findings §3.8
threshold_offset: 0 # 出自旧项目 findings §3.8
min_area: 300 # findings §2A:非代码默认 64。出自旧项目 findings §3.8
min_area_ratio: 0.015 # findings §2A:非代码默认 0.0。出自旧项目 findings §3.8
# 下面四项旧 schema 里没有,旧 dark_region.py 用 getattr(..., 默认值) 读,这里照旧值写出来。
# 旧项目工程侧定的,无出处
max_regions: null # 每帧最多保留几块暗区,null 不限
max_contours_per_region: null # 每块暗区最多取几条外轮廓,null 不限
preferred_area_ratio_range: null # 暗区占 ROI 面积的偏好区间 [lo, hi],null 时面积分偏好占一半
prompt_exclude_dilate: 3 # 剔绿框色前对绿色像素的膨胀核边长(与 tic_analysis 那个是两个独立的数)
preserve_holes: true # 出自旧项目 findings §3.8
fill_holes: false # 出自旧项目 findings §3.8
morphology_kernel: 5 # 出自旧项目 findings §3.8
fragment_penalty_weight: 0.08 # 出自旧项目 findings §3.8
temporal_consistency_weight: 0.35 # 出自旧项目 findings §3.8
contour_points: 64 # 出自旧项目 findings §3.8
# 以下是各方法的子参数:参考 yaml 没列,取参考代码的默认值。出自旧项目 findings §2C、§3.8
percentile: 45.0 # 出自旧项目 findings §2C
threshold: 96 # absolute 法的固定灰度阈值。出自旧项目 findings §2C
adaptive_block_size: 31 # 须奇数 ≥3。出自旧项目 findings §2C
adaptive_c: 5.0 # 出自旧项目 findings §2C
kmeans_max_iter: 30 # 出自旧项目 findings §2C
kmeans_attempts: 3 # 出自旧项目 findings §2C
clahe_clip_limit: 2.0 # 出自旧项目 findings §2C
clahe_tile_grid_size: 8 # 出自旧项目 findings §2C
constraints: # 出自旧项目:findings §3.9 提示帧位置约束
keyframe_position:
enabled: true # findings §2A:非代码默认 false。出自旧项目 findings §3.9
mode: center_interpolation # 出自旧项目 findings §3.9
strength: 1.0 # 截到 [0, 1]。出自旧项目 findings §3.9
tic_analysis: # 出自旧项目:findings §3.11 TIC 曲线(参考 yaml 整块不存在,取参考代码默认值)
brightness_metric: grayscale_mean # 出自旧项目 findings §3.11
exclude_prompt_color: true # 出自旧项目 findings §3.11
prompt_exclude_dilate: 3 # 出自旧项目 findings §3.11
baseline: # 增强前基线。出自旧项目 design/0030 决策二
preferred_duration_s: 2.0 # 出自旧项目:Linear《临床口径契约》
minimum_duration_s: 1.0 # 出自旧项目:Linear《临床口径契约》
stability_sd_multiplier: 3.0 # 临床口径里没有这个判据,旧项目工程侧占位,无出处
reference_region: # 病灶外背景圆。出自旧项目 findings §3.11
enabled: true # 出自旧项目 findings §3.11
mode: auto_near_roi # 出自旧项目 findings §3.11
radius_px: 24 # 出自旧项目 findings §3.11
min_distance_px: 12 # 出自旧项目 findings §3.11
nonblack_threshold: 12 # 出自旧项目 findings §3.11
min_valid_fraction: 0.65 # 出自旧项目 findings §3.11
center_xy: null # manual 模式必填。出自旧项目 findings §3.11
fitting: # Lognormal 拟合。出自旧项目 design/0044:工程验收占位,代表性开发集标定后一次性锁定
algorithm_version: lognormal-v2 # 出自旧项目 design/0044
detect_duplicate_frames: true # 出自旧项目 design/0044
candidate_window_s: 1.5 # 二阶 Savitzky-Golay 只做候选检测,窗口按秒。出自旧项目 design/0044
candidate_long_window_s: 5.0 # 宏观团注候选,抑制逐帧掩膜与压缩波动。出自旧项目 design/0044
candidate_polyorder: 2 # 出自旧项目 design/0044
max_candidate_gap_s: 0.5 # 出自旧项目 design/0044
duplicate_mean_absdiff_threshold: 0.25 # 8 位灰度的平均绝对差。出自旧项目 design/0044
minimum_valid_samples: 20 # 出自旧项目 design/0044
minimum_peak_distance_s: 1.0 # 出自旧项目 design/0044
minimum_relative_peak_height: 0.10 # 出自旧项目 design/0044
multi_peak_minimum_separation_s: 5.0 # 出自旧项目 design/0044
multi_peak_minimum_relative_height: 0.50 # 出自旧项目 design/0044
multi_peak_maximum_valley_fraction: 0.25 # 出自旧项目 design/0044
sigma_min: 0.08 # 出自旧项目 design/0044
sigma_max: 2.5 # 出自旧项目 design/0044
robust_loss: soft_l1 # 出自旧项目 design/0044
max_nfev: 4000 # 出自旧项目 design/0044
minimum_r2: 0.35 # 出自旧项目 design/0044
maximum_nrmse: 0.45 # 出自旧项目 design/0044
maximum_residual_noise_ratio: 2.0 # 残差不高于基线噪声同量级时允许低 R²。出自旧项目 design/0044
boundary_margin_s: 0.25 # 出自旧项目 design/0044
estimated_baseline_percentile: 15.0 # 无稳定开头时的有界基线先验。出自旧项目 design/0044
estimated_baseline_lookback_s: 10.0 # 允许 t0 位于视频起点前,但截图不外推。出自旧项目 design/0044
maximum_perf_area_step_fraction: 0.15 # 相邻帧去暗区面积比例最大变化。出自旧项目 design/0044
parameter_boundary_fraction: 0.001 # 形状参数贴边判据占允许区间的比例。出自旧项目 design/0044
anchor_frames: # 7 张关键帧定位(第 8 步)。出自旧项目 design/0040 决策二
# 下面这批数旧项目注明镜像自 Linear《临床口径契约》(2026-08-25 版,同步日期 2026-09-01),
# 动任何一个之前先去那边核对。容差窗口的出处任务书 02 第二阶段逐个核对过(旧 yaml 注释、
# 旧 research-wiki/explanation/tic-quantification-encoding.md 第 8、9 节、
# 旧 research-wiki/reference/glossary.md「锚点帧」两张表、旧 design/0030 的「已定的事」表)。
arrival: # 到达判据,门槛取两个候选的高者。出自旧项目:《临床口径契约》5.2
baseline_sd_multiplier: 3.0 # 候选一:基线抖动 ×3.0。出自旧项目:《临床口径契约》5.2
relative_peak_threshold: 0.10 # 候选二:峰高 ×0.10。出自旧项目:《临床口径契约》5.2
persistence_s: 0.5 # 越线后连续保持 0.5 秒。出自旧项目:《临床口径契约》(08-23 确认)
# 主峰突出度门槛:基线抖动 ×3。与到达判据那个 3.0 是两个独立的数,改一个不连带改另一个。
# 出自旧项目:《临床口径契约》第六节
peak_prominence_baseline_sd_multiplier: 3.0
baseline_frame_backoff_s: 0.3 # B0 锚点 = 到达时刻再往前 0.3 秒。出自旧项目:《临床口径契约》5.11(临床方原规范 §13.2)
# D1 窗 [锚点, 锚点+0.5 秒](不许取到达之前)。出自旧项目:《临床口径契约》第 12 题四个容差之一,
# 对应临床方原规范 §13.3
d1_window_after_s: 0.5
d2_window_s: 0.3 # D2 窗 ±0.3 秒。出自旧项目:《临床口径契约》第 12 题,临床方原规范 §13.4
d3_window_s: 0.5 # D3 窗 ±0.5 秒。出自旧项目:《临床口径契约》第 12 题,临床方原规范 §13.5
# D4 窗 ±0.5 秒:临床方原规范 §13.6 只给约束(晚于主峰、不许用最后一帧)不给窗口,契约第 12 题
# 委托工程侧。旧项目工程侧定,理由是 D4 与 D2/D3 同属曲线形状锚点,洗出段比洗入段平缓、导数
# 极值定位误差更大,取 D2/D3 中较宽的一档。无外部出处
d4_window_s: 0.5
# B0 窗 ±0.5 秒:临床口径只说「视频开始到到达前 0.3 秒之间挑帧」,没给窗口。旧项目工程侧取与 D4
# 同档,无外部出处
b0_window_s: 0.5
late_phase:
# F2 锚点:推注后 60 秒。出自旧项目:《临床口径契约》,临床方 2026-08-16 定(旧 glossary 记 HAI-75)
preferred_time_s: 60.0
# F2 容差 ±2 秒(只属于 F2)。出自旧项目:《临床口径契约》第 12 题四个容差之四,临床方原规范
# §10.1、§13.7
tolerance_s: 2.0
# F1 锚点:推注后 20 秒。出自旧项目:《临床口径契约》(08-16 口头定)。
# F1 没有容差键:旧项目工程侧暂定「无上限,在视频有效帧范围内取最近的一帧」(旧
# tic-quantification-encoding.md 第 8 节),临床方没给容差,无外部出处
f1_anchor_s: 20.0