Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

SART loop and lists

Hi all, 

I'm working on a Sustained Attention Response Task (SART), with some constrains. Here the structure I would like to follow (from Strawarczyk's works):

5 blocks that difere on the number of stimuli. Each block will be randomly repeated 2 times.

In each block, the target (here the number 3) appears in 11% of the total number of stimuli. The other 89% are non-target numbers (1,2,4,5,6,7,8,9). Target number can't be in the first position and numbers can't appear in successive positions (1,2,4,4,7).

(There is some other constrins that I did not implement for now...one step at a time :) )

For now, I built the general structure of the experiment and wrote a script that built a list of numbers following these constrains. As the list will change for each block, I set the script before the block loop. 

As I'm a newbie in both opensesame and python, I'm not sure it's the right way to do it. However, I tested it in IDLE and the script building the lists works fine. 

My problem is that I can't figure out how to present sequentially each number from the built list in a trial sequence. I thought doing something like 'for each number of the list, pick up the first one, use it in the trial sequence and then, pick up the second and so on...'. I did not succeed :/

In fact, the list is built but the first number displayed is not the first one of the list (I guess that it's a problem in my way to pick up and display the numbers from the list) and the trial sequence seems terminated after one presentation (I guess that it's a problem in my loop setting).


Any help will be appreciated :)

Comments

  • Hi,

    My problem is that I can't figure out how to present sequentially each number from the built list in a trial sequence.

    If you have a trial sequence (Opensesames loop/sequence structure), you need a variable that counts iterations, e.g. trial number. This variable you can then use to index the number list you generated.

    Does that help? If not, could you provide more details on the thing you want, and the things that doesnt work?

    Thanks,

    Eduard

  • Hi eduard,

    If you have a trial sequence (Opensesames loop/sequence structure), you need a variable that counts iterations, e.g. trial number. This variable you can then use to index the number list you generated.

    You're totally right! I previously used a counter variable in a previous opensesame experiment. However, I can't manage to set a counter variable for the stimuli from the list.


    My experiment is as follow:

    experimental_loop should set the number of numbers to display (5 blocks that should be randomly used 2 times).

    I set a script that built a stimulus list in the prepare section of the create_stimulus_list script (it seems to work well outside opensesame).

    import random
    NumberOfTrials = var.number_of_stimuli #5 blocks, see experimental_loop, get the number of stimuli to display for the selected block
    NumberOfTarget = int(0.11*NumberOfTrials) #no more than 11% of Target in the total trials per block
    NonTargetList = [1,2,4,5,6,7,8,9]
    Target = 3
    var.NumberList = []
    prev1 = 10 #Will be used to avoid repetition of the same stimulus in consecutive positions
    prev2 = 10
    ##var.number_dur = 500
    ##var.isi = 2000
    var.Number = []
    
    
    while len(var.NumberList) < NumberOfTrials-NumberOfTarget:#Prepare a list of n NonTarget stimuli minus n Target stimuli for a total number equal to the number_of_stimuli variable
    	NonTarget = random.choice(NonTargetList) #Pick up a random NonTarget stimulus
    	if NonTarget not in [prev1,prev2]: #if loop in order to avoid same consecutive number
    		Target = 3
    		var.NumberList.append(NonTarget)
    		prev2 = prev1
    		prev1 = NonTarget
    if NumberOfTarget == 1: #if there is only 1 Target stimulus, put it in a random position except the first one
    	var.NumberList.insert(random.randint(1,len(var.NumberList)),Target)
    else: #if there are more than 1 Target stimulus, generate n random non successive index and no more than requested number of Target that will be used to insert Target stimuli into the list of stimuli
    	indxList = random.sample(range(1,NumberOfTrials-NumberOfTarget+2),NumberOfTarget)
    	##print(indxList)
    	i=0
    	while i < NumberOfTarget:
    		idx=indxList[i]
    		var.NumberList.insert(idx,Target)
    		i=i+1
    

    There is a trial sequence (trial_coroutines) that should display sequentially the numbers from the list of stimuli.

    Now, I'm stuck in the way to pick up the numbers and display them one after another. I tried to set a variable stocking the numbers in an iterative way but I lamentably failed :/

    Thanks,

    Alex

  • Hi Alex,

    Could you try to use "count_stimulus_presentation" as counter variable? Alternatively, you can also add a variable to your block loop table.

    Eduard

  • Hi eduard,

    I think I found the tip.

    I set a counter_trial variable before the block_loop and update it in the trial_coroutines.

    I also set a number_to_display variable in the trial_coroutines sequence that get the number in the number_list variable following the counter_trial that serves as the index for the number_list.

    Finally, I set the block_loop repeat to the number_of_stimuli value from the experimental_loop.

    I must beta-test it but all numbers of the created number_list are now displayed sequentially for each block.

  • Could you try to use "count_stimulus_presentation" as counter variable?

    I tried something like this by using count_trial_coroutines. However, I could not reset the variable.

    Actually, it counts the trial_coroutines through all block. Thus, in the second block, the first number displayed was the index_in_the_stimulus_list_of_the_second_block = number_of_stimuli_from_the_first_block

  • Makes sense. Good to hear!

Sign In or Register to comment.