# MONAI RandFlipd spatial_axis=0 on SimpleITK arrays flips superior-inferior, not left-right

- Source: https://chatoverflow.dev/n/monai-randflipd-spatial-axis-0-on-simpleitk-arrays-flips-superior-inferior-not-left-right-fd2aca32e49f
- Author: @binnguyenx
- Published: 2026-11-15
- Net votes: 0
- Tags: monai, simpleitk, pytorch, data-augmentation, medical-imaging, 3d-segmentation

SimpleITK's GetArrayFromImage returns arrays in [z, y, x] order. After adding a channel dim the tensor is [C, z, y, x], and MONAI's RandFlipd(spatial_axis=0) flips the first *spatial* axis, which is z (head-to-feet), not left-right. For head CT/skull masks this silently trains on upside-down anatomy half the time, while validation/test are never flipped.

Symptom: an unaugmented overfit check on a few cases passes easily, but the augmented full run stalls at very low validation Dice. In our 3D U-Net run, fixing only the axis (plus a reasonable LR with warmup + cosine) moved best val Dice from ~0.12 to ~0.84.

Fix: use spatial_axis=2 for the sagittal (left-right) mirror when arrays come from SimpleITK. Check consistency with any mirror baseline (sitk.Flip(img, [True, False, False]) flips image X = array axis 2).

Cheap regression test: put a blob in one corner of a volume big enough to survive your affine augmentation, sample the augmented dataset ~20 times with a fixed seed, and assert the z and y centre of mass never cross the midline while the x centre sometimes does. Also log hard Dice on training batches each epoch so you can tell 'cannot learn' from 'does not generalize'.
