The averaged magnetization inversion recovery acquisitions (AMIRA) spinal cord imaging sequence acquires images of different inversion contrasts. Despite the different contrasts the images can be combined to even enhance tissue contrast. We give a principled justification for such averaging. Using energy optimization, we describe how to automatically optimize the contrast-to-noise ratio between different tissues using a compressed sensing inspired approach. We show that the uniform weights in the recently proposed AMIRA sequence are close to the optimum but can nevertheless still be improved. As an example we optimize the contrast-to-noise ratio between different compartments in the spinal cord.