Reaction Time and Audio File Questions


Author
Message
christinahaywood
christinahaywood
Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)
Group: Forum Members
Posts: 12, Visits: 59
I am writing a script where I would like to have a ball bouncing continuously on the screen for 2 minutes. For this block, the participant will be instructed to tap the space key when the ball hits the bottom of the screen.

1. I would like to record reaction time data, but I am unsure of how to go about doing this.

2. Is there any way that I can make a sound appear whenever the keyboard is tapped during this block?

Thanks!
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
> I am writing a script where I would like to have a ball bouncing continuously on the screen for 2 minutes. For this block, the participant will
> be instructed to tap the space key when the ball hits the bottom of the screen.

You can have a <video> displaying the bouncing ball displayed during the entire <block> using its /bgstim attribute. You'll also want the <block>'s /timeout to 120000 (2 minutes).

> 1. I would like to record reaction time data, but I am unsure of how to go about doing this.

Have the <block> run a single <trial> that does not display any stimuli, but mere allows for pressing the space bar. If you want latencies relative to the start of the <block>, you can log the block's elapsedtime property to the data file.

> 2. Is there any way that I can make a sound appear whenever the keyboard is tapped during this block?

Yes. You can play back a sound via the <trial>'s /responsemessage attribute.

In a nutshell:

<block myblock>
/ bgstim = (bouncingballvideo)
/ trials = [1=keypresstrial]
/ timeout = 120000
</block>

<trial keypresstrial>
/ isvalidresponse = [{values.rt_relative_to_blockstart = block.myblock.elapsedtime; trial.keypresstrial.response == 57}]
/ branch = [trial.keypresstrial]
/ responsemessage = (57,systembeep, 50)
</trial>

<video bouncingballvideo>
/ items = ("bouncingball.mpg")
/ playthrough = false
/ loop = true
/ erase = false
/ size = (100%, 100%)
</video>

<values>
/ rt_relative_to_blockstart = -1
</values>

<data>
/ columns = [date time subject group blocknum blockcode trialnum trialcode response latency values.rt_relative_to_blockstart]
/ separatefiles = true
</data>

As for scripts in the library, the "Inattentional Blindness Task" is similar in nature and worth taking a look at:

https://www.millisecond.com/download/library/InattentionalBlindness/


christinahaywood
christinahaywood
Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)
Group: Forum Members
Posts: 12, Visits: 59
So far I've coded the ball bouncing using two trials (one where the ball bounces fast and the other where it bounces slow). I also have an mp3 sound file that I want to use for the response noise instead of systembeep. Here is what I've coded so far, but when I run the script I am unable to hear the sound when I press the space bar.

Second question is - how can I change the input from spacebar to a mouse click?

Thanks!



<block sync>
/ trials = [1-12 = random(slow,fast), taprecording]
</block>

<trial taprecording>
/ isvalidresponse = [{values.rt_relative_to_blockstart = block.sync.elapsedtime; trial.taprecording.response == 57}]
/ branch = [trial.taprecording]
/ responsemessage = (57,Jump_Sound.mp3, 50)

<values>
/ rt_relative_to_blockstart = -1
</values>

<data>
/ columns = [date time subject group blocknum blockcode trialnum trialcode response latency values.rt_relative_to_blockstart]
/ separatefiles = true
</data>




<trial fast>
/ pretrialpause = replace(0-850)
/ stimulustimes = [
 0=ball10, table;
15=blank10, ball12.5;
30=blank12.5, ball15;
45=blank15, ball17.5;
60=blank17.5, ball20;
75=blank20, ball17.5;
90=blank17.5, ball15;
105=blank15, ball12.5;
120=blank12.5, ball10;
/ validresponse = (noresponse)
/ timeout = 120
</trial>

<trial slow>
/ pretrialpause = replace(0-1105)
/ stimulustimes = [
 0=ball10, table;
20=blank10, ball12.5;
40=blank12.5, ball15;
60=blank15, ball17.5;
80=blank17.5, ball20;
100=blank20, ball17.5;
120=blank17.5, ball15;
140=blank15, ball12.5;
160=blank12.5, ball10;
/ validresponse = (noresponse)
/ timeout = 160
</trial>




<picture ball20>
/ items = ("ball.png")
/ position = (70,20)
/ valign = top
/ size = (12%,12%)
</picture>

<shape blank20>
/ shape = rectangle
/ position = (70,20)
/ color = black
/ valign = top
/ size = (12%,12%)
</shape>

<picture ball17.5>
/ items = ("ball.png")
/ position = (70,17.5)
/ valign = top
/ size = (12%,12%)
</picture>

<shape blank17.5>
/ shape = rectangle
/ position = (70,17.5)
/ color = black
/ valign = top
/ size = (12%,12%)
</shape>

<picture ball15>
/ items = ("ball.png")
/ position = (70,15)
/ valign = top
/ size = (12%,12%)
</picture>

<shape blank15>
/ shape = rectangle
/ position = (70,15)
/ color = black
/ valign = top
/ size = (12%,12%)
</shape>

<picture ball12.5>
/ items = ("ball.png")
/ position = (70,12.5)
/ valign = top
/ size = (12%,12%)
</picture>

<shape blank12.5>
/ shape = rectangle
/ position = (70,12.5)
/ color = black
/ valign = top
/ size = (12%,12%)
</shape>

<picture ball10>
/ items = ("ball.png")
/ position = (70,10)
/ valign = top
/ size = (12%,12%)
</picture>

<shape blank10>
/ shape = rectangle
/ position = (70,10)
/ color = black
/ valign = top
/ size = (12%,12%)
</shape>

<picture table>
/ items = ("table1.png")
/ position = (70,20)
/ valign = top
/ erase = false
/ size = (20%, 20%)


christinahaywood
christinahaywood
Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)
Group: Forum Members
Posts: 12, Visits: 59
Ok so I figured out the sound issue, but is there any way to get two trials to play simultaneously?

<block sync>
/ preinstructions = (intro1sync)
/ trials = [1-12=random(slow,fast); 1-12=taprecording]
</block>

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
> [...]  is there any way to get two trials to play simultaneously?

No.

christinahaywood
christinahaywood
Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)
Group: Forum Members
Posts: 12, Visits: 59
Following the code you wrote above, I've created the manipulation. However, I would like to change the input from spacebar to a simple mouse click. How can I do this specifically for trial.trialname.response in the isvalidresponse attribute? When I type mouse it does not work.

<trial taprecordingA>
/ isvalidresponse = [{values.rt_relative_to_blockstart = block.recordingA.elapsedtime; trial.taprecordingA.response == mouse}]
/ branch = [trial.taprecordingA]
/ responsemessage = (mouse,bounce,200-250)

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
You need to set the <trial>'s /inputdevice to either mouse or mousekey.

You need to specify a valid mouse event as detailed in the documentation for the /validresponse attribute. By "simple click" you probably mean pressing the left mouse button. The event for that is "leftbuttondown".

<trial taprecordingA>
/ inputdevice = mousekey
/ isvalidresponse = [{values.rt_relative_to_blockstart = block.recordingA.elapsedtime; trial.taprecordingA.response == "lbuttondown"}]
/ branch = [trial.taprecordingA]
/ responsemessage = (lbuttondown,bounce,200-250)
christinahaywood
christinahaywood
Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)Expert (1.4K reputation)
Group: Forum Members
Posts: 12, Visits: 59
Hi, 

I've changed my input device from keyboard to mouse using the code above, however, whenever I click the mouse it pauses my video of the ball bouncing. It does not do this when i set the input to keyboard. Why might this be, and how could I go about setting my input device to mousekey while making sure it does not pause my video?

Here is the script:

<block recordingA>
/ trials = [1=taprecordingA]
/ bgstim = (ballbouncevideo_A)
/ timeout = 60000
</block>

<trial taprecordingA>
/ inputdevice = mousekey
/ isvalidresponse = [{values.rt_relative_to_blockstart = block.recordingA.elapsedtime; trial.taprecordingA.response == "lbuttondown" }]
/ branch = [trial.taprecordingA]
/ responsemessage = (lbuttondown,bounce,200)
</trial>

<values>
/ rt_relative_to_blockstart = -1
</values>

<video ballbouncevideo_A>
/ items = ("PatternAVideo.mp4")
/ position = (50%, 50%)
/ size = (100%, 100%)
</video>

<sound bounce>
/ items = ("Jump_Sound.mp3")
/ resetinterval = 200
</sound>


Thanks.
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
I don't have your video, so I had to plug in some other, arbitrary mp4 I had lying around. I am unable to reproduce this. The video plays uninterrupted upon mouse click for me. I'll point out though, that you should use a <video> element -- not <sound> -- to play back the mp3 "bounce" sound. Please check if this makes any difference.

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
One more thought what might be going on here. If you're running this on a Mac, it's possible that the OS's media display subsystem interprets mouse clicks as commands (and e.g. briefly pauses the video when the mouse button is pressed / until it's released).

I'm not near a Mac right now, but perhaps one can work around this by overlaying some transparent stimulus and defining that as the valid response. I.e.

<block recordingA>
/ trials = [1=taprecordingA]
/ bgstim = (ballbouncevideo_A)
/ timeout = 60000
</block>

<trial taprecordingA>
/ stimulusframes = [1=click]
/ inputdevice = mouse
/ isvalidresponse = [{values.rt_relative_to_blockstart = block.recordingA.elapsedtime; trial.taprecordingA.response == "click" }]
/ branch = [trial.taprecordingA]
/ responsemessage = ("click",bounce,200)
</trial>

<picture click>
/ items = ("transparent.png")
/ size = (100%, 100%)
/ erase = false
</picture>

<values>
/ rt_relative_to_blockstart = -1
</values>

<video ballbouncevideo_A>
/ items = ("PatternAVideo.mp4")
/ position = (50%, 50%)
/ size = (100%, 100%)
</video>

<video bounce>
/ items = ("Jump_Sound.mp3")
</video>

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search