A Django-based web application for comparing and evaluating RT structure sets with advanced DICOM visualization tools.
- 📁 Patient Management - Browse and manage patient DICOM studies
- 🔍 DICOM Viewer - Advanced side-by-side CT and RTSTRUCT visualization
- 📊 Structure Comparison - Compare manual vs automatic RT structure sets
- 🎨 Interactive ROI Overlays - Toggle and visualize multiple ROI contours
- ⚙️ Window/Level Controls - Adjust CT image display with presets
- 🔄 Slice Navigation - Navigate through CT slices with keyboard shortcuts
- Backend: Django 5.0+
- Frontend: HTML, CSS (TailwindCSS), Vanilla JavaScript
- DICOM Processing: pydicom, NumPy
- Database: SQLite (development), PostgreSQL (production ready)
- Python 3.10 or higher
- pip (Python package manager)
- Clone the repository:
git clone <repository-url>
cd Structure-Comparision- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Run migrations:
python manage.py migrate- Create a superuser (for admin access):
python manage.py createsuperuser- Run the development server:
python manage.py runserver 8014- Access the application:
- Home: http://localhost:8014/
- Patient List: http://localhost:8014/patients/
- Admin Panel: http://localhost:8014/admin/
python populate_dicom_database.py /path/to/dicom/directorypython manage.py import_dicom_directory /path/to/dicom/directorydicom/
├── patient_id_1/
│ ├── CT_slice_001.dcm
│ ├── CT_slice_002.dcm
│ ├── ...
│ ├── RTSTRUCT_manual.dcm
│ └── RTSTRUCT_auto.dcm
└── patient_id_2/
└── ...
Structure-Comparision/
├── rtstructcompare/ # Main Django app
│ ├── models.py # Database models
│ ├── views.py # View functions (cleaned)
│ ├── urls.py # URL routing
│ ├── admin.py # Admin configuration
│ └── management/ # Custom management commands
├── templates/ # HTML templates
│ ├── base.html # Base template
│ ├── home.html # Landing page
│ ├── patients.html # Patient list
│ └── dicom_web_viewer.html # DICOM viewer
├── static/ # Static files (CSS, JS, images)
├── dicom/ # DICOM files directory (gitignored)
├── populate_dicom_database.py # DICOM import script
├── requirements.txt # Python dependencies
└── manage.py # Django management script
patient_id- Unique patient identifierpatient_name- Patient namepatient_birth_date- Date of birthpatient_sex- Gender
- Links to Patient
study_instance_uid- Unique study identifierstudy_date- Study datestudy_description- Study description
- Links to DICOMStudy
series_instance_uid- Unique series identifiermodality- CT, RTSTRUCT, etc.series_description- Series descriptionseries_root_path- Path to DICOM files
- Links to DICOMSeries
sop_instance_uid- Unique instance identifierinstance_number- Instance numberinstance_path- Full path to DICOM file
- Navigate to http://localhost:8014/patients/
- Browse the list of imported patients
- Click "Compare Studies" to open the DICOM viewer
Navigation:
- Previous/Next buttons - Navigate between slices
- Slice slider - Jump to specific slice
- Arrow Up/Down keys - Navigate slices
Window/Level:
- Soft Tissue - W:400, L:40
- Lung - W:1500, L:-600
- Bone - W:2000, L:300
- Brain - W:80, L:40
- Liver - W:150, L:60
- Custom - Manual adjustment
ROI Overlays:
- Select individual ROIs from the list
- Select All / Clear All buttons
- Common structures shown between both RTSTRUCT files
python manage.py testpython manage.py checkpython manage.py makemigrations
python manage.py migrateKey settings in rtstructcompare/settings.py:
DEBUG- Set toFalsein productionALLOWED_HOSTS- Add your domain in productionDATABASES- Configure PostgreSQL for productionSTATIC_ROOT- Set for production static files
Create a .env file for sensitive settings:
SECRET_KEY=your-secret-key-here
DEBUG=False
ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
DATABASE_URL=postgresql://user:password@localhost/dbname- Set
DEBUG = False - Configure
ALLOWED_HOSTS - Use PostgreSQL database
- Set up static file serving
- Configure HTTPS
- Set strong
SECRET_KEY - Enable CSRF protection
- Configure logging
- Set up backups
python manage.py collectstaticProblem: Files not importing
- Check file permissions
- Verify DICOM file format
- Check console output for errors
Problem: Missing RTSTRUCT files
- Ensure at least 2 RTSTRUCT files per patient
- Check modality field in DICOM files
Problem: Blank/black canvases
- Check browser console for JavaScript errors
- Verify CT and RTSTRUCT data loaded correctly
- Check that pixel data exists in DICOM files
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
[Add your license here]
For issues and questions:
- Create an issue on GitHub
- Contact: [your-email@example.com]
- Built with Django
- DICOM processing powered by pydicom
- UI components using TailwindCSS
Version: 1.0.0
Last Updated: January 2026