How to Combine Multiple Scripts

Often a study will involve administering multiple measures to each participant. For example, a study might administer an IAT, a direct measure of attitude, and a demographic questionnaire, or it may require that 2 different IAT tasks be administered. Inquisit places no constraints on the number of measures that can included in a single script. However, for a number of reasons, it is often more convenient for each measure to be defined in its own script. For example, putting all of the measures in a single file may result in a large and unwieldy script. Also, in many cases each of the measures already exists as a separate script anyway.

Inquisit provides two mechanisms for combining different scripts into a single data collection session, the <batch> element and the <include> element.

The <batch> Element

The batch element provides a simple way of running a set of scripts in sequence. To use the batch element, create new empty script file that will contain only the batch element definition and no other commands:

/ file = "IAT1.iqx"
/ file = "IAT2.iqx"
/ file = "IAT3.iqx" </batch>

As you can see from this example, the batch element is really just a list of the script files you wish to run. In the above example, three IAT scripts are listed, IAT1.iqx, IAT2.iqx, and IAT3.iqx. As you might have guessed, the batch runs each of these scripts in the order they are listed. To run the batch, simpy open the script file that contains the batch element definition in Inquisit, and select the Run command from the Experiment menu. You will be prompted for a subject id, after which each script is run in sequence. Data from each script are saved in separate files, and the same subject id is used for each file. To use the batch element with Inquisit Web, simply register the script containing the batch element, and then upload the other scripts to the web server. With the Web, the data are also saved in different files using the same subject id.

The batch file is very easy to use, but it does have some limitations. Most notably, there is currently no built in way to randomize the order in which the scripts are run (this is true as of version, but the feature is planned for a future release). If you are using the lab version of Inquisit, you can create multiple batch files, each of which contains a different ordering, and then randomly assign participants to one of those batch files. With the Web, this technique would require you to register multiple batch scripts, each of which would require a separate license. For web experiments requiring randomized ordering, the <include> element described below is likely a better option.

The <include> Element

The include element provides a convenient way to "copy and paste" elements from one script into another script without requiring you to go through the hastle of actually copying and pasting. It therefore can serve as a useful tool for combining measures defined in separate scripts, although typically the scripts will have to be modified somewhat in order to combine properly.

As an example, let's say we wish to run two IAT measures, randomly varying the order. We could arbitrarily choose either IAT script and add the include element to it. However, in order to make it easier to reuse this solution with other scripts (containing IATs or other measures), we'll start with a new empty file and then add our include definition to it:

/ file = "IAT1.iqx"
/ file = "IAT2.iqx" </include>

In the above example, we've included two different scripts, IAT1.iqx and IAT2.iqx. The order in which they are listed doesn't matter. Conceptually, we now have a single virtual script that contains all of the element definitions contained in IAT1.iqx and IAT2.iqx. If you try to run the script, however, you'll notice a whole bunch of errors. This is because both scripts use the same names for elements. They also both include definitions of global elements such as <data>, <defaults>, <values>, <variables>, and <expressions>, so Inquisit will report an error stating that these elements have been defined more than once.

The first step in resolving these errors is to put a single copy of the global elements in our include script, and remove these element definitions from both of the IAT scripts. The global elements to add to our include script and remove from our IAT scripts are as follows:

/ fontstyle = ("Arial", 3.5%)
/ screencolor = (0,0,0)
/ txbgcolor = (0,0,0)
/ txcolor = (255, 255, 255)
/ minimumversion = ""

/ columns = [date, time, subject, blockcode, blocknum, trialcode, trialnum, response,
  correct, latency, stimulusnumber, stimulusitem, expressions.da, expressions.db,
  expressions.d ]

/ latencydistribution = normal(500, 100)
/ percentcorrect = 90

/ sum1a = 0
/ sum2a = 0
/ sum1b = 0
/ sum2b = 0
/ n1a = 0
/ n2a = 0
/ n1b = 0
/ n2b = 0
/ ss1a = 0
/ ss2a = 0
/ ss1b = 0
/ ss2b = 0
/ magnitude = "unknown"

/ m1a = values.sum1a
/ values.n1a
/ m2a = values.sum2a
/ values.n2a
/ m1b = values.sum1b
/ values.n1b
/ m2b = values.sum2b
/ values.n2b
/ sd1a = sqrt((values.ss1a - (values.n1a * (expressions.m1a * expressions.m1a))) / (values.n1a - 1))
/ sd2a = sqrt((values.ss2a - (values.n2a * (expressions.m2a * expressions.m2a))) / (values.n2a - 1))
/ sd1b = sqrt((values.ss1b - (values.n1b * (expressions.m1b * expressions.m1b))) / (values.n1b - 1))
/ sd2b = sqrt((values.ss2b - (values.n2b * (expressions.m2b * expressions.m2b))) / (values.n2b - 1))
/ sda = sqrt((((values.n1a - 1) * (expressions.sd1a * expressions.sd1a) + (values.n2a - 1) * (expressions.sd2a * expressions.sd2a)) + ((values.n1a + values.n2a) * ((expressions.m1a - expressions.m2a) * (expressions.m1a - expressions.m2a)) / 4) ) / (values.n1a + values.n2a - 1) )
/ sdb = sqrt((((values.n1b - 1) * (expressions.sd1b * expressions.sd1b) + (values.n2b - 1) * (expressions.sd2b * expressions.sd2b)) + ((values.n1b + values.n2b) * ((expressions.m1b - expressions.m2b) * (expressions.m1b - expressions.m2b)) / 4) ) / (values.n1b + values.n2b - 1) )
/ da = (m2a - m1a) / expressions.sda / db = (m2b - m1b) / expressions.sdb
/ d = (expressions.da + expressions.db) / 2
/ preferred = "unknown"
/ notpreferred = "unknown"

The next step is to rename all of the blocks, trials, stimuli, and stimulus items in both IAT scripts so that they are all unique. In our case, we'll simply add an "iat1" to beginning of all of the names in the IAT1.iqx script, and "iat2" to the beginning of all of the names in the IAT2.iqx script. Thus, the blocks named "targetcompatiblepractice" becomes "iat1targetcompatiblepractice" and "iat2targetcompatiblepractice". The text stimulus named "instructions" becomes "iat1instructions" and "iat2instructions". The trial named "iat1summary" and "iat2summary". And so forth. Note that you will need to update the parts of each script that refer to these elements as well. For example, iat1summary trial contains the command / stimulustimes = [0=summary], which must be changed to / stimulustimes = [0=iat1summary].

The element responsible for running our IATs is the <expt>element, so we'll next need to remove these element definitions from the IAT scripts and rewrite them in our include script so that they run the blocks of each of our IATs. After we delete these elements from the IAT scripts, we'll add the following element definition to the include scripts.

/ subjects = (1 of 4)
/ blocks = [1=iat1targetcompatiblepractice; 2=iat1attributepractice; 3=iat1compatibletest1;
4=iat1compatibletestinstructions; 5=iat1compatibletest2; 6=iat1targetincompatiblepractice;
7=iat1incompatibletest1; 8=iat1incompatibletestinstructions; 9=iat1incompatibletest2;
10=iat1summary; 11=iat2targetcompatiblepractice; 12=iat2attributepractice; 13=iat2compatibletest1;
14=iat2compatibletestinstructions; 15=iat2compatibletest2; 16=iat2targetincompatiblepractice;
17=iat2incompatibletest1; 18=iat2incompatibletestinstructions; 19=iat2incompatibletest2;
20=iat2summary ]

The above experiment runs IAT1 first and IAT2 second. In both cases, the compatible parings are applied before the incompatible parings.

The next expt element reverses the order of the IATs.

/ subjects = (2 of 4)
/ blocks = [1=iat2targetcompatiblepractice; 2=iat2attributepractice; 3=iat2compatibletest1;
4=iat2compatibletestinstructions; 5=iat2compatibletest2; 6=iat2targetincompatiblepractice;
7=iat2incompatibletest1; 8=iat2incompatibletestinstructions; 9=iat2incompatibletest2;
10=iat2summary; 11=iat1targetcompatiblepractice; 12=iat1attributepractice; 13=iat1compatibletest1;
14=iat1compatibletestinstructions; 15=iat1compatibletest2; 16=iat1targetincompatiblepractice;
17=iat1incompatibletest1; 18=iat1incompatibletestinstructions; 19=iat1incompatibletest2;
20=iat1summary ]

The next expt element runs IAT1 first and IAT2 second, but incompatible pairings are used first, and incompatible pairings second.

/ subjects = (3 of 4)
/ blocks = [1=iat1targetincompatiblepractice; 2=iat1attributepractice; 3=iat1incompatibletest1;
4=iat1incompatibletestinstructions; 5=iat1inccompatibletest2; 6=iat1targetcompatiblepractice;
7=iat1compatibletest1; 8=iat1compatibletestinstructions; 9=iat1compatibletest2;
10=iat1summary; 11=iat2targetincompatiblepractice; 12=iat2attributepractice; 13=iat2incompatibletest1;
14=iat2incompatibletestinstructions; 15=iat2incompatibletest2; 16=iat2targetcompatiblepractice;
17=iat2compatibletest1; 18=iat2compatibletestinstructions; 19=iat2compatibletest2;
20=iat2summary ]

Finally, the last expt element runs IAT2 first and IAT1 second, with incompatible pairings first, and incompatible pairings second.

/ subjects = (4 of 4)
/ blocks = [1=iat2targetincompatiblepractice; 2=iat2attributepractice; 3=iat2incompatibletest1;
4=iat2incompatibletestinstructions; 5=iat2inccompatibletest2; 6=iat2targetcompatiblepractice;
7=iat2compatibletest1; 8=iat2compatibletestinstructions; 9=iat2compatibletest2;
10=iat2summary; 11=iat1targetincompatiblepractice; 12=iat1attributepractice; 13=iat1incompatibletest1;
14=iat1incompatibletestinstructions; 15=iat1incompatibletest2; 16=iat1targetcompatiblepractice;
17=iat1compatibletest1; 18=iat1compatibletestinstructions; 19=iat1compatibletest2;
20=iat1summary ]

Note the /subjects command in each <expt> element determines which conditions a participant is assigned to based on the subject number. Subjects 1, 5, 9, 13, etc are assigned to the first expt element, 2, 6, 10, 14, etc. to the second, 3, 7, 11, 15, etc. to the third, and 4, 8, 12, 16, etc. are assigned to the fourth expt element.

To run the script with Inquisit Lab, simply open the script containing the include element and select the Run command from the Experiment menu. To run it with Inquisit Web, register the script with the include element, and upoad the other two scripts to the server.