Millisecond Forums

Using functions to delete available trials

https://forums.millisecond.com/Topic22603.aspx

By jessjones12 - 9/29/2017

Hi,

Question:
Is there a function that will allow me to delete subsequent available trials if a specific condition is met?

My task:
I am trying to create a short recognition memory task (old v. new judgments) in which there are 16 trials (randomized). Each trial will display 1 image pulled randomly from a group of 4. Each group will contain 4 images from the same category:

  1. “Old” and contain emotion content
  2. "Old” and contain neutral content
  3. “New” and contain emotion content
  4. “New” and contain neutral content

There are 4 categories that each image group belongs to, and 3 groups of 4 images per category (48 images total):

  1. positive/social
  2. negative/social
  3. positive/non-social
  4. negative/non-social

I need to make sure that out of the 16 trials shown as follows:

8 “old” trials

  • 4 emotion content
    • 1 positive/social
    • 1 negative/social
    • 1 positive/non-social
    • 1 negative/non-social
  • 4 neutral content
    • 1 positive/social
    • 1 negative/social
    • 1 positive/non-social
    • 1 negative/non-social
8 “new” trials
  • 4 emotion content
    • 1 positive/social
    • 1 negative/social
    • 1 positive/non-social
    • 1 negative/non-social
  • 4 neutral content
    • 1 positive/social
    • 1 negative/social
    • 1 positive/non-social
    • 1 negative/non-social

My problem:
Once an image from a specific group is shown, I want the rest of the group to be eliminated from the available selection pool. 
I have done this in the past with less complicated constraints by simply using the “/select” and “/resetinterval” attributes, but this has not been working for me with this design.
I have also tried functions like “removeitem()”, but because I can only specific the item index and not the specific text in an item list,this creates issues with my item pools when randomizing (what was at index 3 becomes index 2 when the item at index 1 is deleted and so on).
“Clearstimulusframes()” does delete the frames from a trial (if I create a single trial for each image), but the trial will still run and simply not display stimuli.

If there is a way or function that will allow me to delete subsequent available trials if a specific condition is met, that would be great.

Any help would be greatly appreciated.

Jess

Stimulus pool:

"PositiveSocial_emotion_old_group1.jpg"
"PositiveSocial_neutral_old_group1.jpg"
"PositiveSocial_emotion_new_group1.jpg"
"PositiveSocial_neutral_new_group1.jpg"

"PositiveSocial_emotion_old_group2.jpg"
"PositiveSocial_neutral_old_group2.jpg"
"PositiveSocial_emotion_new_group2.jpg"
"PositiveSocial_neutral_new_group2.jpg"

"PositiveSocial_emotion_old_group3.jpg"
"PositiveSocial_neutral_old_group3.jpg"
"PositiveSocial_emotion_new_group3.jpg"
"PositiveSocial_neutral_new_group3.jpg"

"NegativeSocial_emotion_old_group1.jpg"
"NegativeSocial_neutral_old_group1.jpg"
"NegativeSocial_emotion_new_group1.jpg"
"NegativeSocial_neutral_new_group1.jpg"

"NegativeSocial_emotion_old_group2.jpg"
"NegativeSocial_neutral_old_group2.jpg"
"NegativeSocial_emotion_new_group2.jpg"
"NegativeSocial_neutral_new_group2.jpg"

"NegativeSocial_emotion_old_group3.jpg"
"NegativeSocial_neutral_old_group3.jpg"
"NegativeSocial_emotion_new_group3.jpg"
"NegativeSocial_neutral_new_group3.jpg"

"PositiveNonSocial_emotion_old_group1.jpg"
"PositiveNonSocial_neutral_old_group1.jpg"
"PositiveNonSocial_emotion_new_group1.jpg"
"PositiveNonSocial_neutral_new_group1.jpg"

"PositiveNonSocial_emotion_old_group2.jpg"
"PositiveNonSocial_neutral_old_group2.jpg"
"PositiveNonSocial_emotion_new_group2.jpg"
"PositiveNonSocial_neutral_new_group2.jpg"

"PositiveNonSocial_emotion_old_group3.jpg"
"PositiveNonSocial_neutral_old_group3.jpg"
"PositiveNonSocial_emotion_new_group3.jpg"
"PositiveNonSocial_neutral_new_group3.jpg"

"NegativeNonSocial_emotion_old_group1.jpg"
"NegativeNonSocial_neutral_old_group1.jpg"
"NegativeNonSocial_emotion_new_group1.jpg"
"NegativeNonSocial_neutral_new_group1.jpg"

"NegativeNonSocial_emotion_old_group2.jpg"
"NegativeNonSocial_neutral_old_group2.jpg"
"NegativeNonSocial_emotion_new_group2.jpg"
"NegativeNonSocial_neutral_new_group2.jpg"

"NegativeNonSocial_emotion_old_group3.jpg"
"NegativeNonSocial_neutral_old_group3.jpg"
"NegativeNonSocial_emotion_new_group3.jpg"
"NegativeNonSocial_neutral_new_group3.jpg"


By Dave - 9/29/2017

jessjones12 - Friday, September 29, 2017

Hi,

Question:
Is there a function that will allow me to delete subsequent available trials if a specific condition is met?

My task:
I am trying to create a short recognition memory task (old v. new judgments) in which there are 16 trials (randomized). Each trial will display 1 image pulled randomly from a group of 4. Each group will contain 4 images from the same category:

  1. “Old” and contain emotion content
  2. "Old” and contain neutral content
  3. “New” and contain emotion content
  4. “New” and contain neutral content

There are 4 categories that each image group belongs to, and 3 groups of 4 images per category (48 images total):

  1. positive/social
  2. negative/social
  3. positive/non-social
  4. negative/non-social

I need to make sure that out of the 16 trials shown as follows:

8 “old” trials

  • 4 emotion content
    • 1 positive/social
    • 1 negative/social
    • 1 positive/non-social
    • 1 negative/non-social
  • 4 neutral content
    • 1 positive/social
    • 1 negative/social
    • 1 positive/non-social
    • 1 negative/non-social
8 “new” trials
  • 4 emotion content
    • 1 positive/social
    • 1 negative/social
    • 1 positive/non-social
    • 1 negative/non-social
  • 4 neutral content
    • 1 positive/social
    • 1 negative/social
    • 1 positive/non-social
    • 1 negative/non-social

My problem:
Once an image from a specific group is shown, I want the rest of the group to be eliminated from the available selection pool. 
I have done this in the past with less complicated constraints by simply using the “/select” and “/resetinterval” attributes, but this has not been working for me with this design.
I have also tried functions like “removeitem()”, but because I can only specific the item index and not the specific text in an item list,this creates issues with my item pools when randomizing (what was at index 3 becomes index 2 when the item at index 1 is deleted and so on).
“Clearstimulusframes()” does delete the frames from a trial (if I create a single trial for each image), but the trial will still run and simply not display stimuli.

If there is a way or function that will allow me to delete subsequent available trials if a specific condition is met, that would be great.

Any help would be greatly appreciated.

Jess

Stimulus pool:

"PositiveSocial_emotion_old_group1.jpg"
"PositiveSocial_neutral_old_group1.jpg"
"PositiveSocial_emotion_new_group1.jpg"
"PositiveSocial_neutral_new_group1.jpg"

"PositiveSocial_emotion_old_group2.jpg"
"PositiveSocial_neutral_old_group2.jpg"
"PositiveSocial_emotion_new_group2.jpg"
"PositiveSocial_neutral_new_group2.jpg"

"PositiveSocial_emotion_old_group3.jpg"
"PositiveSocial_neutral_old_group3.jpg"
"PositiveSocial_emotion_new_group3.jpg"
"PositiveSocial_neutral_new_group3.jpg"

"NegativeSocial_emotion_old_group1.jpg"
"NegativeSocial_neutral_old_group1.jpg"
"NegativeSocial_emotion_new_group1.jpg"
"NegativeSocial_neutral_new_group1.jpg"

"NegativeSocial_emotion_old_group2.jpg"
"NegativeSocial_neutral_old_group2.jpg"
"NegativeSocial_emotion_new_group2.jpg"
"NegativeSocial_neutral_new_group2.jpg"

"NegativeSocial_emotion_old_group3.jpg"
"NegativeSocial_neutral_old_group3.jpg"
"NegativeSocial_emotion_new_group3.jpg"
"NegativeSocial_neutral_new_group3.jpg"

"PositiveNonSocial_emotion_old_group1.jpg"
"PositiveNonSocial_neutral_old_group1.jpg"
"PositiveNonSocial_emotion_new_group1.jpg"
"PositiveNonSocial_neutral_new_group1.jpg"

"PositiveNonSocial_emotion_old_group2.jpg"
"PositiveNonSocial_neutral_old_group2.jpg"
"PositiveNonSocial_emotion_new_group2.jpg"
"PositiveNonSocial_neutral_new_group2.jpg"

"PositiveNonSocial_emotion_old_group3.jpg"
"PositiveNonSocial_neutral_old_group3.jpg"
"PositiveNonSocial_emotion_new_group3.jpg"
"PositiveNonSocial_neutral_new_group3.jpg"

"NegativeNonSocial_emotion_old_group1.jpg"
"NegativeNonSocial_neutral_old_group1.jpg"
"NegativeNonSocial_emotion_new_group1.jpg"
"NegativeNonSocial_neutral_new_group1.jpg"

"NegativeNonSocial_emotion_old_group2.jpg"
"NegativeNonSocial_neutral_old_group2.jpg"
"NegativeNonSocial_emotion_new_group2.jpg"
"NegativeNonSocial_neutral_new_group2.jpg"

"NegativeNonSocial_emotion_old_group3.jpg"
"NegativeNonSocial_neutral_old_group3.jpg"
"NegativeNonSocial_emotion_new_group3.jpg"
"NegativeNonSocial_neutral_new_group3.jpg"



I'm not sure I fully understand the design you have in mind or the logic behind the grouping. Can you give me a concrete example what would constitute a valid selection of stimuli from your listed 48 items, i.e. one that satisfies your constraints? Thanks.
By Dave - 9/29/2017

Dave - Friday, September 29, 2017
jessjones12 - Friday, September 29, 2017

Hi,

Question:
Is there a function that will allow me to delete subsequent available trials if a specific condition is met?

My task:
I am trying to create a short recognition memory task (old v. new judgments) in which there are 16 trials (randomized). Each trial will display 1 image pulled randomly from a group of 4. Each group will contain 4 images from the same category:

  1. “Old” and contain emotion content
  2. "Old” and contain neutral content
  3. “New” and contain emotion content
  4. “New” and contain neutral content

There are 4 categories that each image group belongs to, and 3 groups of 4 images per category (48 images total):

  1. positive/social
  2. negative/social
  3. positive/non-social
  4. negative/non-social

I need to make sure that out of the 16 trials shown as follows:

8 “old” trials

  • 4 emotion content
    • 1 positive/social
    • 1 negative/social
    • 1 positive/non-social
    • 1 negative/non-social
  • 4 neutral content
    • 1 positive/social
    • 1 negative/social
    • 1 positive/non-social
    • 1 negative/non-social
8 “new” trials
  • 4 emotion content
    • 1 positive/social
    • 1 negative/social
    • 1 positive/non-social
    • 1 negative/non-social
  • 4 neutral content
    • 1 positive/social
    • 1 negative/social
    • 1 positive/non-social
    • 1 negative/non-social

My problem:
Once an image from a specific group is shown, I want the rest of the group to be eliminated from the available selection pool. 
I have done this in the past with less complicated constraints by simply using the “/select” and “/resetinterval” attributes, but this has not been working for me with this design.
I have also tried functions like “removeitem()”, but because I can only specific the item index and not the specific text in an item list,this creates issues with my item pools when randomizing (what was at index 3 becomes index 2 when the item at index 1 is deleted and so on).
“Clearstimulusframes()” does delete the frames from a trial (if I create a single trial for each image), but the trial will still run and simply not display stimuli.

If there is a way or function that will allow me to delete subsequent available trials if a specific condition is met, that would be great.

Any help would be greatly appreciated.

Jess

Stimulus pool:

"PositiveSocial_emotion_old_group1.jpg"
"PositiveSocial_neutral_old_group1.jpg"
"PositiveSocial_emotion_new_group1.jpg"
"PositiveSocial_neutral_new_group1.jpg"

"PositiveSocial_emotion_old_group2.jpg"
"PositiveSocial_neutral_old_group2.jpg"
"PositiveSocial_emotion_new_group2.jpg"
"PositiveSocial_neutral_new_group2.jpg"

"PositiveSocial_emotion_old_group3.jpg"
"PositiveSocial_neutral_old_group3.jpg"
"PositiveSocial_emotion_new_group3.jpg"
"PositiveSocial_neutral_new_group3.jpg"

"NegativeSocial_emotion_old_group1.jpg"
"NegativeSocial_neutral_old_group1.jpg"
"NegativeSocial_emotion_new_group1.jpg"
"NegativeSocial_neutral_new_group1.jpg"

"NegativeSocial_emotion_old_group2.jpg"
"NegativeSocial_neutral_old_group2.jpg"
"NegativeSocial_emotion_new_group2.jpg"
"NegativeSocial_neutral_new_group2.jpg"

"NegativeSocial_emotion_old_group3.jpg"
"NegativeSocial_neutral_old_group3.jpg"
"NegativeSocial_emotion_new_group3.jpg"
"NegativeSocial_neutral_new_group3.jpg"

"PositiveNonSocial_emotion_old_group1.jpg"
"PositiveNonSocial_neutral_old_group1.jpg"
"PositiveNonSocial_emotion_new_group1.jpg"
"PositiveNonSocial_neutral_new_group1.jpg"

"PositiveNonSocial_emotion_old_group2.jpg"
"PositiveNonSocial_neutral_old_group2.jpg"
"PositiveNonSocial_emotion_new_group2.jpg"
"PositiveNonSocial_neutral_new_group2.jpg"

"PositiveNonSocial_emotion_old_group3.jpg"
"PositiveNonSocial_neutral_old_group3.jpg"
"PositiveNonSocial_emotion_new_group3.jpg"
"PositiveNonSocial_neutral_new_group3.jpg"

"NegativeNonSocial_emotion_old_group1.jpg"
"NegativeNonSocial_neutral_old_group1.jpg"
"NegativeNonSocial_emotion_new_group1.jpg"
"NegativeNonSocial_neutral_new_group1.jpg"

"NegativeNonSocial_emotion_old_group2.jpg"
"NegativeNonSocial_neutral_old_group2.jpg"
"NegativeNonSocial_emotion_new_group2.jpg"
"NegativeNonSocial_neutral_new_group2.jpg"

"NegativeNonSocial_emotion_old_group3.jpg"
"NegativeNonSocial_neutral_old_group3.jpg"
"NegativeNonSocial_emotion_new_group3.jpg"
"NegativeNonSocial_neutral_new_group3.jpg"



I'm not sure I fully understand the design you have in mind or the logic behind the grouping. Can you give me a concrete example what would constitute a valid selection of stimuli from your listed 48 items, i.e. one that satisfies your constraints? Thanks.

To elaborate a bit: My big hangup is this:

"Once an image from a specific group is shown, I want the rest of the group to be eliminated from the available selection pool. "

You seem to have (please correct me if I'm wrong) 12 groups of 4 images each (for a total of 12 x 4 = 48) images. With the above fundamental constraint in place, it seems to me then that you cannot select more than 12 items -- one from each group of four (ignoring any other constraints for the time being). Basically, I'm not quite clear on how to get to 16 trials from there: Wouldn't you require a selection of 16 items?
By jessjones12 - 10/2/2017

Hi Dave,

Apologies for the slow response, I had to double-check with my collaborators. I believe you're correct- there should only be 12 trials total in the real task.

Here’s a more concrete example of my issue:
Let’s say I want to show participants 4 trials, and each trial will contain 1 image randomly pulled from a group of 4 trials:
Trial 1 images:

  • old_emotion_trial1.jpg
  • old_neutral_trial1.jpg
  • new_emotion_trial1.jpg
  • new_neutral_trial1.jpg
Trial 2 images:
  • old_emotion_trial2.jpg
  • old_neutral_trial2.jpg
  • new_emotion_trial2.jpg
  • new_neutral_trial2.jpg
Trial 3 images:
  • old_emotion_trial3.jpg
  • old_neutral_trial3.jpg
  • new_emotion_trial3.jpg
  • new_neutral_trial3.jpg
Trial 4 images:
  • old_emotion_trial4.jpg
  • old_neutral_trial4.jpg
  • new_emotion_trial4.jpg
  • new_neutral_trial4.jpg

In each trial, there are two old images and two new images. For each old and new image, there are two versions of the image (emotion-focused and a neutral-focused). Thus, each trial contains 4 different types of images: old/emotion focus, old/neutral focus, new/emotion focus, new/neutral focus.

In these 4 trials, I would like for each trial to randomly pull an image from it’s own bucket of 4 images. However, I would like to make sure that each of the 4 image-types (old/emotion focus, old/neutral focus, new/emotion focus, new/neutral focus) are shown at least once throughout my 4 trials.

So for example, if trial 1 randomly selects the old/neutral type image (“old_neutral_trial1.jpg”), then trials 2-4 should not randomly choose “old_neutral_trial2.jpg”, “old_neutral_trial3.jpg”, or “old_neutral_trial4.jpg”, respectively, because this would be a repetition of the image type (old/neutral) throughout the trials.

Does this help? Essentially, I’ve been unable to figure out how to use expressions/functions to prevent these excessive repetitions (of image types) throughout the real task.

Thank you for your help,
Jess


By jessjones12 - 10/2/2017

Hi Dave,

Apologies for the slow response, I had to double-check with my collaborators. I believe you're correct- there should only be 12 trials total in the real task.

Here’s a more concrete example of my issue:
Let’s say I want to show participants 4 trials, and each trial will contain 1 image randomly pulled from a group of 4 trials:

Trial 1 images:
  • old_emotion_trial1.jpg
  • old_neutral_trial1.jpg
  • new_emotion_trial1.jpg
  • new_neutral_trial1.jpg
Trial 2 images:
  • old_emotion_trial2.jpg
  • old_neutral_trial2.jpg
  • new_emotion_trial2.jpg
  • new_neutral_trial2.jpg
Trial 3 images:
  • old_emotion_trial3.jpg
  • old_neutral_trial3.jpg
  • new_emotion_trial3.jpg
  • new_neutral_trial3.jpg
Trial 4 images:
  • old_emotion_trial4.jpg
  • old_neutral_trial4.jpg
  • new_emotion_trial4.jpg
  • new_neutral_trial4.jpg

In each trial, there are two old images and two new images. For each old and new image, there are two versions of the image (emotion-focused and a neutral-focused). Thus, each trial contains 4 different types of images: old/emotion focus, old/neutral focus, new/emotion focus, new/neutral focus.

In these 4 trials, I would like for each trial to randomly pull an image from it’s own bucket of 4 images. However, I would like to make sure that each of the 4 image-types (old/emotion focus, old/neutral focus, new/emotion focus, new/neutral focus) are shown at least once throughout my 4 trials.

So for example, if trial 1 randomly selects the old/neutral type image (“old_neutral_trial1.jpg”), then trials 2-4 should not randomly choose “old_neutral_trial2.jpg”, “old_neutral_trial3.jpg”, or “old_neutral_trial4.jpg”, respectively, because this would be a repetition of the image type (old/neutral) throughout the trials.

Does this help? Essentially, I’ve been unable to figure out how to use expressions/functions to prevent these excessive repetitions (of image types) throughout the real task.

Thank you for your help,
Jess

By Dave - 10/2/2017

jessjones12 - Monday, October 2, 2017
Hi Dave,

Apologies for the slow response, I had to double-check with my collaborators. I believe you're correct- there should only be 12 trials total in the real task.

Here’s a more concrete example of my issue:
Let’s say I want to show participants 4 trials, and each trial will contain 1 image randomly pulled from a group of 4 trials:

Trial 1 images:
  • old_emotion_trial1.jpg
  • old_neutral_trial1.jpg
  • new_emotion_trial1.jpg
  • new_neutral_trial1.jpg
Trial 2 images:
  • old_emotion_trial2.jpg
  • old_neutral_trial2.jpg
  • new_emotion_trial2.jpg
  • new_neutral_trial2.jpg
Trial 3 images:
  • old_emotion_trial3.jpg
  • old_neutral_trial3.jpg
  • new_emotion_trial3.jpg
  • new_neutral_trial3.jpg
Trial 4 images:
  • old_emotion_trial4.jpg
  • old_neutral_trial4.jpg
  • new_emotion_trial4.jpg
  • new_neutral_trial4.jpg

In each trial, there are two old images and two new images. For each old and new image, there are two versions of the image (emotion-focused and a neutral-focused). Thus, each trial contains 4 different types of images: old/emotion focus, old/neutral focus, new/emotion focus, new/neutral focus.

In these 4 trials, I would like for each trial to randomly pull an image from it’s own bucket of 4 images. However, I would like to make sure that each of the 4 image-types (old/emotion focus, old/neutral focus, new/emotion focus, new/neutral focus) are shown at least once throughout my 4 trials.

So for example, if trial 1 randomly selects the old/neutral type image (“old_neutral_trial1.jpg”), then trials 2-4 should not randomly choose “old_neutral_trial2.jpg”, “old_neutral_trial3.jpg”, or “old_neutral_trial4.jpg”, respectively, because this would be a repetition of the image type (old/neutral) throughout the trials.

Does this help? Essentially, I’ve been unable to figure out how to use expressions/functions to prevent these excessive repetitions (of image types) throughout the real task.

Thank you for your help,
Jess


Hi Jess,

Thanks for the clarification -- very helpful. Suppose you arrange your items like this:

<item myitems>
/ 1 = "old_emotion_trial1.jpg"
/ 2 = "old_neutral_trial1.jpg"
/ 3 = "new_emotion_trial1.jpg"
/ 4 = "new_neutral_trial1.jpg"

/ 5 = "old_emotion_trial2.jpg"
/ 6 = "old_neutral_trial2.jpg"
/ 7 = "new_emotion_trial2.jpg"
/ 8 = "new_neutral_trial2.jpg"

/ 9 = "old_emotion_trial3.jpg"
/ 10 = "old_neutral_trial3.jpg"
/ 11 = "new_emotion_trial3.jpg"
/ 12 = "new_neutral_trial3.jpg"

/ 13 = "old_emotion_trial4.jpg"
/ 14 = "old_neutral_trial4.jpg"
/ 15 = "new_emotion_trial4.jpg"
/ 16 = "new_neutral_trial4.jpg"
</item>

What you can do, then, is use <list> elements to randomly select one of the "base" items in the group (#1,#5, #9, #13)

<list base>
/ items = (1,5,9,13)
</list>

and then another <list> to select one of the items _within_ the group randomly without replacement:

<list in_group>
/ items = (0,1,2,3)
</list>

Add the two and you get your desired selection across trials:


<item myitems>
/ 1 = "old_emotion_trial1.jpg"
/ 2 = "old_neutral_trial1.jpg"
/ 3 = "new_emotion_trial1.jpg"
/ 4 = "new_neutral_trial1.jpg"

/ 5 = "old_emotion_trial2.jpg"
/ 6 = "old_neutral_trial2.jpg"
/ 7 = "new_emotion_trial2.jpg"
/ 8 = "new_neutral_trial2.jpg"

/ 9 = "old_emotion_trial3.jpg"
/ 10 = "old_neutral_trial3.jpg"
/ 11 = "new_emotion_trial3.jpg"
/ 12 = "new_neutral_trial3.jpg"

/ 13 = "old_emotion_trial4.jpg"
/ 14 = "old_neutral_trial4.jpg"
/ 15 = "new_emotion_trial4.jpg"
/ 16 = "new_neutral_trial4.jpg"
</item>

<list base>
/ items = (1,5,9,13)
</list>

<list ingroup>
/ items = (0,1,2,3)
</list>

<text stimulus>
/ items = myitems
/ select = values.computeditemnumber
</text>

<values>
/ baseitemnumber = 0
/ ingroupitemnumber = 0
/ computeditemnumber = 0
</values>

<trial mytrial>
/ ontrialbegin = [
    values.baseitemnumber = list.base.nextvalue;
    values.ingroupitemnumber = list.ingroup.nextvalue;
    values.computeditemnumber = values.baseitemnumber + values.ingroupitemnumber;
]
/ stimulusframes = [1=stimulus]
/ validresponse = (57)
</trial>

<block myblock>
/ trials = [1-4 = mytrial]
</block>

Hope this helps!
By jessjones12 - 10/2/2017

Hi Dave- this solution worked perfectly, thank you for your help!