Question 14 of 20 Intermediate Practical
How would you design data augmentation for microscopy images without creating impossible samples?
Short answer
Use only transformations that leave the label unchanged in real biology and imaging, such as flips and 90-degree rotations for cells with no orientation, mild intensity changes within instrument range, and crops that keep the object. Apply the same geometry to masks, and never augment validation or test data.
Why
Augmentation teaches a model which changes should not matter. If a change can alter the true label, it teaches the wrong lesson. A cell under a microscope has no up or down, so flips and right-angle rotations are safe.
Color jitter is risky for stains where hue carries the label, and aggressive crops can cut out the mitotic figure that defines the class. torchvision's transforms.v2 module supports images together with bounding boxes, segmentation masks and keypoints, so geometric transforms are applied consistently to the image and its annotations.
How to work it through
- List the factors that genuinely vary in your images, such as orientation, focus, illumination and stain intensity.
- For each, decide whether changing it could change the label, and keep only those that cannot.
- Set ranges from real data, for example intensity scaling within the variation seen across plates.
- Build the pipeline with transforms.v2 so masks and boxes follow the image.
- Inspect a grid of augmented samples with a domain expert before training.
- Compare validation performance with and without each augmentation family rather than adding all of them at once.
An example
A classifier separates mitotic from interphase nuclei in 2,400 crops. The first pipeline adds hue jitter and random crops at 50 percent of the image, and validation accuracy drops from 88 to 83 percent. Review shows crops often cut off condensed chromosomes and hue shifts mimic another stain.
The revised pipeline uses flips, 90-degree rotations, brightness scaling of plus or minus 15 percent matching plate-to-plate variation, and crops keeping at least 85 percent of the nucleus. Validation accuracy rises to 91 percent.
Where the answer stops holding
Augmentation cannot create variation that is absent, such as a new microscope or a new cell line, so it does not replace external validation. Safe ranges are judgments that need expert review. Some properties, such as cell size in absolute units, are meaningful, so scaling can change biology.
Test-time augmentation is a separate technique and must be reported as such.
A strong answer covers
- Only label-preserving transformations
- Ranges set from real acquisition variation
- Masks and boxes transformed with the image
- Expert review of augmented samples
- Ablate augmentation families, none on validation data
Common mistakes
- Copying natural-image augmentation recipes such as strong color jitter to stained tissue
- Applying random augmentation to the validation set
- Rotating images but not their segmentation masks
The interviewer might ask next
Which augmentations would be unsafe for a model that measures cell size?