Automatically segmenting subcortical structures in brain images has the potential to greatly accelerate drug trials and population studies of disease. Here we propose an automatic subcortical segmentation algorithm using the auto context model. Unlike many segmentation algorithms that separately compute a shape prior and an image appearance model, we develop a framework based on machine learning to learn a unified appearance and context model. We trained our algorithm to segment the hippocampus and tested it on 83 brain MRIs (of 35 Alzheimer's disease patients, 22 with mild cognitive impairment, and 26 normal healthy controls). Using standard distance and overlap metrics, the auto context model method significantly outperformed simpler learning-based algorithms (using AdaBoost alone) and the FreeSurfer system. In tests on a public domain dataset designed to validate segmentation  , our new algorithm also greatly improved upon a recently-proposed hybrid discriminative/generative approach , which was among the top three that performed comparably in a recent head-to-head competition.