Welcome Guest, you are in: Login

EventIDE Wiki

RSSRSS

Navigation




Search the wiki


PoweredBy

Page History: Proxy Variables

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: 2012/05/09 06:59


Proxy variables are short-cut labels that can be created for selected properties of events and elements. Being created, each proxy variable automatically becomes accessible as a global variable in all code snippets. This allows to read and modify a status of any EventIDE object status at runtime. There is also another class of proxy variables that are defined by user in the Header snippet. Both types of proxy variables are only type of variables that can be used for data binding on the status screen in order to create a dynamic content.


Description

At the design-time any property of EventIDE events and elements can be set via the property panel, for example, the black can be chosen as the background color of the currently selected event. The property value, shown in the property panel, is used at the start of an experiment. However, in many scenarios it is also desirable to change object properties at runtime under a control of user code. For example, you may want to show either green or red text depending on correctness of participant's response. Since an experiment can contain many events and elements a virtual path to modify the Font Color property of the particular Text element may look like this:
[Main Experiment Event].[Feedback Event].[Message Text Element].[Font Color]=new stColor(255,0,0);
Such path is too verbose, difficult to read and and even exhausting to type. EventIDE offers a mechanism of the proxy variables to solve this problem - short-cut labels can be created always for a selected properties of events and elements. In code snippets the proxy variables can be automatically accessed as global variables with a type that matches to the type of underlying property. Then the above code string becomes shorter:
FeedbackMessageColor=new stColor(255,0,0);
or even shorter if you prefer a 'spartan' coding style:
fmc=new stColor(255,0,0);
Note that stColor is a built-in type in EventIDE for color representation Proxy variables are allowed not for all properties. For example, the proxies are not allowed for properties that have the 'Design-time Only' usage attribute, like the event title. Also, the proxy variables normally cannot be to created for properties that defines various hardware settings, like the port number.

Proxy variables types

EventIDE allows to create four different types of proxy variables.

Single Proxy variable

This type of proxy variables is the most common - a proxy gets linked to a selected property of single EventIDE object.

Proxy array variable

This type of proxy variables is an indexed array that contains several proxy variables, linked to the same property on different objects. The linked objects must be of the same type. The proxy array variable is convenient for enumeration operations in code snippets, e.g. changing the screen positions of multiple targets:
for (int i=0;i<TargetPosition.Length;i++) /// TargetPosition is an array proxy variable
  {
  TargetPosition[i].X=i*10; 
  TargetPosition[i].Y=368;  
  }

Proxy hub variable

User proxy variable



Even a simple experiment

The proxy variables However, if you wish, you can also change the properties values at the runtime, while the experiment is in the progress. For that purpose you have to create the parameters for all properties selected for possible runtime changes. It's simular to assigning a unique global name or label to the particular propety of the particular element or event. With such name any property becomes accessible in across all code snippets as a single global variable. Now you can read and modify its value at any moment.

All created parameters are listed in the Parameter panel located in the second tab at the right of the main EventIDE screen. Any parameter, if there is no plan for its further use, can be removed from this list. It's not true ony for several default parameters that exist in any experiment from the start.

Parameters allow you to specify the experimental conditions, and amend many of the properties of an element on a trial-by-trial basis. If a property of an element is selected, navigating to the Parameter tab on the main menu will allow you to create a new parameter, or merely selecting the small cross that appears when the property is selected.

Figure 1

Practical Use

Single Parameters

A single parameter is the simplest option and is used to change the parameters of a single element’s property (such as the size or color of an image). Once the parameter has been created and given a unique name, it is necessary to write the appropriate code in the appropriate snippets box, detailing under which conditions, the parameter will take which values. Parameters are often manipulated by predefined random number generators and it is of course necessary to set the limits of this random number generator (see Roulette) as appropriate. Once the possible numbers that could be generated are known, it is necessary to set the values of the parameter relating to each of these outcomes. For example if an experiment uses visual stimuli that could be any one of three colors in any trial, we would have pre-defined our random number generator (using the Main Factors option - see Roulette) to be limited to randomly generating the numbers 1,2 or 3 a fixed amount of times in each block. We would then need to write some code in the snippets, before presentation of the stimulus, stating what the parameter values should be for each of these possible numbers. For example if we have defined the property color of our stimulus element to be the unique parameter "SColor" we would need to write:

if (rNumber==1)
SColor.GDIColor=Color.White;

if (rNumber==2)
SColor.GDIColor=Color.Blue;

if (rNumber==1)
SColor.GDIColor=Color.Black; 

Colors can be defined as either GDI or RGB values – see section (_).

Parameter Arrays

Often it is necessary to change the same property parameters of a number of different elements, at the same time. For example a visual stimulus may consist of three different image elements which can each take on one of three colors. Often in a design of this type it is necessary to have all possible combinations of colors of the three images and a multi-parameter array will allow the easy manipulation of these conditions.

In order to create a multi-parameter array it is necessary to use the pinning function. First navigate to the layer and event window where the first of your elements which you wish to include in the array resides. You can then select the relevant element from the left hand side of the window. Once the element is selected, the property list will be shown on the right hand side of the window and just above this list, a tick box next to the word pinned (see figure 2). Ensure that this tick box is selected, navigate to the next element and repeat this pinning procedure until all the appropriate elements are pinned. Only properties that are common to all the pinned elements can be selected to make a multi-parameter array (See figure 2). Once all the elements are pinned, then the multi-parameter array can be created by either selecting the relevant property to be manipulated and navigating to the Parameters tab and selecting Add as Multi-parameter array or by selecting the small cross that appears when the property is selected (see Figure 2).

Figure 2

The elements that have already been pinned are visible above the properties list. Selecting the property ‘Rotation Angle’ and clicking on the small cross prompts the user to create a multi-parameter array. A previously created multi-parameter array is also visible ‘ColorMask. It can be identified as a multi-parameter array and not merely a single parameter by the 0 after the parameter name.

Once a multiparameter array has been created and named, each of the elements involved will now have the multi-parameter name followed by a unique array number sitting next to the relevant property (see the ColorMask example in Figure 2).

As in the case of the single parameter it is necessary to write the appropriate code in the appropriate snippets box, detailing under which conditions, the parameter will take which values. Parameters are often manipulated by predefined random number generators and it is of course necessary to set the limits of this random number generator (see Roulette Element) as appropriate. Once the possible numbers that could be generated are known, it is necessary to set the values of each of the parameter arrays relating to each of these outcomes. For example if an experiment uses visual stimuli consisting of three elements that could be any one of three colors in any trial, we would have pre-defined our random number generator (using the Main Factors option) to be limited to randomly generating the numbers 1,2 or 3 a fixed amount of times in each block. We would then need to write some code in the snippets, before presentation of the stimulus, stating what the multi-parameter array values should be for each of these possible numbers. For example if we have defined the property ‘color’ of our three stimulus element to be the multi-parameter array ‘SColor’ we would need to write:

if (rNumber==1)
SColor[0].GDIColor=Color.White;
SColor[1] .GDIColor=Color.Blue;
SColor[2].GDIColor=Color.Black;

if (rNumber==2)
SColor[1].GDIColor=Color.White;
SColor[2] .GDIColor=Color.Blue;
SColor[0].GDIColor=Color.Balck;

if (rNumber==3)
SColor[2].GDIColor=Color.White;
SColor[0] .GDIColor=Color.Blue;
SColor[1].GDIColor=Color.Balck; 

This code would ensure that the three element’s properties take on the appropriate values as required given the experimental conditions.

Multi-Parameter Pool

The multi-parameter pool function creates a single point of manipulation for a shared property of different events. If the experimental design requires that the same visual stimulus is used in different events, the color of this stimulus can be manipulated across events with a single line of code.

In order to create a multi-parameter pool it is necessary to use the pinning function. First navigate to the layer and event window where the first of your elements which you wish to include in the array resides. You can then select the relevant element from the left hand side of the window. Once the element is selected, the property list will be shown on the right hand side of the window and just above this list, a tick box next to the word pinned (see figure 3). Ensure that this tick box is selected, navigate to the next element and repeat this pinning procedure until all the appropriate elements are pinned. Only properties that are common to all the pinned elements can be selected to make a multi-parameter pool (See figure 3). Once all the elements are pinned, then the multi-parameter pool can be created by either selecting the relevant property to be pooled and navigating to the Parameters tab and selecting Add as Multi-parameter pool or by selecting the small cross that appears when the property is selected (see Figure 3). It is not possible to create a multi-parameter pool from read-only values (such as statistical properties).

Once the pool has been created, changing the value of this property for one element, will change it for all. A more systematic manipulation can be employed by writing the appropriate code in the appropriate snippets box detailing under which conditions, the parameter pool will take which values. Parameters are often manipulated depending on the number of levels of an experimental factor. These different levels are then generated by predefined random number generators and it is of course necessary to set the limits of this random number generator (see Roulette) as appropriate. Once the possible numbers that could be generated are known, it is necessary to set the values of the parameter pool relating to each of these outcomes. For example if an experiment uses the same visual stimuli across a number of events that could be any one of three colors in any trial, we would have pre-defined our random number generator (using the Main Factors option) to be limited to randomly generating the numbers 1,2 or 3 a fixed amount of times in each block. We would then need to write some code in the snippets, before presentation of the stimulus, stating what the pool values should be for each of these possible numbers. For example if we have defined the property Position of our pooled elements to be the multi-parameter pool ‘SPosition’ we would need to write:

if (rNumber==1)
SPosition =

if (rNumber==2)
SPosition =

if (rNumber==1)
SPosition =

This code will ensure that the stimuli is repositioned as appropriate across all events, without the need to code it for each individual event.

ScrewTurn Wiki version 5.2.0.8. Some of the icons created by FamFamFam.