Nonlinear Semi-supervised and Unsupervised Metric Learning with Applications in Neuroimaging