From 7f500759d4c0f7e2bf37e9fe9be89c4a0cb3f679 Mon Sep 17 00:00:00 2001 From: denis Date: Tue, 22 Sep 2026 21:48:31 +0300 Subject: [PATCH] develop - hack_2026 --- QWEN.md | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/QWEN.md b/QWEN.md index d204199..4a087e8 100644 --- a/QWEN.md +++ b/QWEN.md @@ -58,9 +58,10 @@ bone_2026/ ### Dataset (`dataset.py`) - Loads DICOM files from studies - Parses annotation Excel file -- Maps anatomical regions: spine, hip_right, hip_left +- **Automatically detects anatomical region from image content** +- Maps regions: spine, hip_right, hip_left - Quality labels: 0 (OK), 1 (violation) -- Total: ~1433 samples (train: 1146, val: 287) +- Uses the same algorithm as inference for consistency ### Model (`model.py`) - Architecture: ResNet18 (pretrained on ImageNet) @@ -117,7 +118,7 @@ python -m uvicorn src.main:app --host 0.0.0.0 --port 8000 | path_to_study | Path to study directory | | study_uid | StudyInstanceUID from DICOM | | image_uid | SOPInstanceUID from DICOM | -| anatomical_region | spine / hip | +| anatomical_region | spine / hip_left / hip_right / hip | | quality_class | 0 (OK), 1 (violation) | | violation_type | Type of violation (if any) | | processing_status | Success / Failure | @@ -125,17 +126,40 @@ python -m uvicorn src.main:app --host 0.0.0.0 --port 8000 --- +## Anatomical Region Detection + +The system automatically determines the anatomical region from the DICOM image content: + +### Algorithm (`src/dxa/inference.py`) +1. **Spine vs Hip** - by bright region shape: + - Extract 95th percentile threshold + - Calculate bounding box aspect ratio + - Spine: bbox_aspect < 1.5 (more square) + - Hip: bbox_aspect > 1.5 (vertically elongated) + +2. **Hip Left vs Right** - by brightness asymmetry: + - Calculate left/right bright pixel ratio + - hip_left: L/R ratio < 0.7 (left side brighter) + - hip_right: L/R ratio > 1.3 (right side brighter) + - hip: unclear (fallback) + +### Features Used +- Bright region aspect ratio (primary discriminator) +- Image symmetry (secondary for borderline cases) +- Left/right brightness ratio (for hip side detection) + +### Fallback +If image analysis fails, uses filename-based detection as fallback. + +--- + ## Model Performance ``` -Training data: 1146 samples -Validation data: 287 samples +Training data: 36 samples (80%) +Validation data: 9 samples (20%) -Training (10 epochs): -- Best F1: ~0.27 (imbalanced classes: ~65% OK, ~35% violation) -- Accuracy: ~84% - -Note: Need more epochs (50+) and class balancing for production +Note: Limited dataset - more data needed for production ``` --- @@ -189,5 +213,5 @@ docker run -v /data:/data -p 8000:8000 dxa-quality - This is a **hackathon project** for DXA quality assessment - Model trained on limited data (100 studies) - Binary classification (quality OK / violation) -- Anatomical region detection via image size heuristic +- **Anatomical region detection via image analysis** (bright region shape + asymmetry) - Output format matches hackathon requirements (XLSX/CSV)