Predicting chest shape after scoliosis surgery
Predicts what a scoliosis patient's rib cage will look like after spinal fusion surgery, from the CT scan taken before it: the patient is matched to earlier patients on six deformity indices, then the scan is reshaped onto the best match's post-operative scan with B-spline registration in Elastix. Team project; I built the registration and the main pipeline.
- When
- Sep 2021 to Apr 2022
- Where
- MSc Team Challenge in Medical Imaging 2021 to 2022, in a team of five
- Built with
- Python, Elastix, Image registration, MeVisLab, 3D Slicer
- Made as
- Team project
In pictures

About the project
The problem. Scoliosis is a sideways curve of the spine. The most common form, adolescent idiopathic scoliosis, appears during the growth spurt without a known cause, and as the spine curves it also twists the rib cage. In severe cases surgeons straighten the spine and fix it in place with rods and screws, which is called spinal fusion. The operation is planned on a CT scan of the chest, a 3D X-ray image, but there was no objective way to show in advance how the shape of the chest would change. Our team first spent the autumn on a literature study and a research proposal, then built a prototype that predicts the post-operative chest from the pre-operative scan.
The idea. We had CT scans of seven earlier patients, each scanned both before and after surgery. If a new patient's chest looks like one of theirs before surgery, it is likely to change in a similar way. So the tool finds the most similar earlier patients, borrows the shape of their chest after surgery, and fits the new patient's scan to it.
Step 1: measure the deformity. A physician marks eight landmarks, fixed anatomical points such as the front of the vertebra, the back of the breastbone and the outermost point of each side of the rib cage, on the slice where the curve is worst (the apex). We did this in MeVisLab, a medical imaging tool. From those points the program computes six deformity indices published by Farrell et al. Each one is a simple ratio or angle that puts a number on how deformed the chest is, for example:
- Hemithoracic width ratio: the width of one half of the chest divided by the other; 1 means symmetric.
- Rib-hump index: how far the ribs on one side bulge backwards; lower is better.
- Vertebral and thoracic rotation: how far the spine and the chest are twisted.
- Endothoracic hump ratio and spinal penetration index: how far the spine pushes into the chest cavity.
Step 2: find the closest earlier patients. The program divides each of the new patient's six indices by the same index of every earlier patient. For a perfect match every ratio would be 1, so the cost of a candidate is how far its ratios are from 1, added up. The three candidates with the lowest cost are the best matches.
Step 3: image registration. The new patient's pre-operative scan is reshaped in 3D until it lines up with the best match's post-operative scan. This is image registration, done with the Elastix toolkit in two stages:
- Rigid: shift and rotate the whole scan so the two bodies sit in the same place.
- B-spline: lay a grid of control points over the volume and move each one separately, so the scan can bend locally into the shape of the operated chest.
The computer judges the fit with mutual information, a score that rises as the intensities of the two scans line up, and an optimiser (adaptive stochastic gradient descent) adjusts the transform step by step to raise it, first on a blurred, coarse version of the scans and then at full detail. The result is the new patient's own anatomy, bent into the shape of a chest after surgery: the prediction. We visualised it in 3D with 3D Slicer.
Step 4: measure the prediction. The eight landmarks are placed again on the predicted scan and the six indices recalculated, so the surgeon gets numbers as well as a picture: before, and predicted after.
The result. As a proof of concept we ran the pipeline on one of the seven patients, using the other six as the reference set. Registered onto the best match, the predicted chest was more symmetric and had a smaller rib hump at the apex: the hemithoracic width ratio went from 0.54 to 0.65 (closer to 1) and the rib-hump index from 0.50 to 0.29. That is the direction surgery aims for. With seven patients this shows the pipeline works from start to end; it cannot yet say how accurate the predictions are.
Limitations and next steps. A B-spline can bend bone as easily as soft tissue, so the prediction takes on much of the matched patient's shape. Next steps would be to keep the bones rigid during the deformation, to use the landmarks in the registration as well as the image, to find the landmarks automatically from a segmentation instead of by hand, and to grow the set of earlier patients.
My part. I set up and owned the team's code repository and wrote most of the code in it (34 of its 89 commits). I built the registration: the Elastix setup with the rigid and B-spline stages, their parameter files, and running it for the three best matches. I also wrote the main pipeline that runs matching, registration and the measurement of the prediction in order, and fixed the matching step so the whole chain ran from start to end. I also tried moving the landmarks through the registration transform instead of placing them again by hand, found that it did not work reliably across patients, and so the final pipeline places them again in MeVisLab.




