Skip to main content
Warning: this assignment is not yet released. Check back on February 4, 2026.
This assignment is due on Wednesday, February 11, 2026 before 11:59PM.

Get Started:

  1. Accept the assignment on GitHub Classroom — You’ll get your own private repository with starter code and sample DICOM data
  2. Clone your repo and complete the exercises in hw2_dicom.py
  3. Commit regularly as you work (this is part of your grade!)
  4. Push your completed work to GitHub before the deadline

Two-Track Structure: This assignment has a Core Track (Parts 1-3) that everyone completes, and an Advanced Track (Part 4) for students who want to dive deeper into radiation therapy data. The Advanced Track is optional but can earn you extra credit.


Learning Objectives

By completing this assignment, you will:


Background

DICOM (Digital Imaging and Communications in Medicine) is the universal standard for medical imaging. Every CT scan, MRI, X-ray, and most other medical images you’ll encounter in clinical AI are stored as DICOM files.

Understanding DICOM is essential because:


Instructions

Part 1: DICOM Basics (30 points)

1.1 Reading DICOM Files (10 pts)

Load a CT DICOM file and extract key metadata:

1.2 Understanding DICOM Tags (10 pts)

DICOM uses a tag system (Group, Element) to organize data. For the provided CT file:

1.3 Pixel Data Access (10 pts)

Extract and examine the pixel array:


Part 2: Visualization & Window/Level (30 points)

2.1 Basic Visualization (10 pts)

Display a CT slice using matplotlib:

2.2 Window/Level for Different Tissues (15 pts)

The same CT data looks completely different depending on window/level settings. Create a figure showing the same slice with four different window/level presets:

Preset Window Width (W) Window Level (L) Use Case
Lung 1500 -600 Lung parenchyma, airways
Soft Tissue 400 40 Abdomen, organs
Bone 2000 400 Skeletal structures
Brain 80 40 Brain parenchyma

Display all four in a 2x2 subplot figure.

2.3 Custom Window/Level Function (5 pts)

Write a reusable function apply_window_level(image, window, level) that:


Part 3: DICOM Geometry & Coordinates (25 points)

3.1 Image Position and Orientation (10 pts)

For medical imaging AI, understanding spatial relationships is critical. Extract and explain:

3.2 Loading a CT Series (15 pts)

A CT scan consists of many slices. Write code to:


Part 4: Advanced Track — Radiation Therapy DICOM (25 points EXTRA CREDIT)

Optional: This section is for students who want to explore radiation therapy data. It covers RT Structure Sets, RT Dose, and DVH calculation. Complete Parts 1-3 first!

4.1 RT Structure Set Basics (8 pts)

RT Structure Sets (RTSTRUCT) contain contoured regions of interest (ROIs) like organs and tumors.

4.2 RT Dose Visualization (8 pts)

RT Dose files contain 3D dose distributions from radiation treatment planning.

4.3 DVH Calculation (9 pts)

A Dose-Volume Histogram (DVH) is a fundamental tool in radiation oncology, showing what percentage of a structure receives at least a given dose.


Submission via GitHub

  1. Complete your work in hw2_dicom.py
  2. Commit your changes with meaningful messages:
    git add hw2_dicom.py
    git commit -m "Complete Part 2: window/level visualization"
    
  3. Push to GitHub before the deadline:
    git push
    

Commit Expectations


Grading Rubric

Core Track (Required)

Component Points
Part 1: DICOM Basics 30
1.1 Reading DICOM files 10
1.2 Understanding DICOM tags 10
1.3 Pixel data access 10
Part 2: Visualization 30
2.1 Basic visualization 10
2.2 Window/level presets 15
2.3 Custom W/L function 5
Part 3: Geometry 25
3.1 Position and orientation 10
3.2 Loading CT series 15
Git Workflow 15
Multiple meaningful commits 8
Clear commit messages 7
Core Total 100

Advanced Track (Extra Credit)

Component Points
4.1 RT Structure basics 8
4.2 RT Dose visualization 8
4.3 DVH calculation 9
Advanced Total +25

Resources


Tips


Sample Data

Your repository includes sample DICOM data in the data/ directory:

This data is de-identified and safe to use for educational purposes.