# Randomly but always on the same position

**URL:** <https://discourse.psychopy.org/t/randomly-but-always-on-the-same-position/20957>\
**Category:** Builder\
**Tags:** randomization\
**Created:** [March 3, 2021, 6:33pm UTC](https://discourse.psychopy.org/t/randomly-but-always-on-the-same-position/20957 "2021-03-03T18:33:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gblondelle](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/gblondelle/32/13972_2.png) [@gblondelle](https://discourse.psychopy.org/u/gblondelle)\
**Post date:** [March 3, 2021, 6:33pm UTC](https://discourse.psychopy.org/t/randomly-but-always-on-the-same-position/20957/1 "2021-03-03T18:33:06Z")

</div>

Hi,

I am trying to build a picture comparison task (PCT) with psychopy.

In the PCT paradigm, participants perform an ongoing task consisting of a series of trials in which they see a pair of images appear on the computer screen. In each trial, participants are asked to indicate whether the pairs of images are identical or different by pressing the corresponding key on a standard computer keyboard (“L” = identical; “D” = different). They are also asked to perform an additional task which consists of remembering to press a specific key on the keyboard (“Y”) when a picture of an animal appears on the screen. My block consists of 90 ongoing task trials and 6 additional task trials. The ongoing task trials are randomised.

**My problem:** I would like to randomize the 6 additional task trials but have them always appear at the same position, i.e. every 15 trials.

Any help with this would be hugely appreciated. 😃 🙏

Geoffrey

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [March 3, 2021, 6:47pm UTC](https://discourse.psychopy.org/t/randomly-but-always-on-the-same-position/20957/2 "2021-03-03T18:47:28Z")

</div>

So do you need to shuffle an array containing [0,1,2,3,4,5] and then select the task trial using [loopIdx%6] where loopIdx starts at -1 and adds 1 at the start of each loop.

---

<div class="post-metadata">

**Author:** ![gblondelle](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/gblondelle/32/13972_2.png) [@gblondelle](https://discourse.psychopy.org/u/gblondelle)\
**Post date:** [March 4, 2021, 10:53am UTC](https://discourse.psychopy.org/t/randomly-but-always-on-the-same-position/20957/3 "2021-03-04T10:53:08Z")

</div>

Thank you for your response @wakecarter !

Therefore it is necessary to insert a code in the loop with the loopldx function. At the moment my table contains both the 90 trials for the ongoing task and the 6 trials for the additional task. Could you suggest an example of code so that I can apply this function to the paradigm?

Here is an example of my paradigm and the spreadsheet in question below:

[PCT\_task.psyexp](https://discourse.psychopy.org/uploads/short-url/19TOpEV7JFUwJug1EsHlLw4wGq5.psyexp) (33.5 KB) [Stimulus\_test.xlsx](https://discourse.psychopy.org/uploads/short-url/8aGKjQH3wXfuS6Ne8h1GKgxWBnA.xlsx) (12.0 KB)
