Structure-Aware Representation Learning And Its Application To Medical Imaging