Week of 2026-06-15
pix2pix QC
syn7T
After the constrained rerun and the slice-pairing issues from last week, Mary stepped back to do systematic QC on the slice-creation pipeline before continuing with model iterations. That produced both a new QC workflow and a change to the training objective.
Slice creation pipeline
The pipeline generates paired 2D slices from registered 3T → 7T volumes for supervised image translation, with each 3T slice anatomically matched to its 7T target. Preprocessing runs skull stripping on the 3T and 7T volumes, N4 bias-field correction, affine registration of 3T → 7T, a dimension/orientation check, robust percentile intensity normalization (p1-p99 scaled to -1 to 1), and brain/intersection mask generation for masking and QC. Slice extraction then pulls matched 2D slices along the same anatomical axis, drops slices with low brain content (<10% nonzero area), center-crops or zero-pads to a fixed 512×512, and saves side-by-side pix2pix pairs (3T | 7T) plus the single-width intersection mask for masked loss.
The recurring challenges: small registration errors make the model learn blurred anatomy or wrong mappings, so consistent slice correspondence across subjects is essential; 3T and 7T differ in contrast, dynamic range, and bias field, so normalization is needed for stable training; 7T brings its own artifacts (temporal-lobe signal dropout, bright vascular signal near GM/WM boundaries, variable tissue contrast across subjects); and imperfect overlap between 3T and 7T skull-strip masks introduces incorrect loss penalties.
QC workflow
The goal here is to quantitatively assess 3T-7T slice-pairing quality before training, and to catch registration errors, slice mismatches, and unreliable examples.
| Category | Metric |
|---|---|
| Structural overlap | Dice coefficient |
| Intensity similarity | Normalized cross-correlation (NCC), Mutual information (MI) |
| Anatomical alignment | Edge correlation |
| Slice correspondence | Nearest-neighbor slice matching |
A slice gets flagged for low NCC, low MI, poor edge correlation, or a nearest-neighbor best match offset ≥ 2 slices (mi_delta ≥ 0.02). As an example, sub-026 test slice 174: MI 0.254, NCC 0.377, edge 0.003, Dice 0.966, best offset 2 (mi_delta ≥ 0.02). The reasonable Dice reflects skull-strip overlap, but the low NCC and edge correlation with a 2-slice offset indicate misalignment — a candidate for exclusion.

Masked training (intersection mask)
The QC work prompted a related change to the objective: training now uses an intersection mask between the paired 3T/7T images, with L1 loss computed only inside the shared brain region. Penalizing the model for differences outside that shared region conflates synthesis error with skull-stripping and registration artifacts, so restricting the loss to the intersection gives a cleaner signal.
No mask — full image used for L1 loss; skull-strip differences contribute to loss

Intersection mask — L1 loss restricted to the shared brain region only

The slice-creation script now computes and saves the intersection masks, and the pix2pix training loop applies the masked L1 loss.
Two runs are in progress: a masked model on the full dataset with the intersection mask applied during training, and a QC-filtered unmasked model trained only on slices that pass the QC thresholds. Comparing the two should isolate the contribution of each intervention — cleaner training signal vs. cleaner input data.
Next steps: