Gait Analysis Using the Physics Toolbox App

Sensors in new smartphones can be an excellent tool to measure different physical quantities and these can be useful to develop real experiments with application in human health. Therefore, in this research work, the design and construction of a gait analyser was carried out using the toolbox physics app for data acquisition and MATLAB was used for its analysis. This system analyses the behaviour of walking in people and its purpose is to diagnose any health problem caused by the human being’s way of walking. For this, the g-force meter was used in <inline-formula> <tex-math notation="LaTeX">$x$ </tex-math></inline-formula>, <inline-formula> <tex-math notation="LaTeX">$y$ </tex-math></inline-formula>, and <inline-formula> <tex-math notation="LaTeX">$z$ </tex-math></inline-formula> components. This application uses inputs from the device’s sensors to save and export the data in comma-separated values (CSV) format through a.csv extension. The results are very interesting because they can be used in medical diagnoses such as reduced gait speed and loss of regularity, symmetry, or synchronization of body movements. Since many organs are involved in gait, there are several types of gait disturbances that cause gait to be abnormal. With this system, it is possible to identify the hemiplegic gait, festinating gait, paraparhetic gait, waddling gait, among others. This analysis was carried out using the Pearson, Spearman, and Kendall correlation coefficients, which indicate the possible diagnoses in the patients.


I. INTRODUCTION
The continuous increase in technology dedicated to increasing life expectancy has gained attention in the two last decades. Therefore, new diagnostic and monitoring systems are needed, but with the characteristics of being non-invasive, low-cost, reliable and accurate to provide affordable health care services to humans. The most recent advances in the different areas of engineering have provided increasingly smaller sensors in order to propose smart, fast and costeffective solutions for various health-related problems. A system that can be useful for this kind is a device that allows analyzing the way of walking to monitor and predict the health status of people. Since an individual's gait patterns are linked to their health conditions, that is, people with diseases tend to walk differently and their walking patterns differ from The associate editor coordinating the review of this manuscript and approving it for publication was Cihun-Siyong (Alex) Gong . those of healthy people. Until now, walking patterns were analyzed for the purpose of predicting falls. For example in ref. [1], they made the proposal to continuously monitor the walking patterns of the elderly to identify the quality of their joints or diseases related to them in order to predict falls. However, there are few studies on the analysis of the general walking patterns of people that may be related to joint instability and musculoskeletal disorders. In ref. [2], [8], the authors relate the walking patterns to the ages of the individuals, this is due to the fact that the shape of the human body and the muscular strengths change according to age. Thus, a group of people with similar ages have similar gait patterns [3]. Therefore, a person can be classified by their way of walking, that is, there is a correlation of the way they walk with age. For example, for older adults the way of walking indicates the existence of some health problems such as limb imbalance, weak joints or asymmetric acceleration of the limbs [4]. So, analyzing the patterns in an individual's gait could be a good indicator to visualize the state of health that they present. In the ref. [5], [6], it is precisely indicated the need to develop new alternatives for the analysis of walking using low-cost resources, in such a way to build systems with the integration of high-performance devices to provide these services. In ref. [7], the authors also analized the caw's walking using accelerometers and gyroscopes installed on ear tags and collar-tags. However, the physics toolbox application to acquire the signals through cell phone's sensors has been used in different situations like in refs. [10], [11]. In general, the biometric gait recognition can be categorized into three approaches: machine vision based, floor sensor based and wearable sensor based [12]- [29]. In this research work, we used the wearable sensor based method. In our work, the design and construction of a gait analysis using the physics toolbox application to acquire the signals through cell phone sensors and then store them in a .csv file is carried out. The aim of this article is to use the movil phone to evaluate the gait and to predict problems in the future. We use smartphones every day and one can see that they can be used to analyze the gait in humans. The advantage of our system is that it has no data storage limit, since the cell phone is being used and even more so, data can be saved in the cloud. Also, the sensors used by cell phones are very well calibrated and therefore the error rate is minimal. One of the important objectives in the development of embedded systems is precisely to reduce the high costs and their high integration, this system fully fulfills it. The physics toolbox application is widely used and highly reliable, therefore the system here developed.

II. MATERIALS AND METHODS
The design of this embedded system consists, primarily, of the physics toolbox application. The coordinate system in this application is: the total vector represents the relative total gravitational force aligned with the plane of the device screen. Vector components are displayed in red along the x-axis and in green along the y-axis and in blue along the z-axis. While the device screen is vertical with respect to the ground and if it is not accelerated, the vector will read a value of unit down. The system is set as shown in Figure 1.
The graphical user interface of the physics toolboox application is shown in Figure 2. Here the Fg is measured as a function of time. As well as the components in x, y and z. The + symbol is to start saving data to a.cvs file. This application is useful for education, academia and industry, since it contains practically everything that can be measured and generated with a smartphone. This application uses inputs from the device's sensors to record and export data in Comma Separated Value (CSV) format via a .csv file. The data can be recorded in elapsed time on a graph or displayed digitally. Users can export the data for further analysis in a spreadsheet. The g-force meter measures the relationship between normal force and gravitational force (Fn/Fg) in three dimensions. The g-force changes when the mobile device: accelerates, decelerates or changes direction. When the mobile device is not accelerating and is face up relative to the earth's surface, it reads g-force values of 0, 0, 1. This means that a normal force is only experienced in the upward direction, and that it has the same force as the force of gravity. An object experiencing a vertical g-force of 2 feels a force twice as strong as gravity in the upward direction (which is interpreted as ''feeling twice as heavy''). An object that experiences a g-force of 0 is in free fall (which is interpreted as ''feeling weightless''). The g-force data is extracted directly from the accelerometer. Accelerometers often come like sensors that contain at least two components: piezoresistive and capacitive cantilevers. As the mobile device accelerates, the cantilever bends, changing the resistance of the silicon, which is interpreted as acceleration. Alternatively, a capacitive accelerometer contains three comb-shaped inertial masses attached to springs, with one in each dimension. When the mobile device is not accelerating and is lying down, a total g-force of 1 is measured due to the gravitational force pulling downward (and the resulting upward reaction force of equal force). The linear accelerometer measures acceleration in a straight line in three different dimensions. Linear acceleration changes when the mobile device accelerates, decelerates, or changes direction. When the mobile device is at rest relative to the earth's surface, it reads acceleration values of 0, 0, 0. Linear acceleration differs from general acceleration. This is because engineers often interpret the displacement of inertial mass in the z direction as the relativistic acceleration of an object on the surface of a rotating earth. This is accurate when considering the entire Earth as a frame of reference, but not accurate when considering a local frame of reference. Linear acceleration is derived from the gforce meter, but it also uses the gyroscope and magnetometer to cancel out the effects of the earth's gravitational field on the sensor. All these sensors are integrated in your cell phone and here they were used to make this gait analyzer system.

III. RESULTS
For the acquisition of signals, a 30-year-old healthy person was taken as a model. Here the mobile device was placed VOLUME 10, 2022 on the left foot, although it can be placed on the right foot, however it is best to place it on the left foot, which provides more information. Figure 3a shows the g-Force data in the x direction. Figure 3b shows the g-Force data in the y direction, and Figure 3c shows the measured g-Force data in the z direction. The data of the total g-force is shown in Figure 4. The sample only takes 10 steps for its analysis, however the data we have is up to 1000 steps, but for simplicity in the analysis we will only take this sample. As can be seen, the total g-force has positive values and even more they start at 1, which is correct because if the device were at rest it would give us a constant line with a value of 1. To compare our results, we used a comercial device called runscribe [30] and it can be seen in Figure 5. Also, in this case the patient background: he is 30 years old male, no history of mayor injuries and healthy with minor knee and hip complaints. In the results, there are three primary pivots in gait: the heel pivot, the ankle pivot, and the forefoot pivot. Their approach allows you to segment the foot for a more detailed analysis of these three primary pivots of gait. The gait gurve shows total vertical ground reaction force from heel strike to toeoff. The Force vs. Time graphs for the forefoot and heel provide for specific loading patterns during heel contact and forefoot contact, independent of and in conjunction with the gait curve. Their gait curves and ours are pretty similars, it can be seen in Figure 5a, where x, y and z directions have the same forms.
To analysis of the data, there are some methods, for example in refs. [31]- [37]. In refs. [38]- [42], there is an nalysis of the performance of differents algorithms from a systematic review. They presented the influence of sensor position, analysed variable and computational approach in gait timing estimation from IMU measurements. In ref. [43], the authors investigated the validity and reliability of a smartphone-based application to measure postural stability. In this research work, we used the stadisctics and we calculated the coefficient for Pearson's correlation, the coefficients for Kendall's correlation and coefficients for spearman's correlation. These results are for a patient who is healthy in his gait. This dependence of variables is even more noticeable when the dispersion matrix is calculated, which is shown in Figure 6. The dispersion matrix graphically shows us the relationship that exists between the analyzed variables.
Pearson's correlation coefficient is a measure of linear dependence between two quantitative random variables and it is defined as equation (1).
where cov(X,Y) is the covariance and σ X is the standard deviation of X σ Y is the standard deviation of Y . As we know, unlike covariance, Pearson's correlation is independent of the measurement scale of the variables. In a less formal way, we can define Pearson's correlation coefficient as an index that can be used to measure the degree of relationship of two variables as long as they are both quantitative and continuous. Table 1 shows the Pearson's correlation coefficients. For the value of 1, it indicates that there is a perfect correlation and for the value 0, it indicates that there is no linear relationship, but this does not necessarily imply that the variables are independent. If the value goes 0 < r < 1 then there is a positive correlation and if −1 < r < 0, there is a negative correlation. In our case, where there is the greatest correlation is between the variable gFy and TgF.
On the other hand, a statistical analysis was also carried out and the coefficient for Spearman's correlation was found, which is a measure of the correlation between two random variables. To calculate the coefficients of Spearman's correlation, the data are ordered and replaced by their respective order. As shown in equation 2.
where D is the difference between the corresponding statistics of order of X -Y. N is the number of data pairs. The coefficients for Spearman's c correlation is shown in Table 2 . Spearman's correlation coefficient is less sensitive than Pearson's for values that are far from expected. The interpretation of Spearman's coefficient is the same as that of Pearson's correlation coefficient. It oscillates between −1 and +1, indicating negative or positive associations respectively, 0 zero, means no correlation but no independence. In our case, the greatest correlation is between the variable gFy and TgF, and this coincides with Pearson's correlation coefficient. For both cases, they are close to the value of 0.77.  This indicates that indeed the greatest correlation is between these two variables.   Similarly, another statistical analysis was performed, and Kendall's rank correlation coefficient was found, commonly known as Kendall's τ coefficient, this measures the ordinal association between two measured quantities. A τ test is a nonparametric hypothesis test for statistical dependence based on the coefficient τ . It is a measure of rank correlation: the similarity in the ordering of the data when they are classified into ranks for each of the quantities.   The denominator is the total number of pair combinations, so the coefficient must be in the range −1 ≤ τ ≤ 1. If the agreement between the two classifications is perfect (that is, they are equal), the coefficient has the value 1. If the disagreement between the two classifications is perfect (that is, one classification is the inverse of the other), the coefficient has a value −1. If X and Y are independent, then we would expect the coefficient to be approximately zero. The coefficients for Kendall's correlation is showed in Table 3 . In our case, it was simulating the results obtained in the Pearson and Kendall correlation coefficients. Well, where there is the greatest correlation is between the variable gFy and TgF.
From the results obtained, we observed that the coefficient of correlations found is high between gFy and TgF, since it has a similar range. These results are for a patient who is healthy in his gait. This dependence of variables is even more noticeable when the dispersion matrix is calculated, which is shown in Figure 6. The dispersion matrix graphically shows us the relationship that exists between the analyzed variables. In this case, there is a strong correlation between the variable gFy and TgF. For the analysis of the walk of the users, about 100 people of different ages have been taken. Results for 100 people with different age range are presented in Table 4 .

IV. DISCUSSIONS
The gait is a complex motor function that requires the interrelation of the mechanisms of locomotion, balance, motor control and an adequate muscular-skeletal function. Gait disturbances are frequent and sometimes with functional and important consequences for patients, which is why an adequate assessment is essential. Within the classic sections of the evaluation of gait or locomotion we find the dependent or independent ability to walk, the use or the predominant pattern that the patient presents, the identification of the main deficits, the attitude of the trunk during walking and limbs during the cycle, as well as the need to use support products. Finally, the description of the type or pattern of gait can help in the diagnosis of the problems that patients present during locomotion. In this line, the most common gait patterns in the patient with neurological pathology would be the following: Reaper gait is a gait disorder characterized by the flexion posture of the upper limb and extension of the lower limb, so when giving one step, the leg describes a circumduction movement with activation of the quadratus lumbar, this type of gait pattern is observed in patients with cerebrovascular accidents. Festive gait is typical in advanced parkinsonian syndromes, the trunk is in flexion with an internalization of the center of gravity with bent hips and knees and the arms in semi-flexion at the elbow, the steps are very short and also fast as if they were chasing the center of gravity of the patients, it is common the presence of frostbite when passing through doors or when making turns. Toe gait Children with idiopathic toe gait do so bilaterally but are able to perform a plantar gait when expressly requested, when the child is walking only leans on the toes, but upon physical examination It can be found that mobility in the ankle, dorsal flexion is decreased, which is a consequence of a shortening in the Achilles tendon, the neurological examination of the child with toe walking is normal without evidence or muscle weakness, it is usually associated with to a syndrome of minimal brain dysfunction. Scissor gait or paraparetic is a gait disorder characterized by the crossing of the lower extremities in each of the steps as a result of increased tone or hypertonia in the leg muscles, it is observed in spastic paraparesis observed in children with cerebral palsy, ataxic gait also called hesitant or wobbly due to cerebellar involvement and is characterized by the presence of hypotonia, incoordination, alterations in balance, increased base of support, short steps, should not be confused with a tabetic or talone gait due to a proprioceptive affectation, which presents very loud steps since the patient does not know how their lower limbs are located and should not be confused with the compass or star gait that is typical of a vestibular affectation, which presents long steps. Duck or mallard gait characterized by exaggerated lateral displacement of the trunk and the elevation of the hips when walking, is a typical gait with people with muscular dystrophy, these patients present hyperlordosis, falls, difficulty running, jumping or getting up. Steppage gait is the characteristic gait in those patients who have difficulty dorsiflexing the ankle, the foot is therefore dropped, so in order not to drag it in the gait cycle, the patient raises the hip and knee exaggeratedly and when supporting the foot it does so first by touching with the tip of the foot, it is produced by an affectation of the muscular group innervated by the external popliteal sciatic nerve, therefore the tibialis anterior. Trendelenburg gait is the typical gait that appears when the hip abductors are altered, in which the patient's pelvis tends to fall to the opposite side during the stance phase, the opposite hip falls down to avoid falling, the patient moves his center gravity to the opposite side, moving the trunk and head in that direction, the result is a gait with a lateral jerk towards the affected side, if the patient has a dysfunction both hip abductors, therefore bilaterally the lateral shaking of the trunk will be to both sides, which has often been called the duck gait, which is the typical one that patients with muscular dystrophy usually present. Choreoathetosic gait is characterized by rapid, irregular, abrupt movements, movements worsen with gait, associated with abrupt movements of anterior and lateral propulsion of the pelvis that can simulate dance steps, however it is not usual for falls to occur, no matter how aberrant they may be look like this gait pattern.
On the other hand, measurements were made for people with diagnoses of abnormalities in their walks. For patients with festive or parkinsonian gait, a Pearson correlation coefficient of 0.56783 was obtained, which is correct, since the classic appearance is of ''shuffling'' and is caused by a decrease in both the length and the height of the foot. For patients with a gait of the reaper, the Pearson correlation coefficient was 0.45567, however there we do notice that there is a change in the g-force in the z direction, since the movement is like a scythe and of course there is a change in the z direction. On the other hand, patients diagnosed with duck gait were also characterized, which is characterized by a rocking gait due to disorders in the pelvic area. For this case, the Pearson correlation coefficient was obtained with a value of 0.49923, which makes sense, since the steps are short.

V. CONCLUSION
The design and construction of a single gait analyzer using the physics toolboox application for data acquisition was successfully carried out in this research work. MATLAB was used for data analysis. The objective of this system was to analyze the walking behavior of people and thus be able to diagnose any health problem caused by the human's way of walking, as well as to help diagnose any anomaly in the way of walking. For this, the cell phone was placed on the patient's left foot and the physics toolbox application was activated with the g-Force meter, a ratio of Fn/Fg in the x, y, and z directions. Once the data file was obtained, it was preceded by MATLAB. The results are very interesting, because they can be used in medical diagnoses such as reduced gait speed and loss of regularity, symmetry, or synchrony of body movements and therefore with this system gait can be identified of the reaper, festive march, scissor or paraparhetic march, duck or mallard march, among others. This analysis was carried out using the Pearson, Spearman and Kendall correlation coefficients, which indicate the possible diagnoses in the patients.