Skip to main content
. 2020 Oct 9;20(20):5741. doi: 10.3390/s20205741
Algorithm 2 Generation of an emotion-representing animation
Input: a sequence of n brain wave samples s1, s2, …, sn sent to the server in a duration of 5 s with each sample si consisting of the two features of attention and meditation represented by the variables ai and mi, respectively, i.e., si = (ai, mi).
//The input is the same as that of Algorithm 1 except that the time duration is 5 s instead of 20 s
Output: an animation with its scenario being composed by multimedia techniques according to Table 3, representing one of the emotion types of focusing, relaxation, calmness, and anxiety, which appears most frequently during the period of 5 s.
Steps.
Step 1: //Initialization
 1.1 denote the four emotion types of focusing, relaxation, calmness, and anxiety by Fi, Ri, Ci, and Ai, respectively;
 1.2 set up four counters Ftotal, Ttotal, Ctotal, and Atotal for Fi, Ri, Ci, and Ai, respectively.
Step 2: //Classifying the brain waves
for i = 1 to n do
  (a) classify si = (ai, mi) as one of Fi, Ri, Ci, and Ai according to rules specified by Equation (1), and denote the result by Xi;
  (b) increment the counters according to Xi in the following way: //Computing sums
   (i) if Xi = Fi, then set Ftotal = Ftotal + 1;
    end if; //Ftotal = # blue samples
   (ii) if Xi = Ri, then set Rtotal = Rtotal + 1;
    end if; //Rtotal = # green samples
   (iii) if Xi = Ci, then set Ctotal = Ctotal + 1;
    end if; //Ctotal = # orange samples
   (iv) if Xi = Ai, then set Atotal = Atotal + 1;
    end if; //Atotal = # aubergine samples
end for.
Step 3: //Finding the emotion appearing most frequently
 3.1 find the maximum of Ftotal, Rtotal, Ctotal, and Atotal and denote it by Mtotal;
 3.2 let the emotion type corresponding Mtotal be denoted as Ttotal.
Step 4: //Creating the desired animation
 create an animation A of the emotion type Ttotal according to the scenario listed in Table 3 by multimedia techniques.
Step 5: //Ending
 exit with animation A as the desired output.