Deep representation learning for complex medical images