EXTRACTION OF PARAMETERS FROM DYSGRAPHIC HANDWRITING FOR CDSS SYSTEMS

In this study we address the issue of the handwriting processing by extracting parameters from the written speech. The work applies machine learning method – the decision trees method which aims to recognize the impaired handwriting, particularly dysgraphia. 55 features (e.g. total time, pen movement, pressure, speed, acceleration) were extracted from each out of 80 handwriting samples while analyzing the performance of classifier for the dominant parameter – minimal speed, and without the dominant parameter as well. The experimental results of the classifier are compared to the results of the statistical test – Mann Whitney U-test as a complex and challenging endeavor to create an accurate classification.


INTRODUCTION
Clinical decision support systems (CDSS) are information systems or computer applications used in health care to assist clinicians with clinical decisions.The systems themselves are used to process, analyze and retrieve information from available sources.The aim of such systems is to cooperate with a physician and to support him / her in decision-making processes, to prevent mistakes in decision making and to provide early warning [1].We focus on CDSS for handwriting, since handwriting is non-invasive, inexpensive, and reflects the symptoms of many other disorders such as Parkinson's disease [2] [3], Alzheimer's disease [4], Huntington's disease [5], dysgraphia [6] [7] and many others.In response to increasing concerns about handwriting disorders, I focus specifically on dysgraphia, since it manifests itself in childhood.The authors of [7] claim that children spend 31% to 60% of their school day by writing and other tasks of fine motoring.Difficulties in writing and the consequences of bad handwriting can therefore significantly disrupt their academic results, and they can even have a serious impact on the emotional state and behavior of the individual.This discovery encourages timely identification of handwriting disorders as well as preventive and remedial assistance.The goal of this research is to extract parameters from written text obtained with the Wacom graphic tablet in order to perform their processing, comparison and evaluation using the Python programming language.We compare the handwriting of the dysgraphic subjects to the handwriting of people without neurological disease or any other handwriting disorder.We have 80 samples of the handwriting, out of which 39 samples are provided by dysgraphic subjects (test subjects) aged 8 to 19 and 41 by healthy subjects (control subjects) aged 10 to 14.In both groups there is a greater incidence of males than the females, and the righthanded over the left-handed.The paper is organized as follows.In the next section we briefly describe similar works, focused on dysgraphia and handwriting processing.Then we describe preprocessing of the dataset and handwriting analysis.Later, we provide briefly overview of classification models and present the experimental resuls.Finally, some conclusions are drawn.

RELATED WORK
There are several existing studies focusing on analysis and handwriting processing [8] [9] [10].For example, Mekyska et.al in their work [11] describes a method that can be used for automated diagnostics of difficulty in writing text.In the study to suppress individuality in the handwriting and to emphasize the signs of dysgraphia, they introduced a simple method of normalization based on subtraction [12].They found that children with dysgraphia are unable to hold the pen in a stable position and therefore the pen slope varies greatly over time.They were able to design a dysgraphic evaluation system with a HPSQ (Handwriting Proficiency Screening Questionnaire) [13] error estimate of about 10%.Rosenblum and Dror in their work [6] use data mining methods to derive a statistical model that is able to distinguish the dysgraphic handwriting from an experienced handwriting with an accuracy of about 90% based on their performance characteristics.Paz-Villagran et al. in their work [14] compared in the same written assignment 26 adults and children of the third year of elementary school -39 proficient children and 16 dysgraphic children.The aim of the study was to focus exclusively on low-level graphomotor processes.The result of this study is that stopping during writing is more appropriate than an identifier, as opposed to pen strokes when differentiating the fluency of the handwriting to identify dysgraphy.

Dataset
The use of tablets is pervading almost all areas in our complex society.In order to collect the data, we use the graphic tablet -the Wacom Intuos Pro Large and the template with the handwriting tasks created by us.We received 80 samples of the handwriting, out of which 39 samples belong to patients with dysgraphia (27 men, 12 women) and 41 samples belong to healthy ones (26 men, 15 women).The age of all subjects is between 8-14 years old.We created the template based on the previous research [6] [14] [15] [16].The created template with the handwriting tasks consists of repeating the letter l, the syllable le, the words like leto, lamoken, hračkárstvo and the sentence V lete bude teplo a sucho.

Handwriting analysis
The collected samples are processed by the Python programming language.It is necessary to calculate the individual parameters for each sample separately and then to compute the calculations.Then the results are analyzed and the preliminary outcomes of the sample are determined.Table 1 shows parameters of the calculated sample.Samples no.1-5 are obtained from the dysgraphic subjects and samples no.8-12 are obtained from the healthy subjects.As expected, the results differ significantly, for example in the total time of the writing and in the average writing speed as well.We also use classification models for analysing and processing the received data.In more detail they are described in the section 4.

CLASSIFICATION MODEL
Currently, there are multiple classification algorithms.Within this study we decided to use the classification model -decision trees.

Decision tree method
Decision tree method is most commonly used for data classification.It is one of the most preferred techniques in the data mining processes.The most important decision tree criterion is the choice of the most appropriate classifier.It is able to distinguish the objects from one another and divide them into different branches.To select the correct classifier, the statistical property -entropy (information gain) is used, which indicates the rate of division of the object into the target classification.Entropy is calculated according to the relation 1, where S is the set containing all possible states, and p i is the ratio of the set S, falling into the class i.
In general, the method of the decision trees applies multiple different algorithms.The most well-known decision tree algorithms include ID3, C4.5 and CART algorithm.

A. ID3 (Iterative Dichotomizer 3) algorithm
It is an iterative two-class classifier that creates the decision tree in a top-down way.When creating a tree, it follows the rule that if there are several explanations for any phenomenon, it is advisable to prefer the least demanding.We can simply describe the ID3 algorithm through the following three steps: • Takes all unused features and calculates their entropy with respect to the test set of data.
• Selects the attribute with the smallest entropy (highest information gain).
• Creates nodes with the selected attribute.

B. C4.5 algorithm
It is an improved ID3 algorithm.It recognizes nominal (discrete) and real (continuous) features.C4.5 creates a tree from the top down using the "divide and dominate" principle.If some values are missing in the tree, they ignore them and continue "in learning".It uses a relative information gain that already takes into account the number of variables of the given attribute.At present, there is a newer version of this algorithm -the C5.0 (See5) algorithm.

C. CART (Classification and Regression Trees) algorithm
The decision trees created by the CART algorithm have a binary topology, meaning that each node has just two offspring.CART algorithm can process any input data -it can work with both, qualitative and quantitative data.In principle, this algorithm works on the most appropriate allocation of input data according to one of the features.

EXPERIMENTAL RESULTS
In order to provide an accurate classification, we selected the decision tree method as the most appropriate for our study.We used the scikit-learn [18] -a free software machine learning library for the Python programming language, which offers all the tools required for deep data analysis.After comparing the above algorithms, we chose the CART algorithm because the library was used particularly to classify the parameters, and uses the just-optimized version of the CART algorithm.We also conducted statistical testing using the Mann-Whitney U test.It should confirm the assumption that there are characteristic differences between the handwriting of the control subjects and the test subjects.

Mann-Whitney U test
It is the non-parametric statistical test [19] that is used to compare two samples and to test whether the two sample means are equal or not.In our case, we compare the calculated parameters of the control subjects with the parameters of the tested subjects -people with dysgraphia.The calculated parameters represent a set of data.The variable represents whether it is a control subject or a person with dysgraphia.
Hypothesis definition: H0: The handwriting of control subjects is not statistically different from the handwriting of persons with dysgraphia.H1: The handwriting of control subjects is statistically different from the handwriting of persons with dysgraphia.
We have chosen the significance level (p-value) to 0.05.That is, we are working with a 5 percent risk that we mark the right hypothesis as the wrong one.The results of the Mann-Whitney U test of the significance level for the individual parameter are shown in table 2, table 3 and table  4. The green color in the tables highlights the significance levels that confirm the assumption -hypothesis H1.The table 2 shows that for all time parameters there is a significant difference between the tested subjects and the control subjects.minimum 0,726 0,719 0,012 0,134 maximum 0,041 0,027 0,001 0,569 average 0,007 0,021 0,001 0,107 median 0,003 0,011 0,001 0,075 The table 3 shows that the pen pressure parameter does not show the difference between the tested subjects and the control subjects.Conversely, for the pen movement length parameter, the hypothesis H1 was confirmed in all the statistical values except the horizontal and total minimum of this parameter.
Table 4 shows the results for speed (v), acceleration (a) and for jerk (j) coefficient.Significant changes between the tested and control subjects can be observed especially for the minimum and maximum statistical values.

Classification using the decision tree method
Before the classification itself, we created a dataset consisting of all respondents (80) and their calculated parameters (55).The success of the decision tree algorithm is strongly dependent on how we divide the dataset into a test and training subset.This is done using the train test split feature, which is part of the scikit learn library.We defined that the size of the test and training subset was the same.The result is four subsets of data: x train, x test, y train and y test.X-subsets contain values (individual parameters) and Y-subsets contain labels (healthy or dysgraphic).We have computed the test subsets for multiple possible sizes.The resulting success rate, to be as real as possible, is calculated as the average of all the successes that we have obtained through different dataset distributions.The success of the decision trees algorithm in the classification of a set of all parameters was 83.4%.It follows that with the accuracy of 83.4% we can determine whether it is a healthy (control) subject or a person with dysgraphia.While creating the classification using decision trees, we found that the dominant parameter is the minimum speed.Based on this single parameter, the classification score would be 93.9%.Conversely, if we removed this parameter from the dataset, the success rate of the algorithm would drop to 67.9%.For better clarity, the results are shown in table 5. p(a x ) p(a y ) p(j) p( j x ) p( j y ) minimum 0,276 0,05 0,689 0,003 0,004 0,091 0,001 0,001 0,004 maximum 0,007 0,091 0,02 0,0006 0,073 0,021 0,006 0,063 0,021 average 0,704 0,865 0,697 0,749 0,697 0,704 0,741 0,682 0,704 median 0,849 0,704 0,992 0,865 0,741 0,873 0,889 0,795 0,873 all parameters except minimum speed 67,9% We also calculated statistical measures of the performance of a binary classification test -sensitivity and specificity.Sensitivity is intuitively the ability of the classifier to find all the positive samples.It refers to the test's ability to correctly detect ill patients who do have the condition.Mathematically, this can also be written as: tp is the number of true positives and fn the number of false negatives.The results are shown in table 6. all parameters except minimum speed 76% Specificity is intuitively the ability of the classifier not to label as positive a sample that is negative.It relates to the test's ability to correctly reject healthy patients without a condition.. Mathematically, this can be expressed as: where tn is number of true negatives and fp the number of false positives.The results are shown in table 7. all parameters except minimum speed 76% We also plotted a decision tree built from the handwriting parameters.Figure 1 depicts the decision tree generated from the entire dataset (55 parameters).The tree visualization shows that the minimum speed parameter is dominant.However, the decision tree does not contain any other parameter except the minimum speed, which is not very correct.That is why we have chosen to remove this parameter from the dataset and to build another tree.In the same way, we plotted a decision tree containing all parameters except the minimum speed (a dataset consisting of 54 parameters).This tree is shown in figure 2. In this case, the classifier points to the total writing time as the most dominant parameter.

CONCLUSION
In the current study, we extracted basic handwriting features from samples of handwriting obtained by a digital tablet.The handwriting features provided by control subjects were compared with those of dysgraphic subjects in order to confirm the difference in handwriting.Individual parameters of the evaluation of handwriting have been calculated and also visualized using the Python programming language.Above the extracted handwriting parameters, we determined classification using the decision tree classifier.This helped us find the dominant parameter, in our case it was the minimum writing speed.By computing the classifier's success, we found that the data is classified into classes (healthy/damaged) with an accuracy of 83.4% If we determined the classification according to the dominant parameter only, we would achieve a success rate of 93.9%.Conversely, if we did not have the minimum speed parameter available, the classification success would fall to 67.9%.We also calculated classification function for sensitivity and specificity, which can correctly detect ill, respectively reject healthy patients.The success of the sensitivity calculation in the classification for a set of all parameters was 84%.But we obtained the best sensitivity results when calculating only the dominant parameter -89%.When calculating without a minimum speed parameter, the success rate was 76%.We did the same calculations for the specificity.The success of the specifiticy for all parameters was 85%, calculation with only a minimum speed parameter was 90% and calculation of all parameters except minimum speed was 76%.The obtained parameters were also subjected to statistical testing by the Mann-Whitney U test.The test confirmed the hypothesis that the handwriting of control subjects is statistically different from the handwriting of people with dysgraphia.From the calculated significance levels, we found that the most significant difference between the control subjects and the test subjects was in time parameters, as well as in the case of materiality levels.After examining the individual parameters, we can confirm the difference in the handwriting of people with dysgraphia and people without handwriting impaires.The results show that people with dysgraphia write more slowly and need much more time to write the same task than the healthy individuals.Likewise, people with dysgraphia perform excessively long strokes during writing.Further research is intended to focus on the calculation of a larger number of samples and to create a classification with the various other classifiers (e.g. using the support vector machine [20], random forest method or neural networks [21]), to optimize the results.It is also is intended to compare the results from classifiers with the results of statistical testing, e.g. using Bonferroni correction or Mann-Whitney U test.

Fig. 1 Fig. 2
Fig. 1 Visualization of the decision tree plotted from all parameters

Table 1
Sample parameters

Table 2
Results of significance levels for time parameters

Table 3
x ) p(d y ) p(pressure)

Table 4
Results of significance levels for kinematics parameters

Table 5
Results of classification accuracy using decision trees method

Table 6
Results of classification sensitivity using decision trees method

Table 7
Results of classification specificity using decision trees method