The table diagram of the subject behaviour on the bed.

## 1. Introduction

The behaviour of subjects during the sleep gives information about their healthy. Medical staff has done several studies regarding the body position and its motion on the bed. At present the bed and the mattress are conceived in order to satisfy the comfort needs of the user. The mattresses have position, pressure, temperature and humidity sensors which inform the doctor about the behaviour of the subject on the bed (Agarwal R. & Gotman J., 2004).

The sleep depends by the many parameters as: the type of illness, the psychical state, the medical treatment, the alcohol and caffeine consumption, the external conditions etc. This can be classified into several states using information by the polysomnografic measurement that includes: electroencephalogram (EEG), electromyogram (EMG), electrooculogram (EOG).

In this paper are presented the methods for the identification of the body position on the bed using the position sensors. The system of sensors has divided in areas of studies recorded in a matrix. The sensors information’s are acquired with the dedicated card for this application. The card has a microcontroller core for: acquisition, conversion of analog to digital data and sending the data to the PC (Virone, 2003). The sampling values of the sensors give information to the medical staff about the subject presence on the bed, the movement and position of the body (Watanabe T. & Watanabe K., 2004), (Shochart & Oksenberg, 2003). The localization of the body position depends of the numbers of system areas. The data are represented as a matrix in which the row represents the values of sensors placed on the length of bed and column represents the sensors values placed on the transverse direction. The data are classified using fuzzy and neuro-fuzzy algorithms implemented in a MATLAB program. The aim of work is to develop an expert system which can diagnose the healthy of the subject using the data acquired of the different type of sensors placed on the mattress.

In the following sections are described: the sensors' system, the algorithms used to identify the position of the body and in the last are present the results of the experimental part.

## 2. The sensors system

The system of sensors for the identification of the body position is conceived by the use of the medical staff. Several methods to position the sensors are tested. The data are processed for two prototypes.

In the first case (Fig. 1 a), the sensors are equally distributed along of the bed and in the second mode (Fig. 1b), the sensors placed on the bed have a body form.

The data acquired from the sensors distributed as Fig. 1a, are represented in Fig. 2.

The 3D representation of the sampling signals, acquired during the 1000s period of time, are showed in Fig.2 a. The p[V] of the OZ axis represents the values of 14 sensors. The data are acquired with a subject on the bed. The peaks variations represent the body movement when the subject changes the position.

The 2D plot represents the sensors values during the 900s time period (Fig. 2b). The signals of the first 350s represent initial values, without the subject on the bed. Beginning with the 350s, the subject is on the bed. The peaks represent the body movement.

The large values of signals represent the zone of body which presses harder on the bed. Using these results the medical bed can be adjusted according to the body position. The mattress can be build with many layers, to assure the comfort of the subject.

The matrices corresponding to the sensors values for the two models (Fig.1 a, b) are:

The elements of matrix A corresponds of the sensors values represented in Fig. 1a. The matrix have the 3 columns and 6 rows. The number of columns corresponds to the maximum number of sensors placed on the length. The null elements indicate the absence of the sensors. Matrix B has 2 columns and 9 rows. Its elements correspond of the sensors value placed according to Fig 1b. The maximum number of sensors placed on the length is 2.

The sampling period of acquisition is 2s.

Using the values acquired from the sensors and a simple algorithm one can know the hour of presence or absence of subject on the bed, the period of time spend in bed, the movement period and the body position (Table 1.).

Data | The hour of body movement | The sensor value variation (maxim) | The part of body movement | The movement period | The daily period | Hour absence on the bed |

12.01.2005 | 0,572V | All | 10s | Afternoon | ||

12.01.2005 | 1V | All | 1h | Night | ||

12.01.2005 | 1V | All | 10min | Night | - | |

12.01.2005 | 0,22 | Right leg | 5s | Night | - | |

12.01.2005 | 0,57V | All | 5s | Night | ||

12.01.2005 | 1,2V | All | 10s | Night | - |

The sensor value variation (Table 1), represents the maximum variation of the data, between all the sensors, which results after the body movement. The localisation of the body movement is achieved.

The data are analysed during a period of 24 hours and this are divided in the small periods corresponding to the day and the night.

The period of 24 hours is a sum of the absence (*T* _{abs}) and presence (*T* _{pres}) periods of the subject on the bed.

The period of rest of the subject on the bed can be passive or active and this results from the movement period and the amplitude.

The system might be integrated in the intelligent apartment which has many sensors for the tracking of the subject (Ross, 2004), (Hirota & Tamaki, 2001), (Hnatiuc & Fontaine, 2006). Using the entire daily activity data one can identify the healthy of the subject taking into account his behaviour.

## 3. The data analysis algorithms. Short description

### 3.1. The K-means method. Silhouette parameter

A good cluster gives the qualities classes with similarities between the objects of a class and small similarities between external objects of the class. The quality of classification is measured of the abilities to discover the hidden features (Hans-Hermann, 2008).

The K-means algorithm is based on the relative similarities and defines parameter and probabilities. The idea is to find the K centers, one for each cluster. The centers might be placed at the distance one of the other. The next step is to compute the distances between objects and centers. The objects are associated to each center. The new centers are recomputed as centers resulted of the last step. When it is known the new K centers is applied one more time the algorithm describes above. It is generated a loop which is stopped when the centers don’t change their place. The algorithm is achieved with minimization of the function of square error.

The “Silhouette” technique computes the silhouette distance for each sample as average for each cluster and the average of overlapping for all data sets.

The silhouette parameter represents a measure of similarity of a point with the points in the same cluster compared with points of the other cluster.

Let us consider a cluster of K points in K groups; x_{i} is associated of cluster A; C_{k} is a cluster different of A. Depending on the average value of the silhouette parameter there is evaluated the number of classes.

where *a(i)* is the average of not similarly distance of *x* _{i} for all points of *A* and *d(i,C)* is the average of not similarly distance of *x* _{i} for all points of *C*.

One chose the smallest distance between them (6).

where *b(i)* is the neighbourhood of *x* _{i} and no{C_{k}} is number of objects included in cluster D.

The average of silhouette value *s(i)* of point *x* _{i} is:

The coefficient silhouette interpretation, with respect to its value, according to Rousseeuw, 1987, follows:

for the general range *s(xi* ) *Є* [-1,1]

*s(x*_{i}*)Є[0.71, 1]*– the points are in the good class, the structure is strong the distance of the other cluster is good;*s(x*_{i}*)Є[0.51, 0.70]*– the structure is acceptable;*s(x*_{i}*)Є[0.26,0.50]*– the structure is poor, it might be artificial;*s(x*_{i}*)=0*– the point is at the crossing of two class;*s(x*_{i}*)=-1*– the points is not classified

This method is used to find the number of classes and their centres used as parameters for the fuzzy or neuro-fuzzy systems.

### 3.2. The fuzzy classification method

The expert system gives the advice, diagnoses and recommendation inspired from the real world. The organisation of such a system is based on the knowledge of a human expert, but it is difficult to precisely extract the logic which can be implemented. In general, it is developed a prototype based on the experts’ information and then the system is tested in order to update the databases (Fukuda&Kubota, 1996). The knowledge base has the rules of type „IF-THEN”. Using a motor of inference are deduced the final solutions (Zemankova-Leech, 1983). These are represented by the fuzzy or neuro-fuzzy systems. (Fig.4.).

The input data of a system, in many cases, is associated to many classes with a membership degree. This is computed according to a membership function. All these are simulated with a fuzzy system which is divided in premises and consequences parts. The classification systems use the membership function in premises part and singleton in the consequences parts because these might be associated with the centres of classes.

If the numbers of classes and memberships functions of the inputs or outputs are established, one might compute the centre for each class and their limits. These parameters are adjusted in the learning system period.

The expert system has three stages of simulation: learning, testing and checking.

In the learning stage the system might test all the possible cases, using all values acquired in the experimental study. The number of learning stages might be very large excluding the transient period of the beginning. The error between the output resulted after the computing and the targeted output is defined by the user.

*Fuzzy Logic. Definition.*

If *U* is any group, one call the Fuzzy Logic, an application *f:U→[0,1]* characterised by the membership function *μ* _{f} *:U→[0,1].* If, the input *x* is assigned to *U*, *μ* _{f(x)} *(x)* is defined as the membership degree.

The fuzzy system algorithm is based on the fuzzy rules. It uses the linguistic variable in inputs and the output. The linguistics expressions describe the relationship between the condition and the consequence, parts of the classification system. In the end, the value resulted after the deffuzification is a crisp value (Zimmermann, 2001) (Zadeh, 1965), (Zadeh, 1968).

The rules “If-Then”, using the simplified fuzzy inference method, have the form:

If *x* _{1} is *A* _{i,1} and *x* _{2} is *A* _{i,2} and… and *x* _{n} is *A* _{i,n}, then *y* is *w* _{i}

where *A* _{i,j} is a membership function for the *j*-th input of the *i*-rule, and *w* _{i} is a singleton for the output of the *i*-th rule.

There are two types of fuzzy systems: Mamdani and Sugeno. The classification system usually uses the Sugeno, which has the following stages:

1. Computing of the membership degrees of *μ* _{Ai,j} *(x* _{j} *)* and *μ* _{Ai,j+1} *(x* _{j+1} *)* of the *i*-th rule (*i=1,…,r, j=1,…,n*).

2. Computing of the firing strength of the *i*-th rule using equation (2):

3. Computing of the resulting output by weighted average, based on the firing strength, with the equation (7)

Where *y(x)* is the output after the defuzzyfication, *w* _{i} is the singleton of the consequence part.

The fuzzy parameters might be identified with a clustering method.

## 4. Application of fuzzy system. The identification of body position on the mattress

### 4.1. The pre-processing data

The body position on the bed is identified using the position sensors placed on the mattress as presented in Fig 1 a) and b) (Alametsa,Varri, et.al. 2004). The system might give a result about the position in the rest period, when the data acquired is constant for a period of time (Hnatiuc & Caranica, 2009).

The data from the analyses are recorded seven patients, women and men, being tested. The sensors system is divided in three zones of study: the head and shoulders, the abdomen and the legs.

A data pre-processing is done to check if the subject is on the bed and if he is completely outstretched. If the subject is not completed outstretched the data processing is stopped.

In the pre-processing stage is computed the maximum and the minimum values and their area of the sensors at an instant time. First identification is done according to these values. If the minimum value is equal with the initial value of the sensors, the subject is not completely outstretched on the bed. These values help to identify the place of the subject on the bed.

It is known that the information about the position is obtained after the subtraction operation between the sensor value with and without subject. The initial value of sensor is between [0, 0.02]V, when the subject is not present in that place. The value is larger then 0.09V when the subject presses the place where the sensor is located. The maximum amplitude of the sensor signal is 5V.

After the first data analysis it results: the presence of the person on the bed, the body position outstretched or not and the legs’ position (Table 2). The final analysis is about the abdomen position identification. The algorithm for the position identification is not available during the body movement. The sample value is recorded at 2s time.

Test the person presence on the mattress; |

1. If the maximum value sensor variation, from all the sensors, is bigger then 0.02V Then the person is on the mattress and go to 2. |

Test the body movement on the mattress; |

2. If the amplitude between the present value and the previous value of sensor is larger than 0.3V Then the body moves. So go to 1. If not , compute the maximum value of the sensors in the same time and save this value and sensor number (go to 3) |

Test the time period between two body movements; |

3. Compute the time period between two maximum values showed at stage 2. If the time period is bigger then 10 minutes, go to 4. If it is not go to 1. |

Test the zone of the maximum variation. It is known that the basin of the person weighs the most of the body zone; |

4. If the maximum value is at the head or legs area, the patient is not completely outstretched on the mattress and the analysis for the position identification is STOPPED . If this zone is abdomen or shoulders the person is completely outstretched and continue the analyses. |

The data are processed before to be introduced in the classification system. If the subject is not completed outstretched on the bed, the analysis for the body position identification is not necessary.

After the data preprocessing can be studied the number of classes which can be identified with the sensors’ values. Using the K-mean clustering one know which is the maximum number of classes and how are separated.

### 4.2. Cluster data

The acquisition of data is produced in the presence of a specialist. The body position of the subject is recorded after each experiment, using the specialist indication.

One verified, in the following paragraph, if the number of classes resulted after the cluster algorithm are equal with the numbers of classes recorded in experimental part.

*A.* The first test is done on the model 1a). The sensors covered, in this case, the entire bed surface. The area of the sensors is composed by three zones: the head and shoulders (1, 2, 3, 4, 5), the abdomen (6, 7, 8, 9, 10) and the legs (11, 12, 13, 14).

The algorithm presented in section 3.1 is applied on the data and the results are presented on the Table 3. In this test, the databases used don’t contain the column with the body position class. One uses the Euclidian distance for the computing of distance between data. The silhouette parameter must be in range [0, 1].

The results of K-means algorithm prove as the number of classes is five because of this number the value of the silhouette parameter is maximum (Table 3). Looking on the graphic representation, the silhouette parameter has positives and negatives values (Fig. 5). So the maximum numbers of classes which can identify, using the silhouette values is four. The data are recorded using the sensors system represented in Fig. 1a.

The body classification with the K-means method, using silhouette parameter is equal with the predicted number, after the visual observation. Using the arrangements of sensors as in the first figure, one can identify the body position on the bed.

Number of classes | Silhouette Parameter |

2 | 0.3201 |

3 | 0.6772 |

4 | 0.6586 |

5 | 0.7140 |

6 | 0.5775 |

*B.* The tests of the second prototype are presented in the next paragraph.

In this case the sensors are placed, on the bed, under the most important position of the body zone. For each acquisition is marked the position of body, and there are used 12 values provided by the sensors (Table 4).

b1 | b2 | B3 | b4 | b5 | b6 | b7 | b8 | b9 | b10 | b11 | b12 | class |

0.09 | 0.14 | 0.09 | 0.09 | 0.11 | 0.33 | 0.25 | 0.23 | 0.08 | 0.05 | 0.06 | 0.07 | 1 |

0.09 | 0.14 | 0.08 | 0.09 | 0.11 | 0.32 | 0.24 | 0.15 | 0.07 | 0.05 | 0.06 | 0.06 | 1 |

0.12 | 0.11 | 0.02 | 0.12 | 0.15 | 0.21 | 0.21 | 0.19 | 0.16 | 0.01 | 0.02 | 0.06 | 2 |

0.1 | 0.1 | 0.08 | 0.1 | 0.24 | 0.2 | 0.13 | 0.01 | 0.14 | 0.13 | 0 | 0.02 | 3 |

0.1 | 0.1 | 0.08 | 0.1 | 0.23 | 0.19 | 0.12 | 0.01 | 0.13 | 0.13 | 0 | 0.02 | 3 |

0.07 | 0.01 | 0.18 | 0.07 | 0.14 | 0.21 | 0.16 | 0.17 | 0.02 | 0.14 | 0.02 | 0.1 | 4 |

0.06 | 0.07 | 0.11 | 0.06 | 0.11 | 0.29 | 0.34 | 0.05 | 0.02 | 0.07 | 0.02 | 0.11 | 4 |

0.2 | 0.1 | 0.06 | 0.2 | 0.14 | 0.14 | 0.3 | 0.26 | 0.07 | 0.05 | 0.08 | 0.09 | 1 |

Note: In the 15 column the number represents the body position as following: 1 is the breech down, 2 is the lateral left, 3 is the face down and 4 is the right laterally position.

One tries to identify the body position using the visual observation using the data plots. The 3D representations of the matrices B for two position of the body are presented in Fig. 6. The OX axis represents the matrix columns, the OY axis represents the rows of the matrix and on the OZ axis is the sensors values. The Fig. 5a) represent the sensors values for the breech down position. The high values are recorded in the b6, b7, and b8 elements. The second figure (Fig.5b) represents the sample values of the face down position. The high values are recorded for the b1, b2, b3, b11, b12 elements.

The maximum density of the sensors values are in the range [0, 0.25] V. There is not very large difference between the two plots. The visual identification is not possible.

Is presented the classification of body position using the data value of the three sensors. The K-means algorithm is applied to the data provided by 6 sensors (b5, b7, b7 and b7, b8, b9) which are included in two groups. The number of classes for body identification, used in that test, is four (Fig. 7).

So, the last processing is done using the data of all of the second prototype. It has the sensors assigned to the following areas: the head and shoulders (1, 2, 3), the abdomen ( 4, 5, 6, 7, 8) and the legs (9,10, 11, 12, 13, 14).

After cluster computing for 2, 3, 4, 5, 6 classes, the maxim value of silhouette parameter is 0.585 for 5 clusters. The graphics of 5 clusters, similar to the Silhouette parameter, show that the Silhouette average value has negatives values (Fig. 8a). The points of one class are included in the other classes. The representation of the silhouette parameter where there are positive values is for two clusters (Fig. 8b). The average value of the parameter silhouette is smaller then 0.8. The numbers of classes coincides with the classes recorded after visual observation.

The algorithm described above shows the possibilities to identify the position. The centers of classes are too close one to the other and the classes are overlapped.

The classification system might be a fuzzy system in which the sensors’ values can be the inputted. The relations between them are expressed in linguistics expressions.

### 4.3. Data classification

The cluster step offers information about the number of classes and their limits. Using these information a classification system can be created. The data are classified using a fuzzy system with 12 inputs and 4 outputs. The inputs represent the sensors values and the output the position of body. The results of cluster part using k-mean show as the maximum number of classes which represent the body positions is four. The outputs of fuzzy system represent the number of classes in which can be grouped the sampling values of sensors.

The fuzzy system proposed is Sugeno, type 0. The input membership functions are triangular type and the outputs are singleton. Each membership input function has three irregular triangles (10) which are overlapped.

The computing algorithm of the fuzzy system uses the set of stages defined in the section 3.2. The learning stage uses the back-propagation method.

where *i* is a sample number, *j* is the input number, *rule* represents the rule number. The *T *is the membership degree of the time input. The coefficients *aj(i)* is the height of triangle, *aj+1(i)* and *a* _{j-1 }*(i)* are the values of the two sides of the triangle.

The membership functions for the samples amplitude in the input may be defined as: “Small”, “Average”, “Large”. The membership functions of the outputs have the linguistic descriptions as: “Breech Down” - 1, “Left” - 2, “Right” - 3 and “Face Down” - 4.

The rules are created in function of the pressing force on the sensors areas. The most important areas for position identification are the shoulders and basin. Using the matrices elements of the second prototype one creates the following general rules of the fuzzy system.

Rules No. | Rules Description |

R1i | IF the values of the shoulders area are Average AND IF the values of abdomen area are Large AND IF the values of the legs area are Small THAN The position is Face Down |

R2i | IF the values of the shoulders area are Average AND IF the values of abdomen area are Average AND IF the values of the legs area are Average THAN The position is breech down |

R3i | IF the values of the shoulders (left side) area are Big AND IF the values of the shoulders (right side) are Small AND IF the values of abdomen (right side) are Big AND IF the values of the abdomen (left side) are Small AND IF the values of the legs area are Small THAN The position is Right |

R4i | IF the values of the shoulders area (right side) are Big AND IF the values of the shoulders (left side) are Small AND IF the values of abdomen (left side) area are Large AND IF the values of the abdomen (right side) are Small AND IF the values of the legs area are Small THAN The position is left |

R5i | IF the values of the shoulders area (right side) are Average AND IF the values of the shoulders (left side) are Average AND the values of abdomen (left side) area are Large AND the values of the abdomen (right side) are Small AND the values of the legs area are Small THAN The position is left |

R6i | IF the values of the shoulders area (right side) are Average AND the values of the shoulders (left side) are Average AND the values of abdomen (left side) area are Small AND the values of the abdomen (right side) are Large AND the values of the legs area are Small THAN The position is right |

Note:*r* is the number of particularly rules of generals rules presented above.

The custom of the rule R1i is exemplified in the next table. The elements of the matrix B are used as inputs and the positions as output.

The rules are conceived using the results of the cluster algorithm. The knowledge base and the ranges of the variation might be updated with respect to the stature of the subject.

The fuzzy system is simulated in FIS structure of MATLAB. To perform the input/output map the system map inputs through input membership functions and associated parameters, and then through output membership functions and associated parameters to outputs. The parameters associated with the membership functions changes through the learning process. The adjustment of system parameters is facilitated by a gradient vector. This gradient vector provides a measure of how well the fuzzy inference system is modeling the input/output data for a given set of parameters. When the gradient vector is obtained, any of several optimization routines can be applied in order to adjust the parameters to reduce some error measurements. This measurements error is usually defined by the sum of the squared difference between actual and desired outputs. The back-propagation method can be used to estimate this parameter.

Rules No. | Rules Description | |

R1i (i=1÷4) | The rules for the breech down position | |

R11: | If b1 is Average AND IF the b2 is Average and b3 is Average AND IF b4 is Small AND IF b5 is Small AND IF b6 is Average AND IF b7 is Big AND IF b8 is Large AND IF b9 is Average AND IF b10 is Average AND IF b11 is Small AND IF b12 is Small Then the position is breech down | |

R12 | If b1 is Large AND IF the b2 is Average and b3 is Average AND IF b4 is Small AND IF b5 is Small AND IF b6 is Average AND IF b7 is Large AND IF b8 is Large AND IF b9 is Average AND IF b10 is Average AND IF b11 is Small AND IF b12 is Small Then the position is breech down | |

R13 | If b1 is Average AND IF the b2 is Large and b3 is Large AND IF b4 is Small AND IF b5 is Small AND IF b6 is Average AND IF b7 is Large AND IF b8 is Large AND IF b9 is Average AND IF b10 is Average AND IF b11 is Small AND IF b12 is Small Then the position is breech down | |

R14 | If b1 is Average AND IF the b2 is Average and b3 is Average AND IF b4 is Small AND IF b5 is Small AND IF b6 is Large AND IF b7 is Large AND IF b8 is Large AND IF b9 is Large AND IF b10 is Large AND IF b11 is Small AND IF b12 is Small Then the position is breech down. Etc |

A simulation of a structure of the fuzzy Sugeno system for body position identification is presented in Fig. 9.

The input membership function, consisting of three for each input has a triangle form (Fig. 10a) and an output singleton (Fig. 10b).

The simulation of eight rules, which represent the identification of breech down position (class - 1) has the output value of 0.7 (Fig. 11). The class is identified with 70%precision.

The represented fuzzy system is one solution possible for body position identification using sampling values of the sensors.

The fuzzy system with 12 inputs is expensive. Another solution is to use the sensors placed to the shoulders and abdomen area. The number of sensor used is five. A simple simulation using ANFIS Editor of MATLAB is represented in the next figure. The neuro-fuzzy is generated using Grid Partition, and for the learning stage is used the back-propagation algorithm. The system has five inputs and four outputs. The error resulted after the testing stage is 1,2069%. This proved that the body position on the bed can be identified using the sensors placed only in the important area.

## 5.Conclusion

Monitoring systems are very important in medical electronics. Their design and analysis facilitate the medical staff work and offer the user independence.

The original system presented in the paper can be used to detect body position on the bed as well as the type of body movement. Using: the body movement, the time period between two successive movement and the sensor amplitude, one can identify the sleep type (normal, agitate, abnormal, convulsive, etc). The system can be adapted to the person and does not depend on their weight, size or position. The classes of the body positions must be established after a large data base calibration for several patients.

The fuzzy system for classification can be selected with respect to the human’s bodies and habitudes which are not standard; each of them has their particularity which can be linguistic defined. Each person has particular sleep habitudes and their preference body position during the rest period.

The sensors system offers the *subject “signature”*. It can replace the continuum monitoring of the patient and alarms the medical personal in case of problems.

## Acknowledgments

Most of the concepts presented in the paper are the result of the research work done in the framework of the ID1223 project, under the supervision of the National University Research Council (CNCSIS), Romania(Oanta&Panait, 2007).