Infonnatica 23 (1999) 431-436 431 Conceptual Interactive Learning Tools Based on Computer Simulators Damjan Zazula, Bogdan Viher, Dean Korošec, Enis Avdičauševič, Mitja Lenič, Božidar Potočnik University of Maribor, Facuhy of Electrical Engineering and Computer Science Smetanova 17,2000 Maribor, Slovenia Phone: + 386 62 220 7480, Fax: + 386 62 211 178 E-mail: zazula@uni-mb.si Keywords: modelling and simulation, conceptual learning, client-server, Java applets, electromyography Edited by: Rudi Mum Received: December 3, 1998 Revised: July 19, 1999 Accepted: August 18, 1999 An existent computer-based simulator may serve double purpose: simulating the basic phenomenon that was conceptuaUy modelled by the simulator, and offeringits inherent teaching characteristics at the'same tirne. In this paper, we describe shortly the basic concepts ofa simulator of electromyographic signals (EMGs), which was, first, written for a single-user environment in C++ and later ported to Java and In­teractive network environment. At this stage it became natural that the Java application was upgraded by the features ofa teaching and learning tool. Such an integration was possible in a client-server approach providing the network users with a compact facility for generating the EMG components and signals, and learning about the electro-physiologicalphenomena in parallel. Introduction The world-wide accessibility of the Internet applications has recently opened a new prospective of the computer-supported processing and dissemination of Information. In­teraction has become a basic rule moving frontiers out of the local computer, out of the local community. At the same time, the philosophy of security and protection drew the major attention. New concepts have been developed, one of the most outstanding being the Interactive applications in Java [6], and the corresponding tools and approaches, for example the client-server cormections, three-tier archi­tecture, and applets. The simulator ofelectromyographic signals (EMGs) was under the name of EmgSim [3] developed in the System Software Laboratory at the Faculty of Electrical Engineer­ing and Computer Science in Maribor. Initially, it was written in C++ for the Windows environment. Later on, we ported it into Java as an Internet application, built in the client-server mechanism, and even added some features being characteristic for the computer-assisted educational tools. Thus, we developed an integrated environment that may contribute at different levels: - it generates artificial EMG signals whose building blocks are known in details; therefore, it plays a role of a reference to the EMG decomposition techniques [4, 5, 1], - it enables experimenting with the effects of different electro-physiological parameters on the needle- and surface-recorded EMGs [7], and - it also runs as a teaching/leaming tool of the electro­physiology of muscles. The approach will be presented briefly in this paper. Sec­tion 2 describes conceptual model of the EmgSim simula­tor, Section 3 speaks about the transformation into an In­ternet application, whilst the modifications introducing the educational elements are revealed in Section 4. 2 Simulations of electromyographic signals Contractions of muscles are accompanied by electrical ac­tivities that may be measured as an EMG, invasively by needle electrodes or non-invasively by surface electrodes. Physiologically, muscles consist of the so called fibres. Each fibre is innervated by a motoneuron transmitting the triggering electric pulses that cause the contraction of a fi­bre. In fact, one nerve iimervates several fibres that are, consequently, contracted at the same time and acting as a primary unit of force - called a motor unit (MU). Several MUs then build up the whole muscle. Looking at this structure from the electrical point of view, the activation potentials flow down from the mo­toneuron. It triggers the corresponding single fibres, which affects them with a charge spreading from the innervation zone towards the tendons. This travelling charge is mea­sured as a single-fibre potential (SFP). AH the SFPs of one MU sum up into a motor-unit potential (MUP). Sev­eral MUPs are finally superimposed and, thus, form the observed EMG (Figure 1)[7]. Our simulator conceptualIy follows the electro­physiology. Therefore, it begins first with building up a muscle. Several parameters may be specified in this stage [3], like the distribution of single fibres in the MUs, the 432 Informatica 23 (1999) 431-436 CNEMGrecordingelectrode imiscle isiKOidEdli; isasupciposnon toelettal ofSFAPj motor MUAP imits tmiiis Figure 1: The physiology of a muscle and sources of elec­trical activity - top, a model of the muscle - bottom. distribution of MUs in the muscle, the features of the fibres (their diameters), the triggering instants, etc. The principle of operation is depicted in Figure 2. The EMG simulator as an application in Java We have stated multiple advantages of today's interactive network applications. The most important in our čase are flexibility and accessibility supported by intrinsic levels of control, security and protection. This is exactly what was needed for our EMG simulator to become widely avail­able application on the Internet. Actually, the client-server link seems ideal for this purpose. On the server site, the modelling and simulation part runs with aH the calcula­tion routines, data bases, control, security and protection. Clients enter the server from their machines on a platform-independent principle (see Figure 3). If they have access rights, they may send in their requests, i.e., they may run the EMG simulator at different stages. OnIy the user-interface code is transferred to their site, where it is inter­preted and supports the windows and menu environment. However, as ali the computation is done within the server, there is a lot of data that must be transmitted to the D. Zazula et al. musde model parameters jy JL muscle model generatlon simulation of the electrode movement electrode positloning generatlon ofA P AP calculation wavefonn variatlons summation of APs for each MU random llnear transformatlon of AP \ / set of MUAP vvavefomis sImulatBd OEMG signal Figure 2: Principle of operation of the EMG simulator. users in certain stages of simulation. This could degrade the simulator performance and its responsiveness, thafs why a special data communication protocol was developed between the server and the clients. The characteristics of our Java realisation, as well as the client-server communication, will be described in the fol­lowing paragraphs. 3.1 Realisation of the server and client The client software that runs on a user's machine in Java would need more time to run the simulation. Therefore, we divided the simulator in two parts: the client written in Java for user interface, and the server written in C++ (na­tive code) for the calculation of the simulation. The client performs simple calculations and provides user interface. The server performs ali the time critical calculations. The client-server architecture has been used to speed up the simulation. The basic problem is communication over the network. If ali the clients were connected to the same instance of the server, an intemal server mechanism would have to keep trace and status of every action of individual clients. This would make the server code rather compli­cated and vulnerable. Therefore, it was worthwhile to sac­rifice a part of the server's performance by starting a new CONCEPTUAL INTERACTIVE LEARNING TOOLS . Infomiatica 23 (1999) 431^36 433 1 ; Calculation Marshaling 1 : li i • Unmarshaling if-^r '"~7r~"" 1 : • 1 : •••'""'1r-~ Server stale Compression i : j: Decompression Client siaie ,...,._.„. _ ^ 1 : -::^f::: r 1 : •"•"•'"••"•'"•"•••"•" r Conrtol ! Unmarshaling Rpci : ! V ' I-: Marshaling fl——1 Coniral —Ji. 1 ; ' : -.-, -„.. : i .. .-.,„™,™„„„ . Network interface Network interface Figure 3: The simulator structure in Java: a client-server connection. server instance for every new client, and even avoiding the solution with threads for the same reason. The simplest solution for the communication would be remote procedure calls (RPC), -vvhere there would be no need to track the status of simulation, i. e., the stage of its execution. The client would inherently employ the re­mote flinctions as demanded in the successive steps by the user. However, Java programming does not support RPCs, it is based on remote method invocation (RMI), which lacks tools for standard serialisation of data and actions. As mentioned, our solution to the server was starting new instances for every new client. The server incorporates special communication routines - deamons that use stan­dard inputs (STDI) and outputs (STDO). The STDO trans­fer of data is activated by detection of the ENTER code. One inconvenientbehaviour of the deamon is that, after the transfer is finished, terminates the connection. The action is natural in the multi-client environment, however, in our solution it is disturbing. A client and its instance of the server should stay connected and on-line aH the time. To circumvent the problem of the communication channel ter­mination, aH the server messages are sent out by flushing. On the other hand , clients call the server functions by simple strings of the following form: . As the clients are Java applets, they run under multi­threading principle. The server on the other side, which is a C program, is not able to synchronize with the order of precedence of incoming messages. Therefore, the clients communication is synchronized with the server using an in­terval monitor structure which prevents sending a message before the previous one has been completed. To reduce the amount of network communication, the client and the server must have a synchronized copy of the State of their common actions. Another problem is data format. For example, Java ušes IEEE 745 for representing floating point arithmetics. The server could also run on a Motorola, MIPS, SPARC or Intel-based machine that use diflferent floating-point representations. Therefore, the data format for the network should be in a machine independent format. That is done by marshaling/unmarshaling of the data sent or received over the netvvork (see Figure 3). Hence, the data is serialised and transfered in either di­rection in strings containing also aH the necessary Informa­tion about the original data structures (tables, vectors, etc.) and types (integers, floating point values, etc) . The amount of data sent from a client to the server is rather low. On the other hand, in the stage generating the EMG singal the server have to send out about 3 M bytes of data. It is, therefore, of crucial importance that the transfer is coded. We implemented run-time length code compres­sion based on nibbles. The compression rate achieved is 38%, onoverage. Figure 4 depicts class-hierarchy diagram considering the client-server intercormection. Solid lines in the figure show the hierarchical dependence, whereas dotted lines indicate the Information flow. Only the part depicting the client can acctually be shown in the form of class hierarchy. The server has been coded in C++, so the class hierarchy is not applicable in the same way. Nevertheless, the user inter­face in Figure 4 consists of two separated branches: one deals with user interaction, the other with data visualisa­tion. The MUDialog box stands for the parameter input on the motor units, and the SPShapeDialog box accepts pa­rameters on the action potentials. On the other hand, the EMGPanel box deals with the visualisation of the muscle structure, vvhile the MUAPsPanel takes čare of displaying the motor-unit action potentials, i.e., the EMG signals. 4 Upgrading to educational tool Once having a conceptual model in the form of a simulator, it is just a step ahead to upgrade it for educational purposes. Although a reversed order may seem more normal, i.e., to build a teaching tool and then to include the simulation ses­sions as explanations, we haven't found any dravvbacks in our approach. Moreover, it offers a two-level construction that, on the first level, acts as an extended help for the users of our simulator, on the next level, however, it enables self-evaluation. The latter is done in a typical leaming cycle: a piece of leaming material is provided, with explanations, demonstrations, graphics, diagrams, etc , then questions about the topic are asked. The answers are scored auto­matically and the results direct the user either over to the next topic or suggest repetition of some previous chapters (potentially, even some additional pages for basic compre­hension may be inserted). 434 Infomiatica 23 (1999) 431^36 D. Zazula et al. Interface for communication with server Server User interface EMGSIM Data visualisation User interaction Dialogs Presentation L^U—iL^ MUDialog EMGPanel • J APShapeDialog MUAPsPanel Figure 4: Class hierarchy: the client-server connection. The advantage of having chosen the simulator as a driv­ing engine for the leaming subroutines certainly is re­activation of the same leaming modules at any stage of the simulation run, as depicted in Figure 5. In order to extend the Internet EMG simulator as in Fig­ure 3, special program exits were inserted into the code of Java realisation. Their role can be compared to masked pro­cedure calls: the application runs with ali of its functions even if program exits are not activated. When activated, they trigger certain parallel actions which are understood as auxihary to the main operation of the application. The most important and instructive notions and steps in the simulation are elaborated additionally in separate pages of explanations an teaching material. The links are realised in terms of program exists. Each program exit has a cor­responging parameter containing the address of an HTML document vi^hich will be displayed upon a call initiated by the user pressing a button to enter the teaching/leaming procedure. There is another parameter that has special meaning. With this parameter we can switch between two types of the program exits. The first type is browser independent and it is implemented with an applet context. As we know, Java 1.1 is stili not flilly supported by browsers. Therefore we decided to implement additional program exits bound to Netscape's Internet browser. In this way, we can use appletviewer which supports Java 1.1 to run our applet, and the Netscape's brovvser to view educational documents. Hovvever, similar solution would be possible with Internet Explorer as well. Every such a program exit calls the indicated HTML document that may contain any necessary educa­tional/explanation contents, supported by aH the available relevant Information, either locally or over the Internet con­nections. This may include texts, voice, static images, ta­bles, graphs, or movies. Aftenvards, a self-evaluation procedure is entered by a special button. It consists of three stages: - questions on the topics presented, - answers typed in the pre-prepared forms, and - an automatic evaluation of the answers. 4.1 Concept of the question-answer engine The first two stages are more or less straightfonvard. The questions are sequentially numbered and insertet at the end of the HTML pages that are activated through the simulator CONCEPTUAL INTERACTIVE LEARNING TOOLS .. . Infomiatica 23 (1999) 431-436 435 Text, Teachning images, unit o n movie s chosen topic Questions Additional explanation Ans^vvers wron g Database of correct and Statistics •vvrong reply phrases Figure 5: Block diagram of the simulator upgrading to a teaching/leaming tool. program exits. Dialog windows followning the questions receive the typed in answers. The entered answer links to an evaluation CGI (Common Gateway Interface) script di­rectly from HTML. Such scripts enable execution of appli­cations being called from the HTML documents. For the time being, our question-answer engine classifies ansvvers as false or correct only. This is done with the help of a database containing sets of the words and phrases of possi­ble correct and false answers in the following format: :< elemnts of possibly correct answers>:< elements ofpossibly wrong answers>. The computer-assisted evaluation of the ansvvers is, how­ever, not an easy task. If we wanted to have it universal and complete, we would need a thorough base of grammatical, syntactical and semantic rules for every teaching/leaming language. At the present stage of development, we have simplified these demands considerably. The ansvvers are parsed to the individual words. The words and word groups are, aftenvards, compared to two lists of phrases. These lists are linked with the correspond­ing question. One list contains typical correct words and phrases, the other typical wrong words and phrases. Ac­cording to the score achieved in both lists, every answer is treated either correct or wrong. For each question, the user/teacher has to prepare and enter a target path (the document which contains the ques­tion), a question, a list of correct answers, a list of wrong ansvvers, and a path to the next question in chain. This is realised by another CGI script. The target path is an abso­lute path in the file system, the path of the next document in chain is relative to the HTTP server. A blank field for the next question terminates the chain. After having been submitted, a new record is written to the database and the target document is generated. Each question has unique ID (a sequential number) which links it to corresponding record in the database. The generated document contains the question and a field for answer. Submitted answer is evaluated and a new document is generated, containing the evaluation score and a link to the next question in chain, although the entered answer may have been incorrect. 5 Conclusion The described solution could mean a universal approach to upgradings of netvvork versions of simulators. The nec­essary change in the simulator code is minimum, actually it means only inserting a stmple routine to load HTML documents for additional explanation and activatrng the question-answer engine. The latter runs quite independent of the application and, therefore, can be developed and 436 Informatica 23 (1999) 431-436 D. Zazula et al. treated stand alone once for ali the applications using it. Acknowledgemeiit This work was supported by an HP Labs donation of work­stations and by a grant of the Slovenian Ministry of Science and Technology, Contact No. L2-8834, to the Centre for In­teractive Network Applications at the Faculty of Electrical Engineering and Computer Science in Maribor. References [1] Korošec D., Martinez C , Zazula D., "Parametric modelling of EMG signals," lEEEEMBS, Amsterdam 1996, 2 pp. [2] Roeleveld K., Siirface motor unit potenlials; the building stones ofsurface electromyography, PhD Thesis, Katholieke Universiteit Nijmegen, The Netherlands, 1994. [3] Viher B., Korošec D., Zazula D., "Computer simulator of elec­tromyographic signal," CBMS '96, Ann Arbor 1996, pp. 47-52. [4] Zazula D., Korže D., Šoštarič A., Korošec D., "Study of meth­ods for decomposition of superimposed signals vvith application to eIectromyograms," in: Pedotti et al. (Eds.), Neuroprosthetics, Springer Berlin 1996, pp. 377-389. [5] Zazula D., Korošec D., Šoštarič A., "Parametric decomposition of the SEMG," Proceedings ofthe SENIAM Vforkshop, Nijmegen, The Netherlands 1998. [6] Horstmann C. S., Comell G., Core Java Votume 11 -Advanced Fea­tures, Sun Microsystems Press, USA, 1998. [7] Stalberg E., Trontelj J. V., Single Fiber Electmmyography, Raven Press, Nevv York, 1979.