Label Studio 乳腺癌钼靶分类标注模板:基于 BI-RADS 的四视图网格标注方案
【免费下载链接】label-studioLabel Studio is a multi-type data labeling and annotation tool with standardized output format项目地址: https://gitcode.com/GitHub_Trending/la/label-studio
本文以 Label Studio 社区贡献模板 breast_cancer_mammogram_classification.md 为骨架,完整讲解如何基于 BI-RADS(乳腺影像报告和数据系统)构建乳腺癌钼靶(Mammogram)分类标注界面。你将掌握四视图(L-CC / L-MLO / R-CC / R-MLO)网格布局的 XML 配置方法、左右乳腺独立的 BI-RADS 分级与乳腺密度(A–D)评估、常见征象多选记录,以及任务数据的组织方式,可直接用于放射影像标注项目的落地。
模板概述:为放射科医生设计的 BI-RADS 分类工作流
该模板由社区贡献者(redeipirati等)提供,仓库中对应实现位于 label_studio/annotation_templates/community-contributions/breast-cancer-mammogram-classification/config.xml,模板元数据与示例数据见同目录下的 config.yml。
其核心设计目标是:让标注人员(通常是放射科医生或受训标注员)在单一界面内,同时完成双侧乳腺(Left / Right)× 两个标准投照体位(CC 头尾位、MLO 内外斜位)共四张钼靶影像的查看、比对与分类记录。界面遵循 BI-RADS 标准的临床工作流,覆盖三类核心信息:
| 信息维度 | 采用标准 | 字段示例 |
|---|---|---|
| BI-RADS 分类 | 0–6 七级分类 | birads_left/birads_right |
| 乳腺密度 | A–D 四级分类 | density_left/density_right |
| 常见征象 | 多选(Mass 等 5 类) | findings_left/findings_right |
此外还提供自由文本备注区(notes),用于记录技术问题、与既往检查的对比等补充观察。
完整标注配置
以下为模板的完整 Labeling Configuration(与仓库 config.xml 一致):
<View> <Style> .mammogram-container { padding: var(--spacing-600); box-shadow: 0 2px 8px rgba(var(--color-neutral-shadow-raw) / 0.15); border-radius: var(--corner-radius-medium); margin-bottom: var(--spacing-800); } .mammogram-grid { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; grid-template-areas: 'left-cc right-cc' 'left-mlo right-mlo'; gap: var(--spacing-600); margin: var(--spacing-600) 0; max-width: 1000px; margin-left: auto; margin-right: auto; } .mammogram-view { text-align: center; border: 2px solid var(--color-neutral-border); border-radius: var(--corner-radius-medium); padding: var(--spacing-500); background: var(--color-neutral-background); transition: border-color 0.3s ease; min-height: 480px; display: flex; flex-direction: column; } .mammogram-view:hover { border-color: var(--color-primary-border-subtle); } .left-cc { grid-area: left-cc; } .right-cc { grid-area: right-cc; } .left-mlo { grid-area: left-mlo; } .right-mlo { grid-area: right-mlo; } .mammogram-image { width: 100%; height: 400px; object-fit: contain; border-radius: var(--corner-radius-small); background: var(--color-neutral-background); } .view-header { font-size: var(--font-size-16); font-weight: var(--font-weight-semibold); color: var(--color-neutral-content); margin-bottom: var(--spacing-300); padding: var(--spacing-200) var(--spacing-300); background: var(--color-neutral-surface); border: 1px solid var(--color-neutral-border-subtle); border-radius: var(--corner-radius-small); text-align: center; } .instructions { background: var(--color-primary-background); padding: var(--spacing-500); border-radius: var(--corner-radius-medium); border-left: 4px solid var(--color-primary-border); margin-bottom: var(--spacing-600); line-height: var(--line-height-body-medium); } .instructions-header { font-size: var(--font-size-16); margin-bottom: var(--spacing-400); line-height: var(--line-height-body-medium); color: var(--color-neutral-content); } .birads-legend { background: var(--color-warning-background); color: var(--color-warning-content); padding: var(--spacing-400); border-radius: var(--corner-radius-small); border: 1px solid var(--color-warning-border-subtler); margin-top: var(--spacing-400); font-size: var(--font-size-14); line-height: var(--line-height-body-small); } .classification-section { background: var(--color-neutral-background); color: var(--color-neutral-content); padding: var(--spacing-600); border-radius: var(--corner-radius-medium); box-shadow: 0 2px 4px rgba(var(--color-neutral-shadow-raw) / 0.1); margin: var(--spacing-500) 0; border: 1px solid var(--color-neutral-border-subtle); } </Style> <!-- Header for context --> <Header value="Breast Cancer Mammogram Classification" style="text-align: center; font-size: var(--font-size-24); color: var(--color-neutral-content); margin-bottom: var(--spacing-500);" /> <!-- Instructions --> <View className="instructions"> <Header value="Please review the standard mammographic views (CC and MLO) of both breasts. Compare corresponding views (e.g., L-CC with R-CC). Label each breast individually, and report any findings." style="font-size: 16px; margin-bottom: 10px; height:auto;" /> <View className="birads-legend"> <Text name="birads_legend" value="BI-RADS: 0 = Incomplete, 1 = Negative, 2 = Benign, 3 = Probably Benign, 4 = Suspicious, 5 = Highly Suggestive of Malignancy, 6 = Known Cancer" /> </View> </View> <!-- Mammogram Views Grid --> <View className="mammogram-container"> <View className="mammogram-grid"> <!-- Left CC --> <View className="mammogram-view left-cc"> <Header value="Left CC" className="view-header" /> <Image name="left_cc" value="$img1" className="mammogram-image" /> </View> <!-- Right CC --> <View className="mammogram-view right-cc"> <Header value="Right CC" className="view-header" /> <Image name="right_cc" value="$img3" className="mammogram-image" /> </View> <!-- Left MLO --> <View className="mammogram-view left-mlo"> <Header value="Left MLO" className="view-header" /> <Image name="left_mlo" value="$img2" className="mammogram-image" /> </View> <!-- Right MLO --> <View className="mammogram-view right-mlo"> <Header value="Right MLO" className="view-header" /> <Image name="right_mlo" value="$img4" className="mammogram-image" /> </View> </View> </View> <!-- Left Breast Classification --> <View className="classification-section"> <Header value="Left Breast: BI-RADS Classification" style="font-size: var(--font-size-20); color: var(--color-neutral-content); margin-bottom: var(--spacing-400);" /> <Choices name="birads_left" toName="left_cc,right_cc,left_mlo,right_mlo" choice="single" required="true"> <Choice value="0 - Incomplete" /> <Choice value="1 - Negative" /> <Choice value="2 - Benign" /> <Choice value="3 - Probably Benign" /> <Choice value="4 - Suspicious Abnormality" /> <Choice value="5 - Highly Suggestive of Malignancy" /> <Choice value="6 - Known Biopsy-Proven Malignancy" /> </Choices> <Header value="Left Breast: Density" style="font-size: var(--font-size-16); color: var(--color-neutral-content-subtle); margin: var(--spacing-500) 0 var(--spacing-200) 0;" /> <Choices name="density_left" toName="left_cc,right_cc,left_mlo,right_mlo" choice="single"> <Choice value="A - Almost entirely fatty" /> <Choice value="B - Scattered fibroglandular densities" /> <Choice value="C - Heterogeneously dense" /> <Choice value="D - Extremely dense" /> </Choices> <Header value="Left Breast: Findings (Optional)" style="font-size: var(--font-size-16); color: var(--color-neutral-content-subtle); margin: var(--spacing-500) 0 var(--spacing-200) 0;" /> <Choices name="findings_left" toName="left_cc,right_cc,left_mlo,right_mlo" choice="multiple"> <Choice value="Mass" /> <Choice value="Calcifications" /> <Choice value="Architectural Distortion" /> <Choice value="Asymmetry" /> <Choice value="Skin/Nipple Retraction" /> </Choices> </View> <!-- Right Breast Classification --> <View className="classification-section"> <Header value="Right Breast: BI-RADS Classification" style="font-size: var(--font-size-20); color: var(--color-neutral-content); margin-bottom: var(--spacing-400);" /> <Choices name="birads_right" toName="left_cc,right_cc,left_mlo,right_mlo" choice="single" required="true"> <Choice value="0 - Incomplete" /> <Choice value="1 - Negative" /> <Choice value="2 - Benign" /> <Choice value="3 - Probably Benign" /> <Choice value="4 - Suspicious Abnormality" /> <Choice value="5 - Highly Suggestive of Malignancy" /> <Choice value="6 - Known Biopsy-Proven Malignancy" /> </Choices> <Header value="Right Breast: Density" style="font-size: var(--font-size-16); color: var(--color-neutral-content-subtle); margin: var(--spacing-500) 0 var(--spacing-200) 0;" /> <Choices name="density_right" toName="left_cc,right_cc,left_mlo,right_mlo" choice="single"> <Choice value="A - Almost entirely fatty" /> <Choice value="B - Scattered fibroglandular densities" /> <Choice value="C - Heterogeneously dense" /> <Choice value="D - Extremely dense" /> </Choices> <Header value="Right Breast: Findings (Optional)" style="font-size: var(--font-size-16); color: var(--color-neutral-content-subtle); margin: var(--spacing-500) 0 var(--spacing-200) 0;" /> <Choices name="findings_right" toName="left_cc,right_cc,left_mlo,right_mlo" choice="multiple"> <Choice value="Mass" /> <Choice value="Calcifications" /> <Choice value="Architectural Distortion" /> <Choice value="Asymmetry" /> <Choice value="Skin/Nipple Retraction" /> </Choices> </View> <!-- Additional Observations --> <View className="classification-section"> <Header value="Additional Observations / Notes (Optional)" style="font-size: var(--font-size-20); color: var(--color-neutral-content); margin-bottom: var(--spacing-400);" /> <TextArea name="notes" toName="left_cc,right_cc,left_mlo,right_mlo" rows="5" placeholder="Describe any notable findings, technical issues, or comparison to prior exams." style="width: 100%; padding: var(--spacing-300); border: 2px solid var(--color-neutral-border); border-radius: var(--corner-radius-small); font-size: var(--font-size-14); background: var(--color-neutral-background); color: var(--color-neutral-content);" /> </View> </View>提示:所有标注配置(Labeling Configuration)都必须包裹在
<View>标签内,详见 View 标签文档。
配置拆解:从样式系统到功能区块
1. 使用<Style>建立"诊断工作台"式视觉布局
模板在<Style>标签内定义了完整 CSS,全部基于 Label Studio 的设计令牌(Design Tokens,如var(--spacing-600)、var(--color-neutral-border)、var(--corner-radius-medium)),因此能自动适配浅色/深色主题,无需硬编码颜色值。
关键的布局思路:
.mammogram-grid使用 CSS Grid 定义 2×2 网格:grid-template-areas明确映射为'left-cc right-cc'/'left-mlo right-mlo',与放射影像阅片习惯一致——上方为 CC(头尾位),下方为 MLO(内外斜位),左侧为左乳、右侧为右乳,便于左右对应视图直接对比;.mammogram-view为每个视图提供卡片容器:设置min-height: 480px与 flex 纵向排列,保证四张影像高度对齐;:hover时边框高亮(transition: border-color 0.3s ease),帮助标注员定位当前查看的视图;.mammogram-image使用object-fit: contain:影像等比缩放完整显示,避免裁剪造成阅片信息丢失;.birads-legend采用警示色背景:将 BI-RADS 分级速查表常驻显示在操作区顶部,减少标注员记忆负担;.classification-section将左右乳腺分类区块卡片化:每个区块带边框、圆角与轻阴影,视觉上区分"影像区"与"评估区"。
2. 四视图影像网格:<Image>与任务数据绑定
<View className="mammogram-grid"> <View className="mammogram-view left-cc"> <Header value="Left CC" className="view-header" /> <Image name="left_cc" value="$img1" className="mammogram-image" /> </View> <!-- ... 其余三个视图同理 ... --> </View>四个<Image>标签分别命名为left_cc、left_mlo、right_cc、right_mlo,通过value="$img1"至value="$img4"从任务数据中读取图片 URL(Image 标签文档)。结合仓库 config.yml 中附带的示例数据映射,字段对应关系为:
| 任务数据字段 | 对应视图 | Image 标签 name |
|---|---|---|
img1 | Left CC(左乳头尾位) | left_cc |
img2 | Left MLO(左乳内外斜位) | left_mlo |
img3 | Right CC(右乳头尾位) | right_cc |
img4 | Right MLO(右乳内外斜位) | right_mlo |
值得注意的是,toName统一指向这四个 Image 标签名称(逗号分隔),因此所有分类字段在语义上都归属于这组影像对象。
3. 左右乳腺独立的 BI-RADS 分级(必填)
<Choices name="birads_left" toName="left_cc,right_cc,left_mlo,right_mlo" choice="single" required="true"> <Choice value="0 - Incomplete" /> <Choice value="1 - Negative" /> <Choice value="2 - Benign" /> <Choice value="3 - Probably Benign" /> <Choice value="4 - Suspicious Abnormality" /> <Choice value="5 - Highly Suggestive of Malignancy" /> <Choice value="6 - Known Biopsy-Proven Malignancy" /> </Choices>左右乳腺各有一个独立的Choices单选框组(birads_left/birads_right),完整覆盖 BI-RADS 0–6 七个分类级别(Choices 标签文档):
| 级别 | 含义 |
|---|---|
| 0 | Incomplete(评估不完整,需补充影像/检查) |
| 1 | Negative(阴性) |
| 2 | Benign(良性) |
| 3 | Probably Benign(可能良性,建议短期随访) |
| 4 | Suspicious Abnormality(可疑异常,建议活检) |
| 5 | Highly Suggestive of Malignancy(高度提示恶性) |
| 6 | Known Biopsy-Proven Malignancy(已知活检证实恶性) |
choice="single"表示单选;required="true"强制标注员对每个乳腺都必须给出分级,确保输出数据的完整性。
4. 乳腺密度评估(A–D 四级)
<Choices name="density_left" toName="left_cc,right_cc,left_mlo,right_mlo" choice="single"> <Choice value="A - Almost entirely fatty" /> <Choice value="B - Scattered fibroglandular densities" /> <Choice value="C - Heterogeneously dense" /> <Choice value="D - Extremely dense" /> </Choices>密度评估同样左右乳腺独立(density_left/density_right),采用 BI-RADS 第五版的 A–D 四级标准:A(几乎全部为脂肪)、B(散在纤维腺体密度)、C(不均匀致密)、D(极度致密)。该字段未设置required,属于可选评估项。
5. 常见征象多选记录(可选)
<Choices name="findings_left" toName="left_cc,right_cc,left_mlo,right_mlo" choice="multiple"> <Choice value="Mass" /> <Choice value="Calcifications" /> <Choice value="Architectural Distortion" /> <Choice value="Asymmetry" /> <Choice value="Skin/Nipple Retraction" /> </Choices>choice="multiple"开启多选,覆盖乳腺影像报告中 5 类常见征象:肿块(Mass)、钙化(Calcifications)、结构扭曲(Architectural Distortion)、不对称(Asymmetry)、皮肤/乳头回缩(Skin/Nipple Retraction)。左右乳腺分别记录(findings_left/findings_right)。
6. 自由文本备注区
<TextArea name="notes" toName="left_cc,right_cc,left_mlo,right_mlo" rows="5" placeholder="Describe any notable findings, technical issues, or comparison to prior exams." ... />TextArea标签(TextArea 标签文档)提供 5 行自由文本输入,用于记录其他发现、影像技术质量问题(如伪影、体位不标准)或与既往检查(prior exams)的对比,placeholder 已给出引导性提示。
任务数据准备与示例
在 Label Studio 中创建项目后,可通过Settings → Labeling Interface粘贴上述配置。任务数据(JSON/CSV)需要包含四个图片字段,参考 config.yml 中的示例数据注释,结构如下:
{ "data": { "img1": "https://example.com/assets/l-cc.png", "img2": "https://example.com/assets/r-cc.png", "img3": "https://example.com/assets/l-mlo.png", "img4": "https://example.com/assets/r-mlo.png" } }导入时需保证img1–img4四个字段齐全,否则对应视图将无法显示。图片既可以是可公开访问的 URL,也可以使用本地存储(Local Storage)或 S3、GCS 等云存储源。
标注输出格式
提交后,Label Studio 会为每个任务生成标准化的 JSON 标注结果。以左侧乳腺为例,BI-RADS 分类、密度与征象会分别产出choices类型的 result 记录:
[ { "from_name": "birads_left", "to_name": "left_cc,right_cc,left_mlo,right_mlo", "type": "choices", "value": { "choices": ["4 - Suspicious Abnormality"] } }, { "from_name": "density_left", "to_name": "left_cc,right_cc,left_mlo,right_mlo", "type": "choices", "value": { "choices": ["C - Heterogeneously dense"] } }, { "from_name": "findings_left", "to_name": "left_cc,right_cc,left_mlo,right_mlo", "type": "choices", "value": { "choices": ["Mass", "Calcifications"] } } ]备注文本则产出textarea类型的 result:
{ "from_name": "notes", "to_name": "left_cc,right_cc,left_mlo,right_mlo", "type": "textarea", "value": { "text": ["多学科会诊后建议补充放大摄影。"] } }这种"标准化输出"正是 Label Studio 的定位所在——标注结果可直接转换为后续机器学习训练所需的统一格式(详细格式说明可参考 Task 格式文档 与 Result 格式说明)。
使用步骤与扩展建议
- 创建项目:在 Label Studio 中新建项目,进入Settings → Labeling Interface;
- 粘贴配置:将上文完整配置复制到 Labeling Interface 编辑器中(可用Code模式),Label Studio 会自动校验 XML 合法性;
- 准备数据:按
img1–img4字段组织任务数据并导入; - 分配任务:将任务分配给标注员(或标注团队),标注员按界面提示依次完成左右乳腺的分级、密度与征象标注;
- 导出结果:通过Export功能导出 JSON/CSV 等格式的标注结果。
在此基础上,你可以按需扩展模板:
- 为 0–6 各分级添加热键(
<Choice value="..." hotkey="1"/>),提升标注效率(参考 Shortcut 标签文档); - 使用
visibleWhen条件显示逻辑,例如当 BI-RADS ≥ 4 时才显示征象多选框; - 若需在影像上绘制病灶区域,可引入 Rectangle 标签 或 KeyPoint 标签 与分类字段配合。
延伸阅读
- 本模板的仓库实现:config.xml 与 config.yml
- 模板中使用的标签文档:View、Image、Choices、TextArea、Header、Style
- 社区贡献模板总览:community-contributions
- 其他医学影像相关模板可参考 label_studio/annotation_templates 目录下的 computer-vision 等分类
- 更多模板的 HTML 渲染示例见 docs/source/templates
【免费下载链接】label-studioLabel Studio is a multi-type data labeling and annotation tool with standardized output format项目地址: https://gitcode.com/GitHub_Trending/la/label-studio
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考