develop - hack_2026

This commit is contained in:
denis 2026-09-22 21:48:31 +03:00
parent 273611f252
commit 7f500759d4
1 changed files with 35 additions and 11 deletions

46
QWEN.md
View File

@ -58,9 +58,10 @@ bone_2026/
### Dataset (`dataset.py`) ### Dataset (`dataset.py`)
- Loads DICOM files from studies - Loads DICOM files from studies
- Parses annotation Excel file - 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) - Quality labels: 0 (OK), 1 (violation)
- Total: ~1433 samples (train: 1146, val: 287) - Uses the same algorithm as inference for consistency
### Model (`model.py`) ### Model (`model.py`)
- Architecture: ResNet18 (pretrained on ImageNet) - 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 | | path_to_study | Path to study directory |
| study_uid | StudyInstanceUID from DICOM | | study_uid | StudyInstanceUID from DICOM |
| image_uid | SOPInstanceUID 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) | | quality_class | 0 (OK), 1 (violation) |
| violation_type | Type of violation (if any) | | violation_type | Type of violation (if any) |
| processing_status | Success / Failure | | 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 ## Model Performance
``` ```
Training data: 1146 samples Training data: 36 samples (80%)
Validation data: 287 samples Validation data: 9 samples (20%)
Training (10 epochs): Note: Limited dataset - more data needed for production
- Best F1: ~0.27 (imbalanced classes: ~65% OK, ~35% violation)
- Accuracy: ~84%
Note: Need more epochs (50+) and class balancing 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 - This is a **hackathon project** for DXA quality assessment
- Model trained on limited data (100 studies) - Model trained on limited data (100 studies)
- Binary classification (quality OK / violation) - 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) - Output format matches hackathon requirements (XLSX/CSV)