Materials for MP‑566: Physics of Radiotherapy, Lab 8 at UW‑Madison. The lab walks students through acquiring Winston‑Lutz (WL) MV portal images on a Varian TrueBeam, then analyzing them to check whether the mechanical and radiation isocenters coincide within AAPM TG‑142 / TG‑198 tolerance for SRS/SBRT machines.
Both the original MATLAB analysis and a modern Python/Colab version are included. The Python version uses pylinac, which implements the same Low et al. (1995) formalism as the MATLAB code.
| File | Purpose |
|---|---|
Lab8_WinstonLutz.ipynb |
Student notebook (Google Colab–ready). Walks through DICOM familiarization, pylinac analysis, and pass/fail against TG‑142. Contains four TODO cells. |
Analyze_Fields.m |
Original MATLAB analysis (hand‑written Low et al. formalism with imfindcircles + pinv). |
WL_plotter.m |
MATLAB helper to overlay the radiation field and BB on an image. |
Coding_Workspace.m |
MATLAB entry point / scratchpad. |
Lab_Data_Final |
A folder of 14 .dcm portal images (one per WL field in Table 1 of the handout). |
The 14 portal images correspond to the gantry/collimator/couch combinations in Table 1 of the handout:
| Fields | Gantry | Collimator | Couch |
|---|---|---|---|
| 1–3 | 270° | 90 / 0 / 270 | 0 |
| 4–6 | 0° | 90 / 0 / 270 | 0 |
| 7–9 | 90° | 90 / 0 / 270 | 0 |
| 10–12 | 180° | 90 / 0 / 270 | 0 |
| 13–14 | 0° | 0 | 90 / 270 |
- Download
Lab8_WinstonLutz.ipynband the 14.dcmfiles fromLab_Data_Final/(unzipLab_Data_Final.ziplocally first). - Open Google Colab → Upload notebook → select
Lab8_WinstonLutz.ipynb. - Run the cells top‑to‑bottom. The upload cell will prompt you to pick the 14
.dcmfiles; drag‑select them all in the dialog. - Fill in the four
TODOcells as you go:- TODO #1 — the BB diameter in mm.
- TODO #2 — the
Δu/Δv/ total per image. - TODO #3 — the magnitude of the 3D shift vector.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
jupyter lab Lab8_WinstonLutz.ipynb[images, shift_3D] = Analyze_Fields('Lab_Data_Final');
WL_plotter(images(1)) % overlay field CAX + BB on field #1Running either the MATLAB code or the Python notebook on the provided data yields (within segmentation precision):
Per‑image 2D shifts (Δu, Δv, total — 14 rows, one per field).
3D shift vector from the radiation isocenter to the BB center:
For each image, locate the radiation field centroid and the BB centroid on the EPID, convert pixel coordinates to mm at the isocenter plane (multiply by ImagePlanePixelSpacing / (RTImageSID/RadiationMachineSAD)), and record the in‑plane shift (Δu, Δv).
Stack the 14 in‑plane shifts with the first two rows of each field's R_gantry · R_couch rotation matrix and solve, by least‑squares (Moore–Penrose pseudoinverse), for the single 3D offset between the radiation isocenter and the BB. This is the formalism from Low et al. (1995) and is what both the MATLAB script and pylinac implement.
- Lutz, W., Winston, K. R., & Maleki, N. (1988). A system for stereotactic radiosurgery with a linear accelerator.
- Low, D. A., Li, Z., & Drzymala, R. E. (1995). Minimization of target positioning error in accelerator-based radiosurgery. Med. Phys. 22(4): 443–448.
- AAPM TG‑142. Quality assurance of medical accelerators.
- AAPM TG‑198. An Implementation Guide for TG‑142 Quality Assurance of Medical Accelerators.
- AAPM MPPG Report 9.a. Guidelines for SRS‑SBRT.
- Pylinac documentation: https://pylinac.readthedocs.io/en/latest/winston_lutz.html
Lab materials © the UW‑Madison MP‑566 course staff. Code and notebook provided for educational use. Pylinac is licensed under the MIT license.