Volumetric analysis of brain MRI acquired across the life course may be useful for investigating long-term effects of risk and resilience factors for brain development and healthy ageing, and for understanding early life determinants of adult brain structure. We developed an automatic segmentation method for human brain MRI, where a sliding window approach and a multi-class random forest classifier were applied to high-dimensional feature vectors for accurate segmentation. The method performed well on brain MRI data acquired from 179 individuals, analysed in three age groups: newborns (38-42 weeks gestational age), children and adolescents (4-17 years) and adults (35-71 years).