|
Post by bobbie on Jan 25, 2021 20:36:44 GMT
Hi, is there a way to choose randomly between two tables in a task? It want to show a fixed number of target- and nontarget-words in one task. Within the task, I want them to appear in random order. The tables contain more words than I want to show in one task. Half of the words of both tables should be shown in one block and the other half in the next block. Also, I want the decision, which word to show in which block, to be random for each participant. But I do not want a participant to see any of the words twice. (Does "all_before_repeat" remember the tablerows that were already used across different blocks?)
How can I do this?
Thank you!
|
|
silk
Experienced
Posts: 32
|
Post by silk on Jan 26, 2021 12:33:50 GMT
Hi there, I think that currently there is no way to randomly/conditionally select a table in a task. However, there are alternative ways to (pseudo-)randomize your tests items : - Create two similar experiments you will embed in your survey. One experiment will contain half of your items, and the second one the other half. Then you will randomly choose the first experiment to appear in your survey script.
- Use the blockorder instruction. Create two similar tasks, but each task select a different set of tables. Then create two block orders, PsyToolkit will randomly choose one of the two block orders. However you may need to re-think your tables.
In any cases I think you have to change the way you use your tables. Having a target table and a non-target table is a convenient way of presenting things, but it does not work well in PsyToolkit. One possibility is to use lists. So basically, you no longer use a complete random list of items, but rather pseudo-randomized lists you created before. Then put all your lists in one single table and conditionally select a list in your script by using @ references. Have a look at my sample script below :
table lists "word1" "word3" "word2" "word2" "word1" "word3" "word3" "word2" "word1"
task mytask table lists if &mylist == 1 #Pick item set %mytext paste @1 #from list 1 fi if &mylist == 2 #Pick item set %mytext paste @2 #from list 2 fi if &mylist == 3 #Pick item set %mytext paste @3 #from list 3 fi show text %mytext 0 0 255 0 255 delay 1000 save &mylist %mytext
block myblock set &mylist random 1 3 1 #Choose a list number tasklist mytask 3 fixed end
In this script :
- I have created a table where each column corresponds to a list. You can create those lists using a spreadsheet software and then copy-paste your spreadsheet (that should look like a table) in PsyToolkit. So in my table here, I have three lists of three items.
- I created a random global variable in the block section. It allows me to assign a random value to a variable that will never change, which corresponds to the list the participant will see. It is important to define this variable outside of the task since you don't your participant to be exposed to more than one list.
- In the task, I conditionally select an item from a column based on my random global variable, using @ references. Said in other words, I pick an item from the list that has been attributed to the participant. Notice that I used the fixed parameter since I don't want PsyToolkit to randomly choose a row in my table.
This way of doing things worked pretty well for me. I hope it will help you too.
According to the scripting tab, PsyToolkit remembers which rows have been selected in a table, even if you switch from one task to another, if you're using the all_before_repeat parameter (however I don't think it is necessary if you use the fixed parameter with lists).
There are other ways to counterbalance/randomize your items and I think that arrays can help. It's more advanced stuff, but it is very useful. Basically, you create two arrays, one for target words and another one for non-target words, and then you randomly select a value from each of these two arrays, show these value and remove them from the arrays. Have a look my sample script :
table myitems "target1" "non target1" "target2" "non target2" "target3" "non target3"
task prepare_arrays table myitems set &&target append @1 set &&nontarget append @2 set &&target shuffle set &&nontarget shuffle show text &&target 0 0 0 255 0 show text &&nontarget 0 -100 0 255 0 delay 1000
task mytask set $targetword &&target remove first set $nontargetword &&nontarget remove first show text $targetword 0 0 255 0 255 show text $nontargetword 0 100 255 0 255 delay 1000 save $targetword $nontargetword
block items tasklist prepare_arrays 3 all_before_repeat end
block test tasklist mytask 3 end
In this script :
- I have created a table where each column contains one type of items (target vs. non target words).
- I have two tasks : one to prepare my arrays and another to test my participants. In the first task I create two arrays, using @ references I put all the target words in the first array and all the non-target words in the second array. Then I shuffle each array. Notice that I added some "debug" lines so that you can see how the array is built (its always useful to keep those kind of lines as a comment, it allows you to understand what could go wrong in your script). In the block section for this task, I indicated that the task should be run 3 times since I have 3 target words and 3 non target words. The all_before_repeat is very important here, you don't want a value from your table to appear twice or more (you can replace this parameter by fixed, it should work the same).
- In the second task, I create two variables. Each of them selects the first value from one of the two arrays, stores it and removes it from the array. Then I show these variables to the participant or do whatever needs to be done with these variables. I run the block for this task 3 times since I have three values stores in my arrays.
It's one way to do it with arrays, especially for the test task. I really recommend to read the documentation on arrays. It's a really powerful tool if you know how to use them
|
|
|
Post by bobbie on Jan 28, 2021 15:10:50 GMT
Hi, thank you very much for your detailed answer, I appreciate it a lot! Still trying to figure out completely what you were doing in your examples, I started reading more about arrays. Accidentally, I found that the command "tablerow" allows to specify exactly which tablerow to use in each single trial. So I crated one array, that contains the semi-random order of tablerows and meets the criteria described before. (Code below) Although my solution is different from what you suggested, your answer was very helpful for me! Thanks again and all the best!
task array ##tabellenzeilen nach Farbe und Target sortieren: ##alle roten Targetwörter: set &&t_red 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 set &&t_red shuffle ##die Hälfte der Wörter kommt in eine neue Variable: set $tb1 &&t_red remove first set $tb2 &&t_red remove first set $tb3 &&t_red remove first set $tb4 &&t_red remove first set $tb5 &&t_red remove first set $tb6 &&t_red remove first set $tb7 &&t_red remove first set $tb8 &&t_red remove first ## die Hälfte der Targetwörter soll blau sein: set $tb1 increase 1 set $tb2 increase 1 set $tb3 increase 1 set $tb4 increase 1 set $tb5 increase 1 set $tb6 increase 1 set $tb7 increase 1 set $tb8 increase 1 ##neue Variable zusammensetzen: set &&t_blue $tb1 times 1 set &&t_blue append $tb2 set &&t_blue append $tb3 set &&t_blue append $tb4 set &&t_blue append $tb5 set &&t_blue append $tb6 set &&t_blue append $tb7 set &&t_blue append $tb8 ## das gleiche für die nicht-targetwörter: ##alle roten nicht-Targetwörter: set &&nt_red 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 ## alle nontargetwörter in rot set &&nt_red shuffle ## die Hälfte kommt in eine neue Variable: set $ntb1 &&nt_red remove first set $ntb2 &&nt_red remove first set $ntb3 &&nt_red remove first set $ntb4 &&nt_red remove first set $ntb5 &&nt_red remove first set $ntb6 &&nt_red remove first set $ntb7 &&nt_red remove first set $ntb8 &&nt_red remove first set $ntb9 &&nt_red remove first set $ntb10 &&nt_red remove first set $ntb11 &&nt_red remove first set $ntb12 &&nt_red remove first set $ntb13 &&nt_red remove first set $ntb14 &&nt_red remove first set $ntb15 &&nt_red remove first set $ntb16 &&nt_red remove first ##die Hälfte der nontaregtwörter soll blau sein: set $ntb1 increase 1 set $ntb2 increase 1 set $ntb3 increase 1 set $ntb4 increase 1 set $ntb5 increase 1 set $ntb6 increase 1 set $ntb7 increase 1 set $ntb8 increase 1 set $ntb9 increase 1 set $ntb10 increase 1 set $ntb11 increase 1 set $ntb12 increase 1 set $ntb13 increase 1 set $ntb14 increase 1 set $ntb15 increase 1 set $ntb16 increase 1 ##zusammensetzen der variable: set &&nt_blue $ntb1 times 1 set &&nt_blue append $ntb2 set &&nt_blue append $ntb3 set &&nt_blue append $ntb4 set &&nt_blue append $ntb5 set &&nt_blue append $ntb6 set &&nt_blue append $ntb7 set &&nt_blue append $ntb8 set &&nt_blue append $ntb9 set &&nt_blue append $ntb10 set &&nt_blue append $ntb11 set &&nt_blue append $ntb12 set &&nt_blue append $ntb13 set &&nt_blue append $ntb14 set &&nt_blue append $ntb15 set &&nt_blue append $ntb16 ##arrays in der Mitte teilen: ##rot target: set $str1 &&t_red remove first set $str2 &&t_red remove first set $str3 &&t_red remove first set $str4 &&t_red remove first set &&t_red2 $str1 times 1 set &&t_red2 append $str2 set &&t_red2 append $str3 set &&t_red2 append $str4 ##blau target: set $stb1 &&t_blue remove first set $stb2 &&t_blue remove first set $stb3 &&t_blue remove first set $stb4 &&t_blue remove first set &&t_blue2 $stb1 times 1 set &&t_blue2 append $stb2 set &&t_blue2 append $stb3 set &&t_blue2 append $stb4 ##rot nontarget: set $sntr1 &&nt_red remove first set $sntr2 &&nt_red remove first set $sntr3 &&nt_red remove first set $sntr4 &&nt_red remove first set $sntr5 &&nt_red remove first set $sntr6 &&nt_red remove first set $sntr7 &&nt_red remove first set $sntr8 &&nt_red remove first set &&nt_red2 $sntr1 times 1 set &&nt_red2 append $sntr2 set &&nt_red2 append $sntr3 set &&nt_red2 append $sntr4 set &&nt_red2 append $sntr5 set &&nt_red2 append $sntr6 set &&nt_red2 append $sntr7 set &&nt_red2 append $sntr8 ##blau nontarget: set $sntb1 &&nt_blue remove first set $sntb2 &&nt_blue remove first set $sntb3 &&nt_blue remove first set $sntb4 &&nt_blue remove first set $sntb5 &&nt_blue remove first set $sntb6 &&nt_blue remove first set $sntb7 &&nt_blue remove first set $sntb8 &&nt_blue remove first set &&nt_blue2 $sntb1 times 1 set &&nt_blue2 append $sntb2 set &&nt_blue2 append $sntb3 set &&nt_blue2 append $sntb4 set &&nt_blue2 append $sntb5 set &&nt_blue2 append $sntb6 set &&nt_blue2 append $sntb7 set &&nt_blue2 append $sntb8 ##speichern ##save &&t_red ##save &&t_red2 ##save &&t_blue ##save &&t_blue2 ##save &&nt_red ##save &&nt_red2 ##save &&nt_blue ##save &&nt_blue2 ##arrays zusammensetzen set &&t_red append &&t_blue set &&t_red append &&nt_red set &&t_red append &&nt_blue set &&t_red shuffle ##enthält alle Wörter für Stroop1 set &&t_red2 append &&t_blue2 set &&t_red2 append &&nt_red2 set &&t_red2 append &&nt_blue2 set &&t_red2 shuffle ## enthält alle Wörter für Stroop2 set &&tablerows &&t_red times 1 set &&tablerows append &&t_red2 save &&tablerows
|
|
silk
Experienced
Posts: 32
|
Post by silk on Jan 29, 2021 12:26:17 GMT
Hi, Yeah, sometimes I write a lot, sorry about that... I didn't understand exactly what you wanted to do, that's why I proposed two scripts to create and use different lists of items (one using only table, and the other using arrays). I didn't think of the tablerow instruction, but it is indeed very useful, especially if you're working with arrays. (I think this instruction is not in the scripting tab, I only found it here). I just had a look at your script, you can make it shorter. You are using the same instructions a lot of times in order to remove a variable from an array and then append it to another array. Instead of writing the same instruction over and over, you can say : repeat this instruction until I'm ok with the result, which can be translated by the while instruction. Have a look at the following script : set &&t_red 1 3 5 7 9 11 13 15 ###Create my first array set $array_size 0 ###Create a control variable while $array_size != 4 ###Repeat until $array_size is 4 set $removed_value &&t_red remove first ###Remove a value from the first array set $removed_value increase ###Increase the removed value set &&t_blue append $removed_value ###Add the removed value to the second array set $array_size increase ###Increase my control variable while-end ###If my control variable is 4, leaveWith this script I simply store the removed value from the first array in a variable ( $removed_value), and I append the value of this variable to the second array. Then I use the while instruction to repeat the whole process until I removed 4 values from the first array. Here I used the variable $array_size to say when I have to leave the while loop. Have a look below at my script (55 lines), similar to yours (161 lines) in terms of what it does, with while loops. I hope it can help you to improve your script task create_arrays ### TARGET RED & BLUE ### set $array_size 0 set &&t_red 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 set &&t_red shuffle while $array_size != 8 set $removed_value &&t_red remove first set $removed_value increase set &&t_blue append $removed_value set $array_size increase while-end ### NON-TARGET RED & BLUE ### set $array_size 0 set &&nt_red 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 set &&nt_red shuffle while $array_size != 16 set $removed_value &&nt_red remove first set $removed_value increase set &&nt_blue append $removed_value set $array_size increase while-end ### SPLIT TARGET ARRAYS #### set $array_size 0 while $array_size != 4 set $removed_value &&t_red remove first set &&t_red2 append $removed_value set $removed_value &&t_blue remove first set &&t_blue2 append $removed_value set $array_size increase while-end ### SPLIT NON-TARGET ARRAYS #### set $array_size 0 while $array_size != 8 set $removed_value &&nt_red remove first set &&nt_red2 append $removed_value set $removed_value &&nt_blue remove first set &&nt_blue2 append $removed_value set $array_size increase while-end ### APPEND ARRAYS IN BLOCK 1 ### set &&first_block append &&t_red set &&first_block append &&nt_red set &&first_block append &&t_blue set &&first_block append &&nt_blue set &&first_block shuffle ### APPEND ARRAYS IN BLOCK 2 ### set &&second_block append &&t_red2 set &&second_block append &&nt_red2 set &&second_block append &&t_blue2 set &&second_block append &&nt_blue2 set &&second_block shuffle ### PUT EVERYTHING TOGETHER ### set &&rows_selection append &&first_block set &&rows_selection append &&second_block set &&rows_selection shuffle
|
|