Have a personal or library account? Click to login
A Python Package for Automatic Face Alignment (AFA) in Experimental Psychology Cover

A Python Package for Automatic Face Alignment (AFA) in Experimental Psychology

By: Carl Gaspar and  Oliver Garrod  
Open Access
|Dec 2025

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.

DOI: https://doi.org/10.5334/jors.542 | Journal eISSN: 2049-9647
Language: English
Submitted on: Oct 17, 2024
Accepted on: Nov 13, 2025
Published on: Dec 12, 2025
Published by: Ubiquity Press
In partnership with: Paradigm Publishing Services
Publication frequency: 1 issue per year

© 2025 Carl Gaspar, Oliver Garrod, published by Ubiquity Press
This work is licensed under the Creative Commons Attribution 4.0 License.