A complete web-based platform for converting DICOM mammography data from The Cancer Imaging Archive (TCIA) to STL 3D models using 3D Slicer.
- π DICOM Upload - Drag-and-drop or file picker interface
- π Automated Conversion - 3D Slicer integration for DICOMβSTL
- π Real-time Progress - Live status updates during processing
- π¨ 3D Visualization - Interactive Three.js viewer with WebGL
- βοΈ Parameter Control - Adjustable threshold, smoothing, decimation
- π RESTful API - Complete API for programmatic access
- β‘ Background Processing - Non-blocking conversions
- π§Ή Automatic Cleanup - Scheduled file cleanup
- π³ Docker Support - Containerized deployment
- π± Responsive Design - Works on desktop and mobile
- Quick Start
- Installation
- Configuration
- Usage
- API Documentation
- Architecture
- Troubleshooting
- Contributing
- License
# 1. Clone repository
git clone https://github.com/KY-BChain/MammoViewer.git
cd MammoViewer
# 2. Run setup script
chmod +x setup.sh
./setup.sh
# 3. Configure 3D Slicer path
# Edit backend/config.py and set SLICER_PATH
# 4. Start application
cd backend
python app.py
# 5. Open browser
# Navigate to http://localhost:5000- OS: macOS, Windows, or Linux
- Python: 3.8 or higher
- RAM: 4GB minimum, 8GB recommended
- Disk: 2GB free space
- 3D Slicer: Version 5.0+
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
# macOS/Linux:
source venv/bin/activate
# Windows:
venv\Scripts\activate
# Install dependencies
cd backend
pip install -r requirements.txtDownload from: https://download.slicer.org/
Installation paths:
- macOS:
/Applications/Slicer.app/Contents/MacOS/Slicer - Windows:
C:\Program Files\Slicer 5.4.0\Slicer.exe - Linux:
/usr/local/Slicer-5.4.0-linux-amd64/Slicer
mkdir -p uploads outputs temp logs slicer_scripts# Copy environment template
cp .env.example .env
# Edit .env file with your settings
nano .envEdit backend/config.py:
# 3D Slicer Path (CRITICAL)
SLICER_PATH = '/Applications/Slicer.app/Contents/MacOS/Slicer'
# Server Configuration
HOST = '0.0.0.0'
PORT = 5000
DEBUG = True
# File Upload Limits
MAX_FILE_SIZE = 500 * 1024 * 1024 # 500 MB
MAX_FILES_PER_UPLOAD = 100
# Conversion Parameters
THRESHOLD_DEFAULT = 100
SMOOTHING_ITERATIONS = 15
DECIMATION_RATE = 0.75
# Cleanup
AUTO_CLEANUP = True
CLEANUP_AFTER_HOURS = 24See backend/config.py for all available options:
- Processing limits
- Security settings
- Feature flags
- Logging configuration
- Database settings
- Start Server
cd backend
python app.py-
Open Browser
- Navigate to
http://localhost:5000
- Navigate to
-
Upload DICOM Files
- Drag-and-drop files or click "Choose DICOM Files"
- Supports .dcm and .dicom formats
-
Adjust Parameters
- Threshold (10-1000): Tissue density cutoff
- Smoothing: Reduce surface roughness
- Mesh Simplification (10-100%): File size vs quality
-
Convert
- Click "Convert to STL"
- Monitor real-time progress
-
View & Download
- Interactive 3D viewer with rotation/zoom
- Download STL file for 3D printing or analysis
# Convert single DICOM directory
python backend/slicer_converter.py /path/to/dicom /path/to/output.stl
# With custom threshold
python backend/slicer_converter.py /path/to/dicom /path/to/output.stl 150import requests
# Upload DICOM files
files = [
('files', open('file1.dcm', 'rb')),
('files', open('file2.dcm', 'rb')),
]
response = requests.post('http://localhost:5000/api/upload', files=files)
upload_id = response.json()['upload_id']
# Start conversion
params = {
'upload_id': upload_id,
'threshold': 100,
'smoothing': True,
'decimation': 0.75
}
response = requests.post('http://localhost:5000/api/convert', json=params)
job_id = response.json()['job_id']
# Check status
response = requests.get(f'http://localhost:5000/api/status/{job_id}')
print(response.json())
# Download result
response = requests.get(f'http://localhost:5000/api/download/{stl_file}')
with open('output.stl', 'wb') as f:
f.write(response.content)GET /api/health- Health checkPOST /api/upload- Upload DICOM filesPOST /api/convert- Start conversionGET /api/status/{job_id}- Check job statusGET /api/download/{filename}- Download STLGET /api/preview/{filename}- Preview STLGET /api/jobs- List all jobsPOST /api/cleanup- Manual cleanup
See API_DOCUMENTATION.md for complete details.
Backend:
- Flask 3.0 - Web framework
- pydicom 2.4 - DICOM handling
- SimpleITK 2.3 - Image processing
- VTK 9.3 - 3D visualization
- 3D Slicer - Medical imaging platform
Frontend:
- HTML5/CSS3 - Structure and styling
- Vanilla JavaScript - Application logic
- Three.js r128 - 3D rendering
Infrastructure:
- Docker - Containerization
- Redis (optional) - Job queue
MammoViewer/
βββ backend/ # Flask application
β βββ app.py # Main server
β βββ config.py # Configuration
β βββ dicom_processor.py
β βββ slicer_converter.py
β βββ requirements.txt
βββ frontend/ # Web interface
β βββ index.html
β βββ styles.css
β βββ app.js
βββ uploads/ # Temporary DICOM storage
βββ outputs/ # Generated STL files
βββ docs/ # Documentation
βββ README.md
Error: 3D Slicer not found at: /path/to/Slicer
Solution:
- Verify 3D Slicer is installed
- Update
SLICER_PATHinbackend/config.py - On macOS, ensure path includes
.app/Contents/MacOS/Slicer
Error: Insufficient DICOM slices
Solution:
- Ensure minimum 10 DICOM slices
- Verify DICOM files are valid
- Check all files are from same series
Error: Address already in use
Solution:
# Change port in config.py
PORT = 5001
# Or kill process using port 5000
lsof -ti:5000 | xargs kill -9Error: MemoryError or crashes
Solution:
- Process smaller batches
- Increase mesh decimation (lower quality)
- Close other applications
- Increase system swap space
Enable detailed logging:
# backend/config.py
DEBUG = True
LOG_LEVEL = 'DEBUG'View logs:
tail -f logs/app.logpython test_installation.py- Visit The Cancer Imaging Archive
- Search for mammography datasets
- Download using NBIA Data Retriever
- Upload to MammoViewer
- Breast-Cancer-Screening-DBT
- CBIS-DDSM
- Any mammography DICOM data
# Build image
docker-compose build
# Start services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down- Web Interface: http://localhost:5000
- API: http://localhost:5000/api
Contributions welcome! Please:
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
MIT License - see LICENSE file for details.
- 3D Slicer - Medical imaging platform
- The Cancer Imaging Archive - DICOM data source
- Open source community - All dependencies
- Issues: GitHub Issues
- Documentation: See
/docsfolder - Discussions: GitHub Discussions
- Repository: https://github.com/KY-BChain/MammoViewer
- 3D Slicer: https://www.slicer.org/
- TCIA: https://www.cancerimagingarchive.net/
- pydicom: https://pydicom.github.io/
- User authentication
- Cloud storage integration
- Batch processing UI
- Multiple export formats (OBJ, PLY)
- AI-powered segmentation
- PACS integration
Built with β€οΈ for medical imaging research