FACTA UNIVERSITATIS Series: Mechanical Engineering Vol. 18, N o 1, 2020, pp. 135 - 151 https://doi.org/10.22190/FUME190210004P © 2020 by University of Niš, Serbia | Creative Commons License: CC BY-NC-ND Original scientific paper  FAST USER ACTIVITY PHASE RECOGNITION FOR THE SAFETY OF TRANSFEMORAL PROSTHESIS CONTROL Aleksandr Poliakov, Vladimir Pakhaliuk Sevastopol State University, Sevastopol, Russian Federation Abstract. In the process of creating powered transfemoral prostheses, one of the most important tasks is the provision of the user safety while walking. Experience shows that security depends not only on the mechanical strength of such devices, but also on the quality of their control systems, which, among other things, must ensure that latency and error rates of recognition are acceptable for each of the possible changes in gait. Incorrect or late recognition of the activity mode at best can lead to suboptimal assistance from the auxiliary device, and at worst - to loss of stability of the user with a subsequent fall. Loss of stability can also occur due to exceeding the critical time or critical errors of the activity phase recognition and the associated incorrect commands generated by the control system. In this paper, a method for quickly recognizing the phase of the user's activity based on the properties of Hu’s moment invariants is substantiated. Its use in the intelligent control systems will minimize the critical errors that contribute to the loss of the user's equilibrium with the powered transfemoral prosthesis. Key Words: Powered Transfemoral Prosthesis, Safety, Activity Mode, Activity Phase, Recognition, Moment Invariant 1. INTRODUCTION Modern transfemoral prostheses (TFP) are sophisticated high-tech devices that enable people with disabilities to overcome the severe psychological consequences associated with amputation of the lower limb above the knee, to lead an active life and to be involved in a community of healthy people. Thanks to TFP, people with disabilities can carry out the usual motor actions typical for a healthy person, including: walking on flat and rough terrain, ascending / descending the stairs, sitting down / getting up from the chair, standing still, riding a bicycle, etc. This was made possible after the appearance on the market of available powered TFP, operating under the influence of commands generated by the intelligent control system (ICS). One of the key problems of ICS is in recognition of the user's intentions to carry out a specific activity mode and generate commands to TFP Received February 10, 2019 / Accepted November 25, 2019 Corresponding author: Vladimir Pakhaliuk Sevastopol State University, Universitetskaya Str. 33, 299053 Sevastopol, Russian Federation E-mail: pahaluk@sevsu.ru 136 A. POLIAKOV, V. PAKHALIUK actuators, facilitate the implementation of this regime. Currently, many algorithms are known to solve this problem, but none of them allows obtaining an absolutely exact solution. In this regard, work to improve the ICSs for powered TFPs and to improve the reliability and performance of algorithms used in them is still relevant. Reference [1] presents general considerations for the synthesis of ICS for powered TFP in the framework of the Intellectual-Synergetic Concept (ISC). As in most modern ICSs, the ISC-based control system provides three-tier architecture, including the high level controllers (HLC), middle level controllers (MLC) and low level controllers (LLC) [2]. The basic idea of ISC is that the ICS created on its basis consists of two subsystems: intellectual (IS = HLC + MLC) and synergetic (SS = MLC + LLC). At the same time, IS is responsible for recognizing the locomotor and non-locomotor intentions of the user in the short and medium term, and SS is for their bio-like implementation [1, 3]. In principle, as noted in the review [4], controllers of such ICS can perform their functions using different algorithms, each of which can be optimal from the point of view of different criteria and conditions. But an unconditional requirement for such algorithms is the provision of the user safety in the process of locomotion with TFP. Despite the fact that IS is not directly involved in the control of TFP actuators, it indirectly plays an important role in the controlling as well as developing a strategy and control tactics that are justified as a result of recognizing the intentions of the user to implement a certain movement in the near or medium term. Objective errors in the recognition of intentions and their classification depend on many factors and, in general, are random, and therefore inevitable when using any recognition algorithms. Moreover, the TFP user can change his initial intentions within a relatively short period of time, which leads to subjective errors. Therefore, the exact solution of the problem of recognizing intentions is impossible. To describe the time during which a classification decision must be made that provides an opportunity for the ICS of TFP to make the appropriate transition between the activity modes, the term "critical time" [5] was introduced, while to describe any errors that lead to subjective perception by the user state of unstable equilibrium, the term "critical error" was introduced [6]. These terms allowed the division of all possible errors with respect to the recognition and classification of intentions, into non-critical ones, i.e. such that the worst case scenario is the lack of assistance to the user on the part of the auxiliary device, and critical ones - in which the user can not only lose balance with a subsequent fall, but can even feel unsure when using an auxiliary device. Further studies in this direction have enabled Zhang et al. to conclude that not all errors lead to instability of equilibrium [7]. In addition, the authors found that such characteristics as the accuracy of activity mode recognition and error rate may not be sufficient for a real estimation of the recognition algorithm potential. In this regard, they proposed to evaluate the quality of recognition algorithms on the time duration and quality of identifying critical errors, which seems more reasonable from a functional point of view [7]. After comparing the identified critical errors with their effect on the functioning of the auxiliary devices, it was found that they depended more on the phases in which the error occurred and on the changes in the mechanical work value in the artificial joints associated with these errors. In this paper, a reliable method for fast and qualitative recognition of the phase of TFP user activity is grounded based on the features of Hu’s moment invariants [8]. Its use in the ICS of powered TFP, equipped with wearable IMUs and pressure sensors, will minimize the time of recognition of intentions and critical errors contributing to the loss of user balance during walking, thus increasing its safety. Fast User Activity Phase Recognition for the Safety of Transfemoral Prosthesis Control 137 In addition to providing security, the qualitative recognition of the activity phase in IS is important for the reliable determination of the boundary conditions of the problem of planning the bio-like movements of TFP elements in SS [1]. It is known that most ICS to achieve these goals use information about the detected activity in HLC mode and the current state of the device determined using sensors installed in the device or directly in the user [4]. But such an approach does not allow direct solving of the problem of planning synergetically optimal (bio-like) motions, even under condition of qualitative recognition of the activity mode because it does not provide information about the time remaining before the end of this activity mode [1]. Consequently, the use of the fast phase activity recognition algorithm in IS will allow increasing the quality of planning the movements of TFP elements not only for realization of typical periodic modes of activity but also in the process of volitional control of powered TFP. 2. MATERIALS AND METHODS The "ideal" powered TFP should help the user make many possible moves in different modes of activity. Such movements as normal walking can be typical for a person, and walking on railway sleepers, overcoming an unknown obstacle, etc. can be atypical. The ability to perform the full range of possible movements is not available to every healthy person and, especially, not to every disabled person. But, as is known, through systematic training, a healthy person can always acquire certain skills to perform the necessary movements [9]. Theoretically, this is available to every disabled person using TFP with advanced ICS. In ICS, the powered TFP should be perceived as one of the subsystems of an integral biomechanical system controlled by the central nervous system (CNS). Because CNS commands are not directly available for TFP actuators, the ICS must perform a number of CNS functions. One such function is to generate and send commands to the TFP actuators needed to implement the required motion. But the ICS must first recognize the intent of the disabled person, which in fact corresponds to the recognition of CNS signals transmitted to the musculoskeletal system. Namely, we can assume that the task of recognizing intentions is the key for IS as a part of ICS. There are many methods and algorithms for recognizing intentions, modes and activity phases that are used in control systems of various auxiliary devices and are described in detail in the review [4]. But the work on their improvement continues at the present time. We offer a fairly simple and very fast method for recognizing the phase of activity, based on the use of reference patterns of activity regimes presented in IS as matrices of Hu’s moment invariants. 2.1. Images of activity modes Each of the activity modes of the TFP user can be investigated experimentally and presented in the IS database as a set of informative parameters, which can be classified as: φH – hip joint angle; φK – knee joint angle; φA – ankle joint angle; yH – position of the hip joint relatively ground support; TH, TK, TA – torques in the hip, knee and ankle joints, respectively; VGRF – vertical ground reaction force; HGRF – horizontal ground reaction force etc. But at the moment the question of which of these parameters are independent remains open. At the same time, it can be argued that the relationships between the above and other parameters of the state are in most cases nonlinear. Therefore, the experimental 138 A. POLIAKOV, V. PAKHALIUK set of all possible parameters, measured at some phase in an arbitrary mode of activity, can be considered unique. In other words, informative parameters, which can be dependent on a certain mode of activity, can be considered independent of the set of possible modes of activity. Consequently, a certain point ω in the n-dimensional parametric activity space Ω can be represented by a set of coordinates pijk, k=1,…,n: ωij ={pij1, pij2, …,pijn}, where n is the number of received informative state parameters; i is the phase number corresponding to the activity mode with the number of j; p is a parameter identifier. In order to uniquely represent the point ω in n-dimensional space, in addition to the independence of n parameters, it is necessary that the space itself satisfies the completeness condition [10]. But in practice such a representation is impossible because up to the present time, a complete set of independent parameters that uniquely determine human activity is unknown. This indicates that a certain point ω can theoretically represent an infinite set of states (phases) corresponding to an infinite set of activity modes in space Ω. One approach that makes it possible to reduce the degree of uncertainty in the activity phase is to localize the space of interest Ω. In other words, if only one, for example, level normal walking is tested, instead of all possible modes of activity, then the probability that two or more phases will be represented by the same set of parameters will be extremely low. But an increase in the area under study, by including other modes of activity, will inevitably lead to an increase in the probability of the emergence of additional states corresponding to the same set of informative parameters if their number does not correspond to the condition of completeness of the activity space. Given the conditions noted above, suppose that the activity phase of the user's TFP is uniquely determined by a set of four informative parameters: φH, φK, φA, VGRF, which are assumed to be conditionally independent. Then an arbitrary point ω in a 4-dimensional parametric space is represented as follows: ωij={φijH, φijK, φijA, VGRFij}. The set of all admissible points ωij defines a bounded activity space, which is the union of subspaces of activity modes , which is a union of subspaces activity modes j, j=1,…,s, i.е.:  = 1  2  ...s. Having located informative parameters in the lexicographic sequence: φH  φK  φA  VGRF, and normalizing them so that max * max * max * max * ,,, ij ij ij ijA ijA ijH ijK ijK ijK ijH ijH ijH VGRF VGRF VGRF           , where  * ijH,  * ijK,  * ijA, VGRF * ij, are the real values of parameters, and max ijH  , max ijK  , max ijA  , max ij VGRF , are the modules of their maximum possible values, we can obtain the image of point ωij. Then the set of such images arranged in a given order so that 0 1 2 ... N, will represent the image of activity mode j. Finally, the combining the s images obtained in this way gives a complete image of the limited activity space  of a specific TFP user. The images of the activity phases, activity modes and space of potentially possible human activity can be obtained experimentally and are presented graphically for clarity. As an example, Fig. 1 shows charts of the change in the normalized informative parameters for the three typical activity modes: level normal walking (1), ascending the stairs (2) and descending the stairs (3), which we obtained as a result of processing information from IMU-sensors installed on the thigh, shin and foot and pressure sensors installed in the sole of the shoe of three adult healthy men aged 22, 23 and 24 years. Elementary analysis shows that these charts are in general similar to those that are currently available in many literary sources. Fast User Activity Phase Recognition for the Safety of Transfemoral Prosthesis Control 139 Level normal walking Ascending the stairs Descending the stairs a) b) c) d) Fig. 1 Parameters changing at different activity modes: a) Hip joint angle; b) Knee joint angle; c) Ankle joint angle; d) VGRF Figs. 2, 3 and 4 show graphical images of the activity modes formed for 20 phases in each of the above modes of activity: Ω1, Ω2 and Ω3, respectively. It is easy to see that the graphical image of each phase (ωij) is practically different from all others, which confirms its uniqueness in studied activity space  = 1  2  3. Therefore, the problem of recognizing the phase of the activity of the TFP user can be reduced to the problem of pattern recognition, choosing the proper method, which provides high recognition quality 140 A. POLIAKOV, V. PAKHALIUK in combination with high speed. From this point of view, the methods of pattern recognition, based on the use of Hu’s moment invariants [8, 10-13], are of interest. 0) 1) 2) 3) 4) 5) 6) 7) 8) 9) 10) 11) 12) 13) 14) 15) 16) 17) 18) 19) Fig. 2 Image of the level normal walking Fast User Activity Phase Recognition for the Safety of Transfemoral Prosthesis Control 141 0) 1) 2) 3) 4) 5) 6) 7) 8) 9) 10) 11) 12) 13) 14) 15) 16) 17) 18) 19) Fig. 3 Image of ascending the stairs 142 A. POLIAKOV, V. PAKHALIUK 0) 1) 2) 3) 4) 5) 6) 7) 8) 9) 10) 11) 12) 13) 14) 15) 16) 17) 18) 19) Fig. 4 Image of descending the stairs Fast User Activity Phase Recognition for the Safety of Transfemoral Prosthesis Control 143 2.2. Hu’s moment invariants Suppose that there is a reference activity space  and available for research, which represents all the potentially possible activity modes of the TFP user. But even in this case, it is possible to estimate the belonging of the real activity phase to a certain region of space  only approximately. This is due to the variability of the user's and environmental conditions, as well as the systematic and random errors of the real sensory systems. Namely, in real conditions, the image of the activity phase the TFP user, determined in accordance with the information coming from the sensors, each time will differ from the reference image. In the general case, the relationship between reference f(Ω) and observed g(Ω) image can be described, the so-called function of degradation, widely used in the field of image recognition [10]: ( )g D f , where D is some degradation operator. Because operator D is unknown or described by a parametric model with unknown parameters, the main problem solved in the recognition process is the comparison of unknown image f(Ω), observed by measuring image g(Ω), based on a priori information on degradation. Its solution can be obtained on the basis of the Hu's moment invariants [8], which are very effectively used to recognize images of objects specified as contours in the plane by K points Bi={𝑥Bi, 𝑦Bi} [11]. In the problem of recognizing the activity phase of the TFP user, invariant I can be considered as a functional defined in activity space Ω on the set of admissible images of phases Ωij that does not change its value under the action of degradation operator D, that is, it satisfies the condition ( ) [ ( )]I f I D f . (1) Taking into account the above discrepancies and limitations, in practice the condition (1) can be considered fulfilled if I(f) does not differ significantly from I[D(f)] and each of these invariants belongs to the same class. In order to successfully solve the recognition problem, it is necessary that the values of I for the phase images belonging to different classes differ significantly from each other. As a rule, such discrimination of classes with the help of a single invariant cannot be performed. To fulfill this condition, we must use the set of invariants Il, l=1,2,…, which can be obtained at the conditions of the problem under consideration. Thus, for example, for each image of phase ωij, the seven Hu's moments that are invariant to the full group of affine transformations can be calculated [8]: hrI  1 , 4 2 2 r M I  , 6 3 3 r M I  , 6 4 4 r M I  , 12 5 5 r M I  , 8 6 6 r M I  , 12 7 7 r M I  , (2) where h is a constant (in the given problem it can be chosen arbitrarily, for example, h = 1);    K i Bi x K x 1 1 and    K i Bi y K y 1 1 are the mean coordinates values of the image contour points; 1 1 ( ) ( ) i i K p q pq B B i x x y y K      are the central moments of order 𝑝 + 𝑞 ≤ 3; 0220  r ; MS, s = 1,…,7 are the moments invariant to the operations of rotation, transfer, and mirror mapping, determined by expressions: 144 A. POLIAKOV, V. PAKHALIUK 02201  M , 2 2 2 20 02 11 ( ) 4M      , 2 2 3 30 12 21 03 ( 3 ) (3 )M        , 2 2 4 30 12 21 03 ( ) ( )M        , 2 2 5 30 12 30 12 30 12 21 30 2 2 21 03 21 30 30 12 21 03 ( 3 )( )[( ) 3( ) ] (3 )( )[3( ) ( ) ], M                              2 2 6 20 02 30 12 21 30 11 30 12 21 30 ( )[( ) ( ) ] 4 ( )( )M                   , 2 2 7 21 03 30 12 30 12 21 03 2 2 30 12 21 03 30 12 21 03 (3 )( )[( ) 3( ) ] ( 3 )( )[3( ) ( ) ]. M                              As an example, Table 1 gives the matrix of Hu's moment invariants (2) calculated for level normal walking. Matrices characterizing other modes of activity can also be represented in a similar way. The combination of such matrices provides another way of representing the image of the limited space of the potential activity of the TFP user. This space can be obtained as a result of experimental studies of the motor activity of healthy people, therefore, in a certain sense it can be considered a reference one. But in the process of training the user to walk with TFP, the activity space can be modified to suit its individual characteristics. 3. RESULTS To ensure safety and obtain initial data for planning the optimal motions of the elements of the powered TFP, it is sufficient to relate with a high degree of reliability the current state of the user to a certain discrete image of phase ωij in the activity mode space Ωj, so that ωi-1j  ωij  ωi+1j, given the errors of the state evaluation with the help of a sensory system. Suppose that each of the sensors used to identify the informative parameters of the user state gives an approximate value of the parameter for the current state: maxmin cskcskcsk ppp  . In addition, taking into account the fact that the typical activity modes Ωj of different users are similar, we will assume that the rationing of informative parameters allows us to evaluate their values regardless of anthropometric data and the user's physical states. This allows us to calculate the vectors of the Hu's moment invariants for possible mean and boundary values of the parameters, i.e. for mid ijk p , m in ijk p , m ax ijk p , which are determined as a result of the experiments. The components of such vectors are generalized coordinates of the space of invariants J7 defining in it some point Hij = {Iijs, s = 1,...,7}. Points mid ij H , m in ij H , m ax ij H generated by parameters mid ijk p , m in ijk p and m ax ijk p respectively, characterize the same image of activity phase ωij and can be considered as homogeneous elements of space J7 forming cluster Clij  J7. The volume and location of Clij in J7 are implicitly determined by the boundary values of the informative parameters of phase image ωij. Therefore, we assume that all the points Hij generated by the values of informative parameters maxmin ijkijkijk ppp  belong to cluster Clij whose center is point mid ij H . Fast User Activity Phase Recognition for the Safety of Transfemoral Prosthesis Control 145 The space of invariants J7 is metrical, therefore in it the metric can be given 2 ( , ) ( ) a b S S d H H d I  , (3) where d(IS) is the difference of the coordinates with number s of points H b and H a . Table 1 Hu's moment invariants for 20 phases of level normal walking Phase No. I1 I2 I3 I4 I5 I6 I7 0 4.519 0.929 0.782e-2 0.101e-2 -1.396e-6 -0.739e-3 2.609e-6 1 4.543 0.882 0.373e-2 0.495e-3 -6.637e-7 -0.457e-3 1.105e-7 2 4.611 0.776 0.169e-2 0.340e-3 8.553e-8 -0.207e-3 -2.914e-7 3 4.598 0.794 0.954e-3 0.182e-3 7.231e-8 -0.128e-4 -2.409e-8 4 4.548 0.871 0.944e-2 0.566e-4 -9.382e-9 0.529e-4 -4.076e-9 5 4.526 0.906 0.167e-2 0.152e-3 4.394e-9 -0.600e-4 8.116e-8 6 4.529 0.902 0.465e-2 0.463e-3 -2.843e-7 -0.372e-3 6.473e-7 7 4.548 0.871 0.944e-2 0.951e-3 -2.090e-6 -0.845e-3 1.974e-6 8 4.585 0.817 0.158e-1 0.157e-2 -6.600e-6 -0.140e-2 4.298e-7 9 4.627 0.758 0.224e-1 0.216e-2 -1.328e-5 -0.189e-2 7.082e-6 10 4.599 0.797 0.218e-1 0.226e-2 -1.532e-5 -0.203e-2 4.157e-6 11 4.508 0.937 0.102e-1 0.116e-2 -3.964e-6 -0.111e-2 -5.757e-7 12 4.506 0.941 0.105e-2 0.959e-4 -1.202e-8 -0.801e-4 -2.931e-8 13 4.594 0.806 0.125e-2 0.173e-3 4.013e-8 -0.622e-4 8.811e-8 14 4.682 0.691 0.510e-2 0.640e-3 2.039e-7 -0.239e-3 1.300e-6 15 4.645 0.748 0.383e-2 0.676e-3 2.501e-7 -0.239e-3 1.230e-6 16 4.586 0.841 0.146e-2 0.293e-3 4.517e-8 -0.107e-3 2.173e-7 17 4.559 0.884 0.135e-2 0.206e-3 -1.891e-8 -0.105e-3 1.161e-7 18 4.541 0.908 0.282e-2 0.376e-3 -1.564e-7 -0.233e-3 3.723e-7 19 4.526 0.925 0.508e-2 0.668e-3 -5.598e-7 -0.452e-3 1.146e-6 The metric (3) makes it possible to measure distance 7 : ( , ) b a b a R H H J  including distance ij CS R between an arbitrary point HCS, characterizing the current state of the user, and cluster center ij mid ij ClH  . Thus, this distance can serve as a measure that allows us to judge whether point HCS belongs to cluster Clij. In fact, this means that the current state of the user described by point HCS corresponds to activity phase ωij determined by cluster Clij if ij CS R has a minimum value among all distances from this point to the cluster centers included in J7. If it is not possible to determine the minimum distance ij CS R , it can be assumed that the user makes a move that is not represented in IS as the typical mode of activity Ωj. In this case, the HLC takes the MLC to volitional control. Thus, to recognize the activity phase of the TFP user, you must perform the following steps, i. e. you must:  generate a database of reference images of i phases for each of j possible modes of activity in the form of a set of vectors Hij = {IijS, s = 1,...,7} representing cluster centers Clij  J7;  determine the vector of informative parameters of the current state of the user PCS = {csH, csK, csA, VGRFcs} and calculate the corresponding values of the generalized coordinates of invariant space J7 : Hcs = {IcsS, s = 1,...,7}; 146 A. POLIAKOV, V. PAKHALIUK  calculate distances ij cs R between points Hcs and Hij : Clij  J7 and determine the smallest among them; and,  decide on whether the current state belongs to cluster Clij and compare this state to activity phase ωij. However, one should take into account the fact that space J7 is extremely inhomogeneous and the generalized coordinates of the clusters centers characterizing the phases of activity differ significantly from one another (see the data in Table 1). Therefore, the generalized coordinates of vectors Hij and Hcs, which have significantly smaller values compared to the others, will practically have no effect on distance ij cs R between the points in J7. At the same time, such generalized coordinates are very sensitive to possible errors of the sensor system [11] and, therefore, are effective for clarifying the belonging of point Hcs to a certain cluster Clij. Given the above features, for the preliminary estimation of the belonging point Hcs to cluster Clij mapping space J4 described by generalized coordinates {I1,I2,I3,I4} can be chosen. In the case of obtaining obvious minimum distance ij cs R in J4, at this stage it is possible to decide on the belonging point Hcs to cluster Clij and, consequently, about the correspondence of the current user state to activity phase ωij. If in the study of this space several small distances close to each other are obtained:, ji cs R )1(  , …, )1( ji cs R ,…, estimating the belonging of point Hcs to cluster Clij should be clarified by performing an analysis of mapping space J3 described using generalized coordinates {I5,I6,I7}. In cases where it is impossible to determine explicit minimum distance ij cs R , a decision is made to switch the MLC to volitional control. As an example, Fig. 5a shows clusters in hyperplane 3  of the space of invariants 4 J , which is described by generalized coordinates {I2,I3,I4}. Each cluster in P3 is represented by three points the coordinates of which are calculated using parameters mid ijk p , m in ijk p and m ax ijk p at the activity phases of 0, 4, 9, 14, 19 corresponding to activity level Ω1 (level normal walking). The visual analysis in Fig. 5a shows that clusters Cl01 and Cl191 arranged in P3 hyperplane are relatively close to each other. Therefore, distances 01 cs R and 191 cs R calculated from the centers of these clusters to some point Hcs may differ slightly. In such cases, it is expedient to refine the decision on the classification of point Hcs and its correspondence to a certain phase of activity from the analysis of mapping space J3, described by generalized coordinates {I5,I6,I7}. A fragment of this space, including clusters Cl01 and Cl191, is shown in Fig. 5b. We will illustrate the process of recognizing the activity phase using a simple example. Suppose that as a result of the experiments a database of reference patterns of activity modes Ω1, Ω2 and Ω3 is formed and the current state of the TFP user is measured, characterized by the following normalized informative parameters: H = 0.0739557, K = 0.106382, A = 0.414937, VGRF = 0.623085. Consequently, the image of the current phase of activity cs  is a vector: {0.0739557, 0.106382, 0.414937, 0.623085}, cs   to which point Hcs corresponds in space J7: Fast User Activity Phase Recognition for the Safety of Transfemoral Prosthesis Control 147 { , 1, 2,..., 7} {4.534, 0.895, 0.772 2, 0.786 3, 0.162 6, 0.728 3, 0.108 7} CS csk H I k e e e e e            . a) b) Fig. 5 Clusters in the activity mode 1 (level normal walking): a) in hyperplane P3 with generalized coordinates {I2,I3,I4} at the activity phases 0, 4, 9, 14, 19; b) in space J3 with generalized coordinates {I5,I6,I7} at the activity phases 0, 19 Fig. 6 shows distances diagrams ij cs R from point Hcs to cluster centers Clij, (i = 0,2,...20; j = 1,2,3) in hyperplane P3. a) b) c) Fig. 6 Distances ij cs R from point Hcs to centers of clusters Clij in hyperplane P3 for i = 0,2,…,20: a) 1i cs R ; b) 2i cs R ; c) 3i cs R Elementary analysis of the charts in Fig. 6 suggests that in the example considered, it is impossible to uniquely determine the smallest distance minij cs R in hyperplane P3, if we consider that: the base of reference patterns of activity regimes is formed on the basis of the average data obtained for discrete phases of activity; the current phase of the activity 148 A. POLIAKOV, V. PAKHALIUK of the TFP user may differ from the discrete phase represented in the base of the reference images of the activity modes; the sensor system approximately evaluates the current state of the TFP user. Therefore, to make a final decision on whether the current phase of activity belongs to a cluster, it is advisable to perform an analysis of space J3, choosing for this a number of clusters, the distances from the centers of which to point Hcs in hyperplane P3 are relatively small. In this example, 5 clusters were selected for each activity mode Clij : j = 1: i = 1, 5, 6, 7, 18; j = 2: i = 5, 6, 8, 9, 13; j = 3: i = 5, 6, 7, 8, 15. The charts of the distances from point Hcs to centers Clij in space J3 are shown in Fig. 7. Their analysis allows us to conclude that the vector of informative parameters used in this example does not allow one to uniquely match point Hcs to a single cluster since the distances from this point to the centers of the nearest clusters in space J3 are practically equal to each other: 6371 cscs RR  . Such a result can be obtained only in the cases when the image of the current activity phase and the images of the activity phases closest to it differ slightly from each other. Comparing the images of activity phases 6371 ,,  cs , it is easy to see that this is the case under the conditions of the example in question (see Fig. 8). a) b) c) Fig. 7 Distances from point Hcs to centers of clusters in space J3: a) ;18,7,6,5,1, 1 iR i cs b) ;13,9,8,6,5, 2 iR i cs c) 15,8,7,6,5, 3 iR i cs a) b) c) Fig. 8 Images of user activity phases: a) 71; b) cs; c) 63 Fast User Activity Phase Recognition for the Safety of Transfemoral Prosthesis Control 149 4. DISCUSSION The method of recognition, grounded in this work, is based on the representation of the activity phase of the TFP user in the form of an artificially created image. Nevertheless, such an artificial image roughly describes some user state in the space of all possible states and can be used to compare it to a certain phase of activity. It is assumed that the image of each phase is unique and can be represented in space J7 in the form of a vector, the components of which are Hu's moment invariants. If we take into account that the artificial images of the activity phases are not subject to displacements, reflections and rotations in space and that they change their shape only by changing the vertical component of the image, then the set of all Hu's moment invariants turns out to be redundant for solving the problem of their recognition. But this makes it possible to perform the stratification of space J7 into two subspaces J4 and J3, in each of which the recognition of the phase images can be performed independently. In this case, the recognition results in space J4 and, in particular, in its hyperplane P3, are more significant, because invariants I2,I3,I4 are less sensitive to measurement errors of informative parameters than invariants I5,I6,I7 [11]. In this connection, subspace J3 in this method is used only if it is necessary to make an accurate decision about the correspondence of the current state of the TFP user to a certain activity phase. The most important advantage of the recognition algorithm proposed in this paper in comparison with others is the time of its realization, which, due to the use of the minimum number of arithmetic and logical operations, is significantly smaller compared to the "critical time" of recognition. This makes it possible to increase the time necessary for making a reasonable decision in IS for a further mode of traffic, which in turn increases the safety of the TFP user. It should also be noted that, in comparison with neuronet methods successfully used both in the practice of pattern recognition and in the practice of recognizing the activity modes, the proposed recognition algorithm does not require a learning procedure. For its practical implementation, only a lot of coordinates of artificially created images are required, which turn out to be similar for the majority of healthy people belonging to a certain group of physical activity. Moreover, even if the current user state is determined by the TFP sensor system with some errors, the image of this state is close in shape to the reference image. In fact, this makes it possible to determine with a high degree of reliability the belonging of the current state to a certain area of the user-implemented activity mode and reduces the probability of generating in SS driving moments in TFP hinges that can lead to "critical errors". The method was tested on a set of vectors { , 1,..., 4} { , , , }k H K Ak VGRF       , whose coordinates were chosen randomly within intervals maxmin k mid kk   at a given phase of a certain reference activity mode. In this case, the given phase could differ from the discrete phase list in the activity mode, i.e.: * * ( 1) : , 0, 2,..., 20; 0 1.0 ij i jI j i i i i              . In most cases, the classification of the "current state" given in this way when using this method was correctly executed. In some test cases, one of which was described earlier, ambiguous solutions of the recognition problem were obtained, which did not allow attributing the "current state" to a certain phase of activity. It can be assumed that for some values of the coordinates of user state vectors ω, even if the conditions 150 A. POLIAKOV, V. PAKHALIUK maxmin k mid kk   are satisfied, an incorrect classification of the "current state" is possible, but in our test studies such solutions were not obtained. It should be noted that in many cases, in which the boundary values of the informative parameters were chosen as the coordinates of the state vectors, it was impossible to make an unambiguous decision about the classification of the "current state". The results of the tests showed that the proposed method is not inferior to neural network and neural fuzzy methods in efficiency, but it requires significantly less computer time to solve the problems of phase activity recognition. Its effectiveness increases significantly when recognizing the phases of specific activity modes implemented by the TFP user at a given time since the difference in phase images within a particular mode is more noticeable than in the entire activity space available to the user. 5. CONCLUSION AND OUTLOOK In this paper, the method for fast recognition of the activity phase of the TFP user is based on the properties of the Hu's moment invariants. Its use in ISC will significantly reduce the time of phase recognition and minimize critical errors that contribute to the loss of equilibrium the user with TFP in different modes of activity. The evaluation of the probability of successful phase recognition based on this method is the subject of a separate study, so this issue in the study was not considered. At the same time, it should be noted that we performed a series of numerical experiments in which it was assumed that the data registered using sensors characterizing the value of a particular parameter keep normal distribution laws with mathematical expectations corresponding to the reference values of the parameters accepted as informative for different dispersion values. As it turned out, in most cases, the activity mode corresponding to the experimental data was recognized correctly. However, there were also incorrectly recognized regimes, especially in the cases where the variances of the distribution laws were chosen as large enough. This suggests that the probability of correct recognition of the activity mode using the proposed method increases with increasing accuracy of the recorded parameters. The method can be used to recognize the phase in the entire activity space that is accessible to a specific user. At the same time, the activity mode realized by the user at a given time is also recognized. However, in such an option, the possibility of an incorrect classification of the current state turns out the greatest. This method is more effective when determining the phase at a given mode of activity, because the images of the phases in this case are more different from each other. In this connection, in ICS algorithms, it is advisable to use activity mode recognition subsystems based, for example, on long short-term memory (LSTM) networks, which allow using time dependences of data streams of sensors [14]. However, it can be assumed that the modification of our approach to the construction of artificial images of phases can lead to the appearance of more noticeable differences in them, which in turn will significantly increase the reliability of their recognition, including in the entire activity space. In conclusion, it should be noted that this paper presents only the mathematical side of the method of recognizing the modes and phases of patients' physical activity when walking with the TFP. At the same time, we assumed that the sensors, controllers, and software in the ICS of a real prosthesis will be similar to those commonly used in prosthetic control systems and described in detail in the scientific literature [4]. That is, the time required to register, Fast User Activity Phase Recognition for the Safety of Transfemoral Prosthesis Control 151 filter and classify the values of informative parameters will correspond to that observed in existing control systems. This suggests that the proposed method is characterized by high speed in relation to generally accepted ones at present, because the number of mathematical operations necessary for its implementation is much smaller than in known methods. Acknowledgements: The reported study was funded by the internal grant of Sevastopol State University, project number 512/06-31. REFERENCES 1. Poliakov, A., Pakhaliuk, V., Kolesova, M., Shtanko, P., Ovchinnikova, M., 2017, Transfemoral prostheses control in a frame of intellectual-synergetic concept, Proc. of the 2017 2nd Int. Conf. on Autom., Mech. and Elect. Eng. (Amee 2017), 87, pp. 245-253. 2. Varol, H.A., Sup, F., Goldfarb, M., 2010, Multiclass real-time intent recognition of a powered lower limb prosthesis, IEEE Transactions on Biomedical Engineering, 57(3), pp. 542–551. 3. Poliakov, A., Pakhaliuk, V., Lozinskiy, N., Kolesova, M., Bugayov, P., Shtanko, P., 2016, Biosimilar artificial knee for transfemoral prostheses and exoskeletons, Facta Universitatis-Series Mechanical Engineering, 14(3), pp. 321-328. 4. Tucker, M.R., Olivier, J., Pagel, A., Bleuler, H., Bouri, M., Lambercy, O., Millan, J.-R., Riener, R., Vallery, H., Gassert, R., 2015, Control strategies for active lower extremity prosthetics and orthotics: a review, Journal of NeuroEngineering and Rehabilitation, 12(1), pp. 1-29. 5. Huang, H., Zhang, F., Hargrove, L.J., Dou, Z., Rogers, D.R., Englehart, K.B., 2011, Continuous locomotion- mode identification for prosthetic legs based on neuromuscular mechanical fusion, IEEE Transactions on Biomedical Engineering, 58(10), pp. 2867-2875. 6. Zhang, F., Liu, M., Huang, H., 2012, Preliminary study of the effect of user intent recognition errors on volitional control of powered lower limb prostheses, Conf. Proc. IEEE Eng. Med. Biol. Soc., pp. 2768-2771. 7. Zhang, F., Liu, M., Huang, H., 2014, Effects of locomotion mode recognition errors on volitional control of powered above-knee prostheses, IEEE Transactions on Neural Systems and Rehabiliation Engineering, 23(1), pp. 64-72. 8. Hu, M.K., 1962, Visual pattern recognition by moment invariants, IRE Transactions on Information Theory, 8(2), pp. 179-187. 9. Bernstein, N.A., 1991, On dexterity and its development, Physical Education and Sport, Moscow, 287 p. 10. Flusser, J., Suk, T., Zitova, B., 2009, Moments and moment invariants in pattern recognition, John Wiley and Sons Ltd Pub., Chichester, 294 p. 11. Abramov, N.S., Khachumov, V.M., 2014, Object recognition based on invariant moments, Bulletin of the Peoples' Friendship University of Russia Series Mathematics, Computer science, Physics, 2, pp. 142-149. 12. Arafah, M., Moghli, Q.A., 2017, Efficient image recognition technique using invariant moments and principle component analysis, Journal of Data Analysis and Information Processing, 5, pp. 1-10. 13. Al-Azzo, F., Taqi, A.M., Milanova, M., 2017, 3D Human action recognition using Hu moment invariants and euclidean distance classifier, International Journal of Advanced Computer Science and Applications, 8(4), pp. 12-21. 14. Hochreiter, S., Schmidhuber, J., 1997, Long short-term memory, Neural Computation, 9(8), pp. 1735-1780.