docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
---
|
||||
id: wiki-2026-0508-medical-imaging-data-augmentation
|
||||
title: Medical Imaging Data Augmentation
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [Medical Augmentation, MONAI Augmentation, 의료영상 증강]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [medical-imaging, data-augmentation, monai, deep-learning, segmentation]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack: { language: python, framework: monai-pytorch }
|
||||
---
|
||||
|
||||
# Medical Imaging Data Augmentation
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 환자 데이터는 매 적고, 매 anatomy 는 망가뜨릴 수 없다"**. 의료영상 augmentation 은 일반 이미지 대비 (1) 데이터가 매우 적고 (2) 라벨이 픽셀 단위 정확해야 하며 (3) 비현실적 변형이 진단을 망친다는 제약 안에서 기하·강도·합성 변환을 신중히 적용해야 한다.
|
||||
|
||||
## 매 핵심
|
||||
### 매 도메인 특성
|
||||
- 3D volume (CT/MRI), DICOM/NIfTI 포맷, voxel spacing 다양.
|
||||
- 라벨이 segmentation mask / bbox / 환자 단위 진단 — affine 변환 시 동기화.
|
||||
- HU scale (CT), bias field (MRI) 등 강도 분포가 modality 마다 다름.
|
||||
|
||||
### 매 변환 카테고리
|
||||
1. **Spatial / 기하**: flip, rotate (소각), translate, scale, elastic deformation, B-spline.
|
||||
2. **Intensity**: brightness/contrast, gamma, Gaussian noise, Rician noise (MRI), bias field, MR motion artifact.
|
||||
3. **Spacing / Resolution**: random resample, low-res sim.
|
||||
4. **Topology-preserving**: mixup/cutmix 의 의료 variant — 단, lesion mask 가 깨지지 않도록 patch-aware.
|
||||
5. **Synthesis**: GAN/diffusion 으로 lesion 합성, healthy↔lesion translation.
|
||||
|
||||
### 매 라이브러리
|
||||
1. **MONAI**: PyTorch 기반 의료영상 표준, `Compose`, dictionary transform.
|
||||
2. **TorchIO**: 3D 친화, MRI artifact 풍부.
|
||||
3. **Albumentations**: 2D slice/엑스레이.
|
||||
4. **NVIDIA DALI**: GPU augmentation 파이프라인.
|
||||
|
||||
## 💻 패턴
|
||||
### 1. MONAI dict transform pipeline
|
||||
```python
|
||||
from monai.transforms import (Compose, LoadImaged, EnsureChannelFirstd,
|
||||
Spacingd, Orientationd, ScaleIntensityRanged, RandCropByPosNegLabeld,
|
||||
RandAffined, RandGaussianNoised, RandBiasFieldd, ToTensord)
|
||||
|
||||
train_t = Compose([
|
||||
LoadImaged(keys=["img","seg"]),
|
||||
EnsureChannelFirstd(keys=["img","seg"]),
|
||||
Orientationd(keys=["img","seg"], axcodes="RAS"),
|
||||
Spacingd(keys=["img","seg"], pixdim=(1,1,1), mode=("bilinear","nearest")),
|
||||
ScaleIntensityRanged(keys="img", a_min=-200, a_max=300, b_min=0, b_max=1, clip=True),
|
||||
RandCropByPosNegLabeld(keys=["img","seg"], label_key="seg",
|
||||
spatial_size=(96,96,96), pos=1, neg=1, num_samples=4),
|
||||
RandAffined(keys=["img","seg"], rotate_range=0.1, scale_range=0.1,
|
||||
mode=("bilinear","nearest"), prob=0.5),
|
||||
RandGaussianNoised(keys="img", std=0.01, prob=0.2),
|
||||
RandBiasFieldd(keys="img", coeff_range=(0.0,0.1), prob=0.2),
|
||||
ToTensord(keys=["img","seg"]),
|
||||
])
|
||||
```
|
||||
|
||||
### 2. Elastic deformation
|
||||
```python
|
||||
from monai.transforms import Rand3DElasticd
|
||||
Rand3DElasticd(keys=["img","seg"], sigma_range=(5,7), magnitude_range=(50,150),
|
||||
mode=("bilinear","nearest"), prob=0.3)
|
||||
```
|
||||
Anatomy 자연스러운 변형 — sigma 너무 작으면 비현실, 크면 underfit.
|
||||
|
||||
### 3. TorchIO MRI artifact
|
||||
```python
|
||||
import torchio as tio
|
||||
tx = tio.Compose([
|
||||
tio.RandomMotion(degrees=5, translation=5, p=0.2),
|
||||
tio.RandomGhosting(num_ghosts=(2,5), p=0.2),
|
||||
tio.RandomBiasField(coefficients=0.3, p=0.3),
|
||||
tio.RandomNoise(std=(0,0.05), p=0.3),
|
||||
])
|
||||
```
|
||||
|
||||
### 4. CT HU window robust
|
||||
```python
|
||||
def hu_window(vol, center, width):
|
||||
lo, hi = center - width/2, center + width/2
|
||||
return np.clip((vol - lo) / (hi - lo), 0, 1)
|
||||
# 학습 중 center/width 를 약하게 jitter
|
||||
```
|
||||
|
||||
### 5. Lesion-aware MixUp (segmentation)
|
||||
```python
|
||||
def lesion_mixup(x1, y1, x2, y2, alpha=0.2):
|
||||
lam = np.random.beta(alpha, alpha)
|
||||
x = lam*x1 + (1-lam)*x2
|
||||
y = (y1 + y2).clip(0,1) # union mask
|
||||
return x, y
|
||||
```
|
||||
|
||||
### 6. Diffusion synthetic lesion
|
||||
```python
|
||||
# Stable Diffusion fine-tuned on chest X-ray with lesion mask conditioning
|
||||
img = pipe(prompt="pneumonia consolidation right lower lobe", mask=mask).images[0]
|
||||
# 합성 데이터는 별도 split, 평가는 real only
|
||||
```
|
||||
|
||||
### 7. Test-Time Augmentation (TTA)
|
||||
```python
|
||||
preds = []
|
||||
for tta in [identity, flip_x, flip_y, rot90]:
|
||||
preds.append(undo(model(tta(x))))
|
||||
final = torch.stack(preds).mean(0)
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Augmentation |
|
||||
|---|---|
|
||||
| 작은 segmentation 데이터 | strong elastic + intensity + cropbypos/neg |
|
||||
| 분류 (X-ray) | mild affine + cutout, lesion 보호 |
|
||||
| MRI multi-site | bias field + intensity histogram match |
|
||||
| CT multi-protocol | HU window jitter + spacing resample |
|
||||
| 매우 적은 라벨 | + synthetic (GAN/diffusion) + self-supervised pretrain |
|
||||
|
||||
**기본값**: MONAI `Compose` + spacing/orient 정규화 → mild affine + intensity + (3D 면) crop-by-label.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Data-Augmentation]]
|
||||
- Adjacent: [[Diffusion-Model]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: pipeline boilerplate, modality 별 적절 변환 추천, 코드 review.
|
||||
**언제 X**: 임상적 plausibility 판단 (radiologist 검증 필요).
|
||||
|
||||
## ❌ 안티패턴
|
||||
- 90° rotate / 큰 scale → CT 좌표계/anatomy 깨짐.
|
||||
- segmentation mask 에 bilinear interpolation — 라벨 손상.
|
||||
- intensity normalize 를 augmentation 후 적용 → 분포 불일치.
|
||||
- synthetic 데이터를 real 평가셋과 섞기 — leakage.
|
||||
- 모든 patient slice 를 독립 sample 로 — patient-level leakage, split 단위는 patient.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified. 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup |
|
||||
Reference in New Issue
Block a user