How to give an audio feedback each time the participant press a specific key

89 views
Skip to first unread message

Apolline Durtette

unread,
Nov 29, 2022, 1:51:01 AM11/29/22
to E-Prime
Greetings, 

First of all thank you very much for welcoming me into this group. I hope to better understand all the possibilities offered by E-Prime through this community.

Concerning my current experience, I would like to enable an audio feedback (nothing too complicated, a simple "beep" would be sufficient) each time the participants would press a specific key (SPACE). It would be the only key he has acces to, but in order to avoid multiple responses from them, fearing they may have not pressed it correctly the key, we would like to offer them that feedback, this without any visual effects on the screen. 

I noticed that there is the possibility to code through some E-Prime tools. Unfortunately, I'm not very familiar with this exercise and would thus like to know if there is any particular coding line I could get inspiration from or even copy/paste at the beginning of my procedure in order to allow that.

Thanks you kindly for your responses and time, 

McFarlane, David

unread,
Nov 29, 2022, 11:45:40 AM11/29/22
to e-p...@googlegroups.com
Could you provide more detail on the design of your trials? Why is the subject asked to respond at all if the only allowed response is Space and nothing else happens when they respond? What sort of stimuli is the subject responding to? Thanks.

-- David McFarlane

Apolline Durtette

unread,
Nov 29, 2022, 12:22:57 PM11/29/22
to E-Prime
Hello again, 

The task follows the "N-back" paradigm : a list of letters will be presented and the participant is asked to click on a button (linked to the "SPACE" key) when he thinks that the target-stimuli appears on the screen. However, since we are in a quite noisy environment (MRI) we would like to provide him an audio feedback just to notice him that he did press the button well and doesn't need to press it again to indicate his answer (which could be dommageable since leading to multiple answering for the same object).

I hope these informations helped in clearing some points, thank you for your time !

Justin Raj

unread,
Nov 29, 2022, 1:01:15 PM11/29/22
to e-p...@googlegroups.com
Hi
Usually most of the MRI compatibility system will be having a reflection mirror with a screen behind the scanner, so through that it will be possible to identify feedback by the subjects. 

--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/b69baf4c-9272-4ef7-adef-f270c7f05bb7n%40googlegroups.com.

McFarlane, David

unread,
Nov 29, 2022, 2:44:06 PM11/29/22
to e-p...@googlegroups.com
OK this gives me something to work with ...

So on each trial the subject gets some stimulus. The stimulus remains for a fixed time whether or not the subject responds. For some stimuli the subject is to give no response, and for other stimuli the subject is to respond by pressing Space. Now you would like to play a beep at the time that the subject responds, without affecting the other timing.

If responses were to terminate the stimuli, or if you could play a beep after the stimulus times out, then you could simply follow the stimulus with a SoundOut object to play the beep. But to play the beep immediately after the response without affecting the stimulus timing does require some finesse.

I might do the following ...

My trial Procedure would look something like
- StimSlide
- FeedbackCode
- FeedbackSound
- PostFeedbackLabel

Since this is for MRI, I would set Timing Mode to "Cumulative" on each stimulus object (I explain this in my online E-Prime 2 course).

StimSlide presents the stimulus. Set PreRelease in this case to 0 (IMPORTANT!), so that the InLine code that follows does not run until the stimulus terminates. For the input mask, set Allowable to {SPACE}, Time Limit to "(same as duration)", and End Action to Terminate -- now when the subject responds with Space the Procedure will move on to FeedbackCode.

FeedbackCode runs InLine code as follows:

If StimSlide.RTTime Then
SetNextTargetOnsetTime StimSlide.TargetOnsetTime
Else
Goto PostFeedbackLabel
End If

Let's dissect that code a bit ...

"If StimSlide.RTTime" is just a compact way of saying "if the subject gave a response" (I could explain further if asked).

"SetNextTargetOnsetTime StimSlide.TargetOnsetTime" will make FeedbackSound behave as if it started at the same time as StimSlide, which will help us maintain our Procedure timing -- more on that below. (This assumes that you want the same effect as Cumulative timing mode -- if you wanted to enact Event timing mode, this line would instead read "SetNextTargetOnsetTime StimSlide.OnsetTime".)

"Goto PostFeedbackLabel" will skip the FeedbackSound when the subject does not give a response.

Moving on ...

FeedbackSound is a SoundOut object that presents the feedback sound. Set its Duration to the same Duration as StimSlide (IMPORTANT!) In FeedbackCode we make FeedbackSound act as if it started when StimSlide started, and because we give FeedbackSound the same Duration, it will now automatically fill in the remaining time of the stimulus. Meanwhile, it will play the feedback sound. I would probably set Stop After to "No" so that it will always play the full sound. End Sound must be set to "(none)" to prevent FeedbackSound ending early!

Finally, PostFeedbackLabel is a lowly Label object, so that we can skip past the feedback sound when the subject does not give a response.

There are of course other ways to achieve your goal. E.g., instead of FeedbackSound you could use a FeedbackSlide with two SlideStates, one which plays a sound and one which does not, and then your FeedbackCode would set an attribute to determine which SlideState to present, as well as fix the timing for the FeedbackSlide as above, but in this case you would not need a Goto or a Label -- I leave this as an exercise. But I think that the approach that I gave above requires a little less advanced knowledge.

I hope this helps.

Bonne chance,
-- David McFarlane

McFarlane, David

unread,
Nov 29, 2022, 2:51:02 PM11/29/22
to e-p...@googlegroups.com
BTW, I note that the careful indentation in my code shows up in some e-mail readers, but does not show up when viewing the Google Groups thread on the web. Sigh.

-- David McFarlane

Apolline Durtette

unread,
Dec 7, 2022, 8:31:29 AM12/7/22
to E-Prime
Hello again, 

I thank you sincerely for your answer. Unfortunately, even if this is closer to what my experiment looks like, it is still not quite right. Indeed, I need my participants to be able to respond at any time of the presentation (even during the stimulus) since it will be a list of items following each others. My typical procedure follows that construction :

-Stimulus (with a link to the [item])
-Mask (in order to avoid retinal reminiscence)
-Blank (to set the Inter-Stimuli Interval)

Which constitue a loop until all [item] (s) have been displayed.

I was thus wondering, if the InLine code couldn't be put at the begining (before the Stimulus object) in order to include it. I also need that playing the feedback sound doesn't end the procedure and go to the next one before the whole time is passed. More than that, the participant is allowed to answer during the Mask and the Blank (until the next stimulus in short).

Isn't there a simple coding procedure which could be described as something like :

If space.PRESS Then Feedbacksound.PLAY
End if

Or :

If stimulus(*).RESP Then Feedbacksound.PLAY
End if
(* with the same code being repeted for "mask" and "blank")

I don't know the correct code objects following the "." , but the ideas remains that pressing a specific key or just responding to a defined object will play the sound, this without shortening its display time.

Thank you again kindly for your time and attention, 


McFarlane, David

unread,
Dec 8, 2022, 2:35:18 PM12/8/22
to e-p...@googlegroups.com
Aha, so you want to start playback of a sound at some time during a *train* of stimuli. That does get trickier. You could accomplish this in a variety of ways, partly depending on whether you use EP2 or EP3 (hint: EP3 makes doing this much easier!).

The issue of making something happen at the time of a response to a stimulus comes up from time to time, and has been discussed in several threads -- see https://groups.google.com/d/topic/e-prime/1StV4j7Q6yw , which contains links to several other threads.

Unfortunately, those threads are now a bit out of date (e.g., using OnsetSignal instead of Task Events), and I do not think that we ever adequately discussed how to handle this during a *train* of stimuli. Those threads also specifically address sending a signal to external equipment, rather than playing a sound, but that is a minor difference.

So I will sketch out a few more ideas here ...

If you have EP3, then you could do this very elegantly with a combination of Extended Input (see Appendix C of the EP2 User's Guide) and Script Task Events -- you would set the Time Limit of the input mask from Stimulus to last throughout the trial, and attach a Task Event that will run a script to play the sound when the Space bar gets pushed.

EP2 has Task Events, but not Script Task Events, so you would have to manage this without Task Events at all. I have actually done this myself for some task designs, using a couple different approaches.

In my first approach, I added InLine code after each of the stimulus objects in the Procedure. Each object has PreRelease set to "(same as duration)", so that code runs during the presentation of each stimulus object, and Stimulus has the Time Limit of the input mask set to extend throughout the trial. Each InLine code object checks to see if a response has already been processed, and if not, it then runs a loop to detect any new response and then handle it.

It got a little tedious to manage multiple InLine objects, one for each stimulus object, each of which did something very similar. So then I came up with a different approach using only one InLine object placed at the end of the Procedure. I added Labels in front of everything except the first object (e.g., in front of Mask, Blank, and the final InLine), and set the End Action of my input mask to Jump to my InLine. My InLine code then handled any response, and either used a Goto to jump back to the appropriate place to continue running the Procedure, or continued to the end of the Procedure.

So a lot depends on whether you use EP2 or EP3 -- EP3 could definitely make your life easier here!

(Perhaps you are coming from a background in JavaScript, where you might implement the structure that you suggested by using a callback function attached to an event handler. And for all I know PsychoPy (which is free) could handle this in a similar fashion.)

-- David McFarlane
Reply all
Reply to author
Forward
0 new messages