Controlling the spin polarization of nanostructures on magnetic substrates.