Week of 2026-06-15
pix2pix QC
Overview
Following the constrained rerun and identification of slice pairing issues, Mary stepped back to perform systematic QC on the slice creation pipeline before continuing model iterations. This led to both a new QC workflow and a methodological improvement to the training objective.
Slice Creation Pipeline
Goal: Generate paired 2D slices from registered 3T → 7T MRI volumes for supervised image translation, with each 3T slice anatomically matched to its 7T target.
Preprocessing steps
- Skull strip 3T and 7T volumes
- Apply N4 bias-field correction
- Register 3T → 7T using affine alignment
- Confirm matching image dimensions and orientation
- Normalize intensities using robust percentile scaling (p1-p99 scaled to -1 to 1)
- Generate brain/intersection masks for masking and QC
Slice extraction
- Extract matched 2D slices along the same anatomical axis
- Remove slices with low brain content (<10% nonzero area)
- Center crop or zero-pad to fixed size (512×512)
- Save side-by-side pix2pix pairs: 3T | 7T
- Save corresponding single-width intersection mask for masked loss
Key challenges
- Spatial alignment - small registration errors can cause the model to learn blurred anatomy or incorrect mappings; consistent slice correspondence required across subjects
- Intensity differences - 3T and 7T have different contrast, dynamic range, and bias fields; normalization required for stable training
- 7T-specific artifacts - temporal lobe signal dropout, bright vascular signal near gray/white matter boundaries, variable tissue contrast across subjects
- Skull stripping mismatch - 3T and 7T masks may not perfectly overlap; poor masks introduce incorrect loss penalties during training
QC Workflow
Goal: Quantitatively assess 3T-7T slice pairing quality prior to model training. Identify registration errors, slice mismatches, and unreliable training examples.
Metrics
| 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 |
Flagging criteria: low NCC, low MI, poor edge correlation, or a nearest-neighbor best match offset ≥ 2 slices (mi_delta ≥ 0.02).
Example: Flagged slice
Sub-026, test slice 174. MI 0.254 | NCC 0.377 | edge 0.003 | Dice 0.966 | best offset 2 (mi_delta ≥ 0.02). Despite reasonable Dice (skull-strip overlap), low NCC and edge correlation with a 2-slice nearest-neighbor offset indicate misalignment - a candidate for exclusion.

Masked Training (Intersection Mask)
The QC work prompted a related methodological change: training now uses an intersection mask between paired 3T/7T images. The L1 loss is calculated only within the shared brain region.
Rationale: Penalizing the model for differences outside the shared brain mask conflates synthesis error with skull-stripping and registration artifacts. Restricting loss to the intersection region gives a cleaner training signal.
Visual comparison
No mask - full image used for L1 loss; skull-strip differences contribute to loss

Intersection mask - L1 loss restricted to shared brain region only

Implementation changes
- Slice creation script updated to compute and save intersection masks
- pix2pix training loop updated to apply masked L1 loss during training
Current Status
Two parallel runs in progress:
- Masked model - full dataset with intersection mask applied during training
- QC-filtered dataset - unmasked model trained on slices passing QC thresholds
Results from both runs will be compared to isolate the contribution of each intervention (cleaner training signal vs. cleaner input data).