ati
Regular
Posts: 22
|
Post by ati on May 30, 2021 7:45:44 GMT
Hello,
What is the problem with this code? I save and compile, everything is fine. But, when I run it, it does not show the stimuli. What I want to do is to show a group of stimuli randomly from one of the table columns. So, it should choose one column randomly, and show 5 stimuli in random order. However, as I said, when it does not give me a feedback about the problem. It runs, but no stimuli.
table lists N001 img_1 img_19 N002 img_2 img_20 N004 img_3 img_21 N011 img_4 img_22 N014 img_5 img_23
task my_task table lists if &mylist == 1 #these are for columns, I also tried @1, @2, @3. set &neutral @1 fi if &mylist == 2 set &positive @2 fi if &mylist == 3 set &positive @3 fi delay 100 save &mylist
block myblock set &mylist random @1 @2 @3 #these are for columns, I also tried 1, 2, 3, it is the same. tasklist my_task 1 random end
|
|
silk
Experienced
Posts: 32
|
Post by silk on May 30, 2021 14:19:56 GMT
Hi there,
In your code you have no show instruction, so no stimuli can be shown. I added this instruction to your code below. Some other comments :- if &mylist == 1 is not equivalent to if &mylist == @1 : the first one means that you check if &mylist has the value 1, the second one means that you check if &mylist has the same value as the cell in the first column of the (randomly) selected row (here N001, N002, N003, etc.). Since you want to select a column, use the first option. If you want to select a specific row, use the tablerow instruction (explained here).
- I changed the variable in the set instruction, so that it saves the name of the selected stimuli.
- You can select a random value from a range with this syntax : set $my_value random "x" "y" "z", and it will randomly select a value between x and y with a step of z. For instance, set $my_value random 0 10 2 means that a random even number is selected between 0 and 10. If you want to randomly select a value from a specific set of values that do not follow, I recommend to use arrays since this instruction doesn't work (for me) : set $my_value random from value1 value2 value3 etc.
- You don't have to specify random in the block section for your task. It's the default parameter in PsyToolkit : each time you run the task a row is randomly selected from the table (which means that a same row can be selected twice or more). If you want to choose all rows before they are chosen again, use the all_before_repeat parameter for your task (see your code below). Note that it will still randomly select a row.
table lists N001 img_1 img_19 N002 img_2 img_20 N004 img_3 img_21 N011 img_4 img_22 N014 img_5 img_23
task my_task table lists if &mylist == 1 show bitmap @1 0 0 set $stimuli @1 fi if &mylist == 2 show bitmap @2 0 0 set $stimuli @2 fi if &mylist == 3 show bitmap @3 0 0 set $stimuli @3 fi delay 1000 save &mylist $stimuli
block myblock set &mylist random 1 3 1 tasklist my_task 5 all_before_repeat end
|
|
ati
Regular
Posts: 22
|
Post by ati on May 30, 2021 16:12:50 GMT
Thank you very much for your answer, it works perfectly. But, since I would like to understand properly, I want to ask more about your comments if you don't mind. First comment: I wanted to use columns (N001...), so not whether mylist has the value 1. In that case, it seems that the second one (mylist == @1) makes more sense, why did you recommend the first one (mylist == 1) and used it? Second comment: In that case, will it save the name of the each stimulus? Because, there will be 5 stimuli. It seems you used local variable, would it be okay in that case? After trial, I will not need the previous ones though because I will not show different column, just one column randomly for each participant.
Fourth comment: What is the meaning of "1 3 1" after random in the block?
Actually, I made it a little bit more complex, I added a rate option and it works fine: task my_task table lists if &mylist == 1 show bitmap @1 0 0 rate option pos 0 200 rate option labels left right rate option items selection_item rate 15000 9 set $stimuli @1 save @1 RATE RATE_RT RATE_STATUS
|
|