MatRPC

MatRPC is an application written in C. It compiles on Linux (gcc version 3.2.3) and uses POSIX threads and Matlab 6.5.1 Engine libraries. Although the application currently compiles only on Linux, the source is largely platform independent. It should be possible to port it to other platforms and Matlab versions with a modest effort.

MatRPC sends and receives messages via TCP/IP network sockets. A TCP/IP socket is a mechanism by which messages are passed between two applications on the same computer or two different computers on a network. MatRPC only supports messages which are passed as strings. Each string sent to MatRPC includes a session identifier and a Matlab function along with its function arguments. The only Matlab functions currently supported are those which return a single string. When a message containing a new session identifier is sent to MatRPC, a Matlab engine is created using the routines provided in the Matlab API. Matlab engines operate in a similar fashion to Matlab workspaces insofar that each engine has its own variable space. However, no user console is provided and the engines are controlled by the daemon. When a new call to MatRPC repeats a session identifier, the same Matlab engine is called. The session identifier sent to MatRPC is identical to the session ID field used in the MySQL database, thereby ensuring that each is unique and providing a straightforward method to match a QPI session to a Matlab engine instance. The Matlab function is called through the engine and the result is sent back to the QPI, which interprets the returned string to play a stimulus, present a break, or skip a series of forms.

During presentation, a QPI form handler associated with one of the forms in the loop calls the Matlab function through MatRPC and a stimulus ID is returned as a string. The form handler queries the database for the path and filename of the stimulus based on the stimulus ID, then passes this information to the Flash player to present the stimulus before presenting the questions associated with the form. After a specified number of stimuli have been presented, the Matlab function returns the string "break," which signals the form handler to present an instruction to the participant to take a break if desired. The form handler presents the participant with a button to continue with the experiment when ready. The Matlab function continues to return stimulus IDs and "break" strings until all of the stimuli have been presented for the session. Once finished with stimuli, the Matlab function returns the string "end," signaling the form handler to skip a number of forms defined in the form handler to break out of the loop.

MatRPC was developed so that researchers would not have to write real-time analysis scripts in PHP. However, Matlab and MatRPC are not required in order to use most of the features in the rest of Ensemble, and most of the more sophisticated logic for which Matlab is used could be written in PHP or an alternative scripting language.

bottom corner