## 1 Introduction  
Assessing and tracking patients' pain levels over time is critical in determining the effectiveness of medical treatments [1, 2] and preventing the development of chronic pain [2]. The current standard methods of pain assessment, which rely on patient self-reporting or medical staff observations, are highly subjective and imprecise, making it difficult to accurately monitor pain levels in patients, especially those with communication impairments [1, 2, 3, 4]. Furthermore, medical staff observations of pain are highly subjective and require experienced observers [5], whose scarcity can hinder the continuity of pain assessment monitoring [6]. The need for accurate pain-level assessment has led to a growing demand for automated pain monitoring systems that can be used both in hospitals and at home for elderly and injured patients [5, 6]. Such a system would provide a more objective and reliable method of pain assessment, helping to ensure that patients receive appropriate pain management and avoid unnecessary suffering. Developing such systems is no easy task due to a variety of challenges, including variations in head poses, illumination [7], and occlusion [8]. Despite significant progress in recent years, many deep-learning-based pain assessment models rely on face detection algorithms as a critical data processing step, which may not work accurately for full left/right profile views. Our previous work, Facial Expressions-based Pain Assessment System (FEAPAS) [9], employs the Multi-Task Cascaded Neural Network (MTCNN) algorithm to detect a face from the input image and subsequently employs OpenCV library to segment the detected face into two parts, in order to extract the upper part of the face (eyes and eyebrows). These parts are then fed to two concurrent pre-trained CNNs to mimic the Prkachin and Solomon Pain Intensity (PSPI) measurement [10]. Therefore, it assigns a higher weight to the upper part of the face in the pain evaluation process. FEAPAS achieved an accuracy of 99.10% on 10-fold cross-validation, thus outperforming the state-of-the-art model on the UNBC-McMaster shoulder pain expression archive dataset [11]. It also scores 90.56% on unseen subject data with an average response time of 6.49 s. However, it is restricted to the limitations of the MTCNN algorithm which cannot detect and extract the upper part of the face from full left/right profile images (note that, as with other referenced pain-assessment material, the left/right facial profiles are removed from input images). Consequently, the absence of input frames hinders the application of the FEPAS model, rendering it ineffective for left/right profile facial images. To overcome these challenges and develop a more robust pain assessment model, we have turned to different approaches such as the Sparse Autoencoders for Facial Expressions-based Pain Assessment (SAFEPA). Unlike traditional models, in the SAFEPA, we utilize Sparse Autoencoders (SAE) to reconstruct the upper part of the face from input images, allowing us to effectively handle variations in head poses. By leveraging this approach, we achieve high recognition performance and surpass the accuracy of state-of-the-art models, even when faced with challenging full left/right profile views. Autoencoders (AE) have gained popularity as an unsupervised neural network that can reconstruct data while minimizing the error between input and output [12] with an encoder mapping the input to a hidden representation through a nonlinear function and a decoder reconstructing the input [13]. AE has been shown to perform well in facial reconstruction, resolving issues of partial occlusion [14]. In this paper, we present a novel and advanced model, named Sparse Autoencoders for Facial Expressions-based Pain Assessment (SAFEPA), which builds upon our previous FEAPAS described in [9]. Our contribution lies in:  
* Developing a new system, such as SAFEPA, for pain assessment that accounts for variations in head poses by utilizing a custom SAE.