randomization

Is it possible to make randomization of 4 items without item repetation? for exp: 1-2-3-4 -1-3-4-1-…

It seems in SL without item repetation is not possible:confused:

There are two ways you could do this:

  1. create four events in a trial. Randomize the events in the trial.

  2. create four trials in a block. Randomize the trials in the block. This is the approach that stimulus lists take: a new trial is created for each stimulus. The proper way to randomize a stimulus list is to randomize the trials in the block. Stimulus lists themselves cannot be randomized.

But the problem is:

For example, one trial ends with stimulus 4, then sometimes the next trial begins also with 4…

Within and between the trials there can be no repeats (eg, -1-1 or -2-2-), and no
“salients” such as “1-2-3-4”

The randomization for the events in trials is possible, or randomization of the trials in blocks…But is it also possible to hinder that the next trial does not begin with the last item of the previous trail?

The randomizer does not take previous randomizations into account, so this isn’t possible in SuperLab 4.

External randomization

You could try the following:

(1) Set the experiment up so that each trial consumes four items from the same image-file stimulus list. Do not specify any randomization within SuperLab.

(2) Externally to SuperLab, come up with a “good” randomization of the four image files, using a shell script or some other method.

(3) In Superlab, open the stimulus list editor and copy/paste the pre-randomized list.

If you need multiple random orders, or if you need a new one for each subject, you’ll have to go through the randomize/copy/paste sequence each time, either in the same experiment, or in a copy of the experiment. What I mean is, you’ll need to delete the old order and paste in the new one each time.

Sometimes a good compromise is to have several randomizations (say, 4 or 5 different ones) prepared in advance, to which subjects are assigned randomly.

The above method only works for the images, it will not work directly if you need to randomize the screen locations too. However, you could do this as well, if you use an image editor to pre-position the images within a larger background-colored frame. That trick will allow you to have control over both the order, the image, and the position, using external randomization and copy/paste.

Greg Shenaut (another Superlab user)

Dear Greg,
thanks a lot for your answer.

But I can not copy-paste to stimulus editor. In the stumulus editor popup menu there is no add files button; I can not add a file… Do I do something wrong!? Only when I select list type “text”, I can import files. But when I select list type “file”, “import files” button does not appear.:frowning:

Cigdem

You are correct

Sorry for my mistake. That’s the problem with users trying to help each other. I’ve only used text stimuli so far, so I “just assumed” it could work the same way with lists of files.

I suppose one last desperate approach to the problem might be to have your external randomization script make copies (or symbolic links, if you know what that means) of all of the image files, each randomization in a separate folder, with prefixes indicating the order (00dog.jpg, 01tree.jpg, … 99horse.jpg) within the randomization. Then, if the stimuli are read into a list from a folder by default in alphabetic order (and I’m not sure that is the case, but it may well be), they will be in the desired random order.

Greg

Yes, stimulus lists that include folders do read the files in alphabetical order, so a number prepended to the file name will have an affect. Remember, though, that 0_name is different from 00_name.

Dear Greg and Hank,

could you please explain, how to copy and paste files to stimulus list editor?
or making external randomization script copies (or symbolic links: but I dont know what that really means) of all of the image files?

I tried to make this…but as I wrote before: I can not copy and paste, when I select file…
Could you maybe send a short example, how to do it ?

Thanks a lot for your effort and help,
Cigdem

In the main SuperLab experiment window:

  1. Go to the experiment menu
  2. Select stimulus lists
  3. Click new
  4. Select File for the List Type in the upper-right corner of the window that appears
  5. Select the List Items tab.
  6. Make sure Picture File is the event type.
  7. Click Add Files at the bottom-left of this window. If you’d prefer, you could instead add an entire Folder. SuperLab will go through this folder recursively at runtime and present the images inside it.
  8. Give the list a name at the top.
  9. Click OK at the bottom.

Now your list will be available to the picture event type.

You can’t copy and paste an image file into SuperLab.

But when I need to load the pictures also in the event editor (expand events that use lists), for what use are stimulus lists?

expand stimulus lists?

If your stimulus lists are already in the order you need (because you randomized externally and copied the stimuli into files with names that produce the desired order via alphabetization), then I don’t think you want to do any expansion of stimulus lists or randomization within superlab.

Once you put a folder prepared in this way into a stimulus list, the order will be correct.

Is there someone at your institution who can help you with some scripting? I’ve attached a simple Korn Shell script that implements a randomization procedure similar to what you described. If you aren’t used to programming or scripting, this will be meaningless to you, but if there is a resource person you have access to, who does understand programming or scripting, I think this may be helpful in getting started. For example, if you don’t have access to the Korn Shell, the script would need to be converted to some other scripting language. In any case, the attached script produces lines that look like this:

ln -s bar.jpg randset1/000-0-bar.jpg
ln -s yyy.jpg randset1/000-1-yyy.jpg
ln -s foo.jpg randset1/000-2-foo.jpg
ln -s xxx.jpg randset1/000-3-xxx.jpg
ln -s foo.jpg randset1/001-0-foo.jpg
ln -s bar.jpg randset1/001-1-bar.jpg
ln -s yyy.jpg randset1/001-2-yyy.jpg
ln -s xxx.jpg randset1/001-3-xxx.jpg

Those are commands to repeatedly create symbolic links in the folder “randset1”, to four image files (foo.jpg, bar.jpg, xxx.jpg, yyy.jpg). The names have a two-part prefix added. The first part is a three-digit trial number starting at 000; the second part is a one-digit event number 0-3. It is the event number that is randomized, so notice that in trial 000, event 0 has the image bar.jpg, while in trial 001, event 0 has the image foo.jpg.

You can run the script repeatedly and it will produce a different order each time. To simplify the example, I coded the names of the image files and the destination folder in the script; to change these, you can edit the script or make some simple changes (simple to someone who understands scripting, that is) that will allow you to specify the names more generally.

The script works by using a table containing all of the 24 possible orders of 4 events; it repeatedly selects one of them randomly until the first event in the new trial is different from the last event in the previous trial; this process is repeated until you have the desired number of trials (in the example script, 100–this can be changed by editing the script as above).

If you have a number of events other than four, you will need to change the table and one or two places in the script that assume four events.

If it were me, I’d edit this script to produce all of the stimulus folders needed for the whole experiment, for example, randset1, randset2,…randset8 (if you want 8 randomizations).

If I’ve misunderstood the exact requirements for your experiment, well I hope that in any case the general example of how to use this kind of script with Superlab will be helpful.

Good luck,
Greg Shenaut

rand4.ksh.txt (1.13 KB)

Dear Greg,
thank you a lotttttt for your kindness and help!
Cigdem