An automated method of estimating the spatial distribution of piglets within a pen was used to assess huddling behaviour under normal conditions and during a febrile response to vaccination. The automated method was compared with a manual assessment of clustering activity. Huddling behaviour was partly related to environmental conditions and clock time such that more huddling occurred during the night and at lower ambient air temperatures. There were no positive relationships between maximum pig temperatures and environmental conditions, suggesting that the narrow range of air temperatures in this study was not a significant factor for pig temperature. Spatial distribution affected radiated pig temperature measurements by IR thermography. Higher temperatures were recorded in groups of animals displaying huddling behaviour. Huddling behaviour was affected by febrile responses to vaccination with increased huddling occurring 3 to 8 h post-vaccination. The automated method of assessing spatial distribution from an IR image successfully identified periods of huddling associated with a febrile response, and to changing environmental temperatures. Infrared imaging could be used to quantify temperature and behaviour from the same images.