Tetris

Summary


Adjusting a game of Tetris from open source code to fit the needs of an fMRI research experiment to run both on the browser and as a desktop application.

Introduction


This was a part of an internship at a neuroimaging lab for a project researching neuronal plasticity - the ability of the brain to adapt to experiences and learning of skills. The aim of this project was to implement a cognitively challenging task to assess neuronal activation with functional MRI (fMRI) as part of a larger clinical investigation that will assess neuronal plasticity induced by regular training. Tetris® was chosen as the cognitive paradigm because it is a challenging task, which demands planning, mental rotation, problem solving as well as rapid visuo-spatial and motor coordination from the participant. Previously, it has been shown that Tetris® evokes changes in neural activation [1] and can enhance the performance of related tasks involving mental rotation [2]. There was no paradigm available for neuroimaging applications and the question was how the brain adapts to continuous training of this task.

The original Tetris® game from 1989.

The problem


Participants of the experiment had the task of playing the game first while lying down in an fMRI machine, using a very simple controller, and then at home, on their own computers in the browser, using a keyboard. Since the game played in the fMRI was supposed to be full screen and save the data on the computer in the lab, using a browser application was not a good option. The web version had a starting page with some information for the participants, was sending log data to a server, and had a questionnaire in the end. Additional complexity was added by having to make 3 slightly different versions of the game for desktop for the requirements of the experiment.
As this was a part time internship for 4 months, with half of that time reserved for other tasks that included running a pilot experiment and data analysis of gathered data, the actual time to develop the game, test it and document it, was equivalent to one month of full time work. I was the sole person working on the game implementation with some help regarding UX from the researchers.

The process


After some research I discovered the Electron library which makes it possible to build cross-platform desktop applications with HTML, CSS, and JavaScript. This would allow for implementing the game just once with the web technologies and then have it run also on desktop. This almost halved the time needed to implement the project, however, the rest of the time still seemed a bit short to implement and test all the features that would be needed. This is why I decided to look for an open source implementation of the game in HTML, CSS, and JavaScript, which I would then adjust for the purposes of the experiment. I have managed to find one that fitted the basic needs and to build upon it. The experiment required 3 versions of the game: easy, hard and control. The hard one has the same logic as the easy one but starts from a higher level. The control one was supposed to provide some elements for the original game of Tetris(TM) but not all of them. This was also part of the problem that I needed to solve in consultation with the research scientist on the project. The control version in research projects is used as a base case to which the other cases are compared in order to draw some conclusion, it cannot be nothing as the participants need to be somewhat involved but they shouldn’t be too involved. The control condition has two gray columns with a space between them and the subject simply has to navigate the bricks through that space, without the need to fill the rows.

The controls


The controller that can be used in the fMRI machine is shown on picture 1. There isn’t much space in an fMRI machine for movement, and in general a lot of movement is not good for recording the brain images, so the controller is positioned either on the side of the person or on their lab (based on individual preferences), and it can be controlled only with one hand. Because of that the controls for the web version of the game that participants play at home had to be adjusted. Instead of using the arrows for movement and some button (usually space) for rotation, we had to choose 4 keys that are next to each other. The choice is shown on picture 2, it’s based on a standard german keyboard (the study was conducted in Vienna, Austria with german speaking participants). The reason why the controllers should have been adjusted is because the participants were tested for changes invoked by learning a skill so conditions should be as similar as possible.

Controllers
Keys

The outcome


The final results are a web and a desktop version. The web version is a website where participants can log in, read instructions, choose the difficulty of a game, see their previous score, and in the end answer a questionnaire. The desktop is an application that runs a predefined sequence of the 3 versions (easy, hard, and control) of the game. Both versions log the version of the game played and time and value for every score made, every brick appearance, every row cleared, every start and end of the game.

Easy version
Hard version
Control version

Tools and skills


UX, research, JavaScript, HTML/CSS, Electron, PHP, documentation