# Random only for the first stimulus

**URL:** <https://psychtoolbox.discourse.group/t/random-only-for-the-first-stimulus/396>\
**Category:** Uncategorized\
**Created:** [November 19, 2012, 5:05pm UTC](https://psychtoolbox.discourse.group/t/random-only-for-the-first-stimulus/396 "2012-11-19T17:05:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![emiliecaspar](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@emiliecaspar](https://psychtoolbox.discourse.group/u/emiliecaspar)\
**Post date:** [November 19, 2012, 5:05pm UTC](https://psychtoolbox.discourse.group/t/random-only-for-the-first-stimulus/396/1 "2012-11-19T17:05:08Z")

</div>

Hello everybody!  
  
I'm trying to program an "alea command", in the way to introduce a random choice of stimuli, but ONLY for the first stimulus. You can see the basic script in the files ('Script Libet').  
  
  
But the problem is this one :   
The first stimulus must be random (the first position on the clock must vary), but the second, the third, etc must continue according to the first stimulus.  
For example: if the first stimulus is Pos23, then must appear Pos24, Pos25, etc.  
  
I have try that command, but without success.   
  
for i=1:nItems   
alea=randperm(60);  
items=items(alea);  
Screen('drawtexture', w, tex(i))  
vbl=Screen(w, 'Flip', vbl+(2.5\*cycleRefresh));  
KbCheck;  
end  
  
Thank you :)

---

<div class="post-metadata">

**Author:** ![gennaer](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@gennaer](https://psychtoolbox.discourse.group/u/gennaer)\
**Post date:** [November 19, 2012, 6:33pm UTC](https://psychtoolbox.discourse.group/t/random-only-for-the-first-stimulus/396/2 "2012-11-19T18:33:39Z")

</div>

I'm not entirely sure what you mean, but perhaps this is what you want:  
  
startingPosition = randi(numberOfPositions);  
positionOrder = [startingPosition:numberOfPositions 1:startingPosition-1];  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "emiliecaspar" \<emiliecaspar@...\> wrote:  
> \>  
> \> Hello everybody!  
> \>   
> \> I'm trying to program an "alea command", in the way to introduce a random choice of stimuli, but ONLY for the first stimulus. You can see the basic script in the files ('Script Libet').  
> \>   
> \>   
> \> But the problem is this one :   
> \> The first stimulus must be random (the first position on the clock must vary), but the second, the third, etc must continue according to the first stimulus.  
> \> For example: if the first stimulus is Pos23, then must appear Pos24, Pos25, etc.  
> \>   
> \> I have try that command, but without success.   
> \>   
> \> for i=1:nItems   
> \> alea=randperm(60);  
> \> items=items(alea);  
> \> Screen('drawtexture', w, tex(i))  
> \> vbl=Screen(w, 'Flip', vbl+(2.5\*cycleRefresh));  
> \> KbCheck;  
> \> end  
> \>   
> \> Thank you :)  
> \>

---

<div class="post-metadata">

**Author:** ![emiliecaspar](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@emiliecaspar](https://psychtoolbox.discourse.group/u/emiliecaspar)\
**Post date:** [November 20, 2012, 1:48pm UTC](https://psychtoolbox.discourse.group/t/random-only-for-the-first-stimulus/396/3 "2012-11-20T13:48:36Z")

</div>

Maybe more precisions on the script : I use 60 pictures (named Pos0 --\> Pos59), which represent the 60 positions on the seconds on a clock. So, the positions must follow always the same order. But, I need that the first picture is random. For example, if the program choses the picture corresponding to the 21 on the clock, then the next stimulus must be 22 on the clock, etc.   
  
I could create 60 different external lists, but I'm sure that there is an easier solution.   
  
Maybe if I indicate the sequential order of the pictures (for example with something like "positionorder") in the script, I can then ask to take one stimulus at random in that list, but then to present the picture +1.  
But I have absolutely not idea how to do that.  
  
  
  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "gennaer" \<gennaer@...\> wrote:  
> \>  
> \> I'm not entirely sure what you mean, but perhaps this is what you want:  
> \>   
> \> startingPosition = randi(numberOfPositions);  
> \> positionOrder = [startingPosition:numberOfPositions 1:startingPosition-1];  
> \>   
> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "emiliecaspar" \<emiliecaspar@\> wrote:  
> \> \>  
> \> \> Hello everybody!  
> \> \>   
> \> \> I'm trying to program an "alea command", in the way to introduce a random choice of stimuli, but ONLY for the first stimulus. You can see the basic script in the files ('Script Libet').  
> \> \>   
> \> \>   
> \> \> But the problem is this one :   
> \> \> The first stimulus must be random (the first position on the clock must vary), but the second, the third, etc must continue according to the first stimulus.  
> \> \> For example: if the first stimulus is Pos23, then must appear Pos24, Pos25, etc.  
> \> \>   
> \> \> I have try that command, but without success.   
> \> \>   
> \> \> for i=1:nItems   
> \> \> alea=randperm(60);  
> \> \> items=items(alea);  
> \> \> Screen('drawtexture', w, tex(i))  
> \> \> vbl=Screen(w, 'Flip', vbl+(2.5\*cycleRefresh));  
> \> \> KbCheck;  
> \> \> end  
> \> \>   
> \> \> Thank you :)  
> \> \>  
> \>

---

<div class="post-metadata">

**Author:** ![dcnieho](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@dcnieho](https://psychtoolbox.discourse.group/u/dcnieho)\
**Post date:** [November 20, 2012, 2:27pm UTC](https://psychtoolbox.discourse.group/t/random-only-for-the-first-stimulus/396/4 "2012-11-20T14:27:41Z")

</div>

gennear's solution does just what you describe. If you don't know how to do that, you better find someone near you that you can talk to in person to figure things out. Its unlikely anyone on the list will write the script for you.

 

Best,

Dee  
  

> 

On Tue, Nov 20, 2012 at 9:48 PM, emiliecaspar \<[emiliecaspar@...](mailto:emiliecaspar@...)\> wrote:  

> Maybe more precisions on the script : I use 60 pictures (named Pos0 --\> Pos59), which represent the 60 positions on the seconds on a clock. So, the positions must follow always the same order. But, I need that the first picture is random. For example, if the program choses the picture corresponding to the 21 on the clock, then the next stimulus must be 22 on the clock, etc.   
>   
> I could create 60 different external lists, but I'm sure that there is an easier solution.   
>   
> Maybe if I indicate the sequential order of the pictures (for example with something like "positionorder") in the script, I can then ask to take one stimulus at random in that list, but then to present the picture +1.  
> But I have absolutely not idea how to do that.
> 
>   
>   
> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox%40yahoogroups.com), "gennaer" \<gennaer@...\> wrote:  
> \>  
> \> I'm not entirely sure what you mean, but perhaps this is what you want:  
> \>   
> \> startingPosition = randi(numberOfPositions);  
> \> positionOrder = [startingPosition:numberOfPositions 1:startingPosition-1];  
> \>   
> 
> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox%40yahoogroups.com), "emiliecaspar" \<emiliecaspar@\> wrote:  
> \> \>  
> \> \> Hello everybody!  
> \> \>   
> \> \> I'm trying to program an "alea command", in the way to introduce a random choice of stimuli, but ONLY for the first stimulus. You can see the basic script in the files ('Script Libet').  
> \> \>   
> \> \>   
> \> \> But the problem is this one :   
> \> \> The first stimulus must be random (the first position on the clock must vary), but the second, the third, etc must continue according to the first stimulus.  
> \> \> For example: if the first stimulus is Pos23, then must appear Pos24, Pos25, etc.  
> \> \>   
> \> \> I have try that command, but without success.   
> \> \>   
> \> \> for i=1:nItems   
> \> \> alea=randperm(60);  
> \> \> items=items(alea);  
> \> \> Screen('drawtexture', w, tex(i))  
> \> \> vbl=Screen(w, 'Flip', vbl+(2.5\*cycleRefresh));  
> \> \> KbCheck;  
> \> \> end  
> \> \>   
> \> \> Thank you :)  
> \> \>  
> \>

---

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [November 20, 2012, 2:42pm UTC](https://psychtoolbox.discourse.group/t/random-only-for-the-first-stimulus/396/5 "2012-11-20T14:42:49Z")

</div>

make a vector like this:  
  
randinum = % however you choose the starting value, ie randint()  
  
indexes = [randinum:60 1:(randinum-1)]  
  
for i = indexes  
  
% the rest of your for loop goes here  
  
end  
  
-----Original Message-----  
From: emiliecaspar [mailto:[emiliecaspar@...](mailto:emiliecaspar@...)]   
Sent: Tuesday, November 20, 2012 5:49 AM  
To: [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com)  
Subject: [psychtoolbox] Re: Random only for the first stimulus  
  
Maybe more precisions on the script : I use 60 pictures (named Pos0 --\>  
Pos59), which represent the 60 positions on the seconds on a clock. So, the  
positions must follow always the same order. But, I need that the first  
picture is random. For example, if the program choses the picture  
corresponding to the 21 on the clock, then the next stimulus must be 22 on  
the clock, etc.   
  
I could create 60 different external lists, but I'm sure that there is an  
easier solution.   
  
Maybe if I indicate the sequential order of the pictures (for example with  
something like "positionorder") in the script, I can then ask to take one  
stimulus at random in that list, but then to present the picture +1.  
But I have absolutely not idea how to do that.  
  
  
  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "gennaer" \<gennaer@...\> wrote:  
> \>  
> \> I'm not entirely sure what you mean, but perhaps this is what you want:  
> \>   
> \> startingPosition = randi(numberOfPositions); positionOrder =   
> \> [startingPosition:numberOfPositions 1:startingPosition-1];  
> \>   
> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "emiliecaspar" \<emiliecaspar@\> wrote:  
> \> \>  
> \> \> Hello everybody!  
> \> \>   
> \> \> I'm trying to program an "alea command", in the way to introduce a  
> random choice of stimuli, but ONLY for the first stimulus. You can see the  
> basic script in the files ('Script Libet').  
> \> \>   
> \> \>   
> \> \> But the problem is this one :   
> \> \> The first stimulus must be random (the first position on the clock must  
> vary), but the second, the third, etc must continue according to the first  
> stimulus.  
> \> \> For example: if the first stimulus is Pos23, then must appear Pos24,  
> Pos25, etc.  
> \> \>   
> \> \> I have try that command, but without success.   
> \> \>   
> \> \> for i=1:nItems   
> \> \> alea=randperm(60);  
> \> \> items=items(alea);  
> \> \> Screen('drawtexture', w, tex(i))  
> \> \> vbl=Screen(w, 'Flip', vbl+(2.5\*cycleRefresh)); KbCheck; end  
> \> \>   
> \> \> Thank you :)  
> \> \>  
> \>  
>    
>    
>    
>    
> ------------------------------------  
>    
> Post your message to: [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com) Please indicate OS9, OSX,  
> or WIN version, and include your full name.  
> Denis Pelli, David Brainard, and Allen Ingling.  
> [http://psychtoolbox.org](http://psychtoolbox.org)  
> Yahoo! Groups Links

---

<div class="post-metadata">

**Author:** ![emiliecaspar](https://avatars.discourse-cdn.com/v4/letter/e/aca169/32.png) [@emiliecaspar](https://psychtoolbox.discourse.group/u/emiliecaspar)\
**Post date:** [November 20, 2012, 3:01pm UTC](https://psychtoolbox.discourse.group/t/random-only-for-the-first-stimulus/396/6 "2012-11-20T15:01:33Z")

</div>

I'm going to try to use solutions described.   
Thank a lot for your answers!  
-Emilie  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "Alan Robinson" \<meetup@...\> wrote:  
> \>  
> \> make a vector like this:  
> \>   
> \> randinum = % however you choose the starting value, ie randint()  
> \>   
> \> indexes = [randinum:60 1:(randinum-1)]  
> \>   
> \> for i = indexes  
> \>   
> \> % the rest of your for loop goes here  
> \>   
> \> end  
> \>   
> \> -----Original Message-----  
> \> From: emiliecaspar [mailto:emiliecaspar@...]   
> \> Sent: Tuesday, November 20, 2012 5:49 AM  
> \> To: [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com)  
> \> Subject: [psychtoolbox] Re: Random only for the first stimulus  
> \>   
> \> Maybe more precisions on the script : I use 60 pictures (named Pos0 --\>  
> \> Pos59), which represent the 60 positions on the seconds on a clock. So, the  
> \> positions must follow always the same order. But, I need that the first  
> \> picture is random. For example, if the program choses the picture  
> \> corresponding to the 21 on the clock, then the next stimulus must be 22 on  
> \> the clock, etc.   
> \>   
> \> I could create 60 different external lists, but I'm sure that there is an  
> \> easier solution.   
> \>   
> \> Maybe if I indicate the sequential order of the pictures (for example with  
> \> something like "positionorder") in the script, I can then ask to take one  
> \> stimulus at random in that list, but then to present the picture +1.  
> \> But I have absolutely not idea how to do that.  
> \>   
> \>   
> \>   
> \>   
> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "gennaer" \<gennaer@\> wrote:  
> \> \>  
> \> \> I'm not entirely sure what you mean, but perhaps this is what you want:  
> \> \>   
> \> \> startingPosition = randi(numberOfPositions); positionOrder =   
> \> \> [startingPosition:numberOfPositions 1:startingPosition-1];  
> \> \>   
> \> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "emiliecaspar" \<emiliecaspar@\> wrote:  
> \> \> \>  
> \> \> \> Hello everybody!  
> \> \> \>   
> \> \> \> I'm trying to program an "alea command", in the way to introduce a  
> \> random choice of stimuli, but ONLY for the first stimulus. You can see the  
> \> basic script in the files ('Script Libet').  
> \> \> \>   
> \> \> \>   
> \> \> \> But the problem is this one :   
> \> \> \> The first stimulus must be random (the first position on the clock must  
> \> vary), but the second, the third, etc must continue according to the first  
> \> stimulus.  
> \> \> \> For example: if the first stimulus is Pos23, then must appear Pos24,  
> \> Pos25, etc.  
> \> \> \>   
> \> \> \> I have try that command, but without success.   
> \> \> \>   
> \> \> \> for i=1:nItems   
> \> \> \> alea=randperm(60);  
> \> \> \> items=items(alea);  
> \> \> \> Screen('drawtexture', w, tex(i))  
> \> \> \> vbl=Screen(w, 'Flip', vbl+(2.5\*cycleRefresh)); KbCheck; end  
> \> \> \>   
> \> \> \> Thank you :)  
> \> \> \>  
> \> \>  
> \>   
> \>   
> \>   
> \>   
> \> ------------------------------------  
> \>   
> \> Post your message to: [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com) Please indicate OS9, OSX,  
> \> or WIN version, and include your full name.  
> \> Denis Pelli, David Brainard, and Allen Ingling.  
> \> [http://psychtoolbox.org](http://psychtoolbox.org)  
> \> Yahoo! Groups Links  
> \>

---

<div class="post-metadata">

**Author:** ![makis6](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@makis6](https://psychtoolbox.discourse.group/u/makis6)\
**Post date:** [August 5, 2021, 8:16pm UTC](https://psychtoolbox.discourse.group/t/random-only-for-the-first-stimulus/396/7 "2021-08-05T20:16:19Z")

</div>

> [@emiliecaspar](#):
>
> Script Libet

Hi Emilie. Where can I find this script? I am also interested in the libet task
