Abstract
We describe AFA, an open-source Python package for automating the most common and important step in the preparation of facial stimuli for psychology and neuroscience experiments – spatial alignment of faces. Researchers typically align their face stimuli manually, use closed source commercial software, or develop in-house software that’s not been validated. AFA is the only open-source face alignment solution whose end-to-end process has been empirically verified on face databases used by psychologists. AFA is based on facial landmark detection that is powered by the reliable and open-source DLIB library. Critical alignment code based on Generalized Procrustes Analysis (GPA) ensures maximal spatial overlap in facial features across all facial features and has been extensively unit-tested. For most researchers who need only a set of aligned facial stimuli, AFA provides a valid, easy-to-use solution that is easily replicated in future research. Alignment is also the first step to creating many other types of stimuli that are common in psychology and neuroscience. We include functions and example scripts for automatically generating image apertures that conceal areas outside the inner face; for image morphing between facial identities; and for shape-based averaging of facial identity.
