How do I code an audio pulse or pre-pulse into Psychopy?

73 views
Skip to first unread message

kr15t3n86

unread,
Feb 22, 2016, 12:01:15 PM2/22/16
to psychopy-users
Hello,

I am developing a pre-pulse inhibition experiment via Psychopy.

I will need 70dB white noise as a constant background noise and then 2 pulses (90db; 115dB) to occur at random/varying ITIs.

I am able to get the 70dB constant audio file to play but cannot seem to figure out how to add larger/varying pulses of sound throughout each block. I also attemted to use a few code components from similar questions.

Please help! Thank you!


Jeremy Gray

unread,
Feb 22, 2016, 12:13:45 PM2/22/16
to psychop...@googlegroups.com
For the bursts within a trial, just use a normal sound component, no code. If that does not work, please describe what happens.


--Jeremy

--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/5c1a7f5b-bfe9-44dd-9c9f-0fb5e936a4a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Richard Höchenberger

unread,
Feb 22, 2016, 12:32:07 PM2/22/16
to psychop...@googlegroups.com
On Mon, Feb 22, 2016 at 6:13 PM, Jeremy Gray <jrg...@gmail.com> wrote:
> For the bursts within a trial, just use a normal sound component, no code. I

I am wondering if the "background noise" should be stopped at
precisely the moment the "target noise" starts playing. Otherwise,
background and target might partially cancel each other out, i.e. the
resulting signal amplitude would vary. But maybe I'm mistaken.

I would, in any case, strongly encourage you to verify very carefully
the duration of the presented stimuli. I don't know what kind of
experiment you are planning, but for example in TOJ and SJ tasks,
stimulus duration affects perceived simultaneity.

Good luck,

Richard

Jeremy Gray

unread,
Feb 22, 2016, 1:28:02 PM2/22/16
to psychop...@googlegroups.com

> For the bursts within a trial, just use a normal sound component, no code. I

I am wondering if the "background noise" should be stopped at
precisely the moment the "target noise" starts playing.

Naw, not needed and too hard.
 
Otherwise, background and target might partially cancel each other out, i.e. the
resulting signal amplitude would vary. 

I could see this happening for some sound stimuli, but for white noise (with one of them being so much louder than the other) I don't think it will matter. Still, I agree its a good idea to check the sound level of the loud stimuli. That is, do your calibrations under actual field conditions, not just per-stimulus.

--Jeremy

kr15t3n86

unread,
Feb 22, 2016, 2:04:01 PM2/22/16
to psychopy-users
Hi Jeremy, 

Thanks for responding! I have tried creating a normal sound component without code.
Essentially, the constant white noise plays at 70dB, but the "bursts" of 115dB with varying ITIs do not present. I have volume set at 1 (calibrated per sound meter at 115dB) and the sound pulling from my whitenoise.wav, both set at every repeat. The 115dB is set to start at 0(s) and last .05(ms) at varying ITIS (18-25s).

Ideally, I would like the 115dB to present "on top" of the 70dB randomly (18-25s).

Eventually, I will need to present a weaker stimulus (90dB) before the loud stimulus (115dB) while 70dB is playing constant.

Any suggestions?

Jeremy Gray

unread,
Feb 22, 2016, 2:16:20 PM2/22/16
to psychop...@googlegroups.com
I am not sure why its not playing, but one possibility is that playing the 70dB sound stops anything else from happening. This is probably the case if you are using a Builder sound component to play the background 70dB sound.

You'll probably need to start the 70bD sound using a code component instead, something like this (untested):

white_noise_array = random(...)  # see earlier email
wn70db = sound.Sound(white_noise_array, loops=10000)

That should start the sound, and keep playing in the background while you do other things in your experiment, like play other sounds.


--Jeremy

kr15t3n86

unread,
Feb 22, 2016, 2:18:56 PM2/22/16
to psychopy-users
Thank you! I will give it a whirl.

Richard Höchenberger

unread,
Feb 22, 2016, 3:56:43 PM2/22/16
to psychop...@googlegroups.com
On Mon, Feb 22, 2016 at 8:16 PM, Jeremy Gray <jrg...@gmail.com> wrote:
> I am not sure why its not playing, but one possibility is that playing the
> 70dB sound stops anything else from happening. This is probably the case if
> you are using a Builder sound component to play the background 70dB sound.

I just tried playing one sound component "on top of another" in
Builder, and this is working fine on OS X using the pygame backend
with two wav files. (Couldn't get pyo to work)

Richard

Kristen Frosio

unread,
Feb 22, 2016, 4:12:26 PM2/22/16
to psychop...@googlegroups.com

Richard,

Thanks! Could you teach me how to do that?


--
You received this message because you are subscribed to a topic in the Google Groups "psychopy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psychopy-users/GOd3m29-DZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to psychopy-user...@googlegroups.com.

To post to this group, send email to psychop...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--

Kristen Frosio

Richard Höchenberger

unread,
Feb 22, 2016, 5:31:36 PM2/22/16
to psychop...@googlegroups.com
On Mon, Feb 22, 2016 at 10:12 PM, Kristen Frosio
<kriste...@gmail.com> wrote:
> Thanks! Could you teach me how to do that?

Err well, for my test I just added two Sound Components, each assigned
with a different wave file. The first one was set to start at 0 s, and
the other one at 0.2 s. For the first 0.2 s, the first component would
play alone, and after 0.2 s, the second component would start to play,
with the first continuing to play in the background.

Does that help you in any way?

Richard

Kristen Frosio

unread,
Feb 22, 2016, 5:39:11 PM2/22/16
to psychop...@googlegroups.com
Yes! I will give it a try. Perhaps it's just starting the "loud burst" after 0.0 (e.g., .2)

THANK YOU, kindly.

Kristen

Kristen E. Frosio
Clinical Psychology Graduate Student
Laboratory of Emotion and Psychophysiology
Oklahoma State University
Email: kristen...@okstate.edu

CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may contain confidential and privileged information that is only to be used by the designated recipient(s) above. You are hereby notified that any review, disclosure, dissemination, distribution, or copying of it or its contents is prohibited. If you have received this communication in error, please contact the sender immediately and destroy all copies of this communication and any included attachments.



    Richard

--
You received this message because you are subscribed to a topic in the Google Groups "psychopy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psychopy-users/GOd3m29-DZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

Kristen Frosio

unread,
Feb 22, 2016, 8:08:42 PM2/22/16
to psychop...@googlegroups.com
Hi,

Here are some screenshots of what I have and the error message.

Mind you, I need to have "Start" time set to $ITIs in order to have the "loud bursts" delivered at varying time intervals.

Please advise.

Kristen E. Frosio
Clinical Psychology Graduate Student
Laboratory of Emotion and Psychophysiology
Oklahoma State University
Email: kristen...@okstate.edu

CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may contain confidential and privileged information that is only to be used by the designated recipient(s) above. You are hereby notified that any review, disclosure, dissemination, distribution, or copying of it or its contents is prohibited. If you have received this communication in error, please contact the sender immediately and destroy all copies of this communication and any included attachments.


overlap00.png
overlap0.png
overlapping error1.png

Michael MacAskill

unread,
Feb 22, 2016, 8:43:57 PM2/22/16
to psychop...@googlegroups.com
Dear Kristen,

This error is simply because PsychoPy can't find your sound files. If you are just specifying their file names (without any folder names), then they need to be in the same folder as the Builder .psyexp file itself.

Also,

— they don't change, so set them to be "constant" rather than set every repeat.

— the volume for one is set at 0.01, so might not be audible…

— not sure what effect setting a long duration (360 s) has for a .wav if it isn't actually 360 s long…

Regards,

Michael


> On 23/02/2016, at 14:08, Kristen Frosio <kriste...@gmail.com> wrote:
>
> Hi,
>
> Here are some screenshots of what I have and the error message.
>
> Mind you, I need to have "Start" time set to $ITIs in order to have the "loud bursts" delivered at varying time intervals.
>
> Please advise.
>
> Kristen E. Frosio
> Clinical Psychology Graduate Student
> Laboratory of Emotion and Psychophysiology
> Oklahoma State University
> Email: kristen...@okstate.edu

--
Michael R. MacAskill, PhD 66 Stewart St
Research Director, Christchurch 8011
New Zealand Brain Research Institute NEW ZEALAND

Senior Research Fellow, michael....@nzbri.org
Te Whare Wānanga o Otāgo, Otautahi Ph: +64 3 3786 072
University of Otago, Christchurch http://www.nzbri.org/macaskill

Richard Höchenberger

unread,
Feb 23, 2016, 10:07:39 AM2/23/16
to psychop...@googlegroups.com

Hello Kristen,

this may seem too simple, but: Have you considered playing the background noise using an ordinary audio player, i.e., outside of PsychoPy? That's the way we present background noise in many of our experiments. You would then be able to focus your PsychoPy experimental design on the actual stimulation.

    Richard

--
Sent from my cell phone.

Kristen Frosio

unread,
Feb 23, 2016, 3:11:56 PM2/23/16
to psychop...@googlegroups.com
Hi Michael,

I put the file pathways in place and it seemed to work well, the white noise plays in the background and the "loud burst" is delivered simultaneously. However, I cannot seem to figure out why my condition file with the varying ITIs ($ITIs) I'd like the "loud burst" to occur during will not go through. More, specifically, after one loud burst there are no more loud bursts.

Any thoughts?
 
Thanks for your help. Really appreciate it.

Kristen E. Frosio
Clinical Psychology Graduate Student
Laboratory of Emotion and Psychophysiology
Oklahoma State University
Email: kristen...@okstate.edu

CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may contain confidential and privileged information that is only to be used by the designated recipient(s) above. You are hereby notified that any review, disclosure, dissemination, distribution, or copying of it or its contents is prohibited. If you have received this communication in error, please contact the sender immediately and destroy all copies of this communication and any included attachments.

--
You received this message because you are subscribed to a topic in the Google Groups "psychopy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psychopy-users/GOd3m29-DZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

Kristen Frosio

unread,
Feb 23, 2016, 3:12:40 PM2/23/16
to psychop...@googlegroups.com
Hi Richard,

Thanks for the reply. Unfortunately, for this pre-pulse inhibition experiment I need the white noise to play in the headphones for acclimation and proper buffering.

Kristen E. Frosio
Clinical Psychology Graduate Student
Laboratory of Emotion and Psychophysiology
Oklahoma State University
Email: kristen...@okstate.edu

CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may contain confidential and privileged information that is only to be used by the designated recipient(s) above. You are hereby notified that any review, disclosure, dissemination, distribution, or copying of it or its contents is prohibited. If you have received this communication in error, please contact the sender immediately and destroy all copies of this communication and any included attachments.


--
You received this message because you are subscribed to a topic in the Google Groups "psychopy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psychopy-users/GOd3m29-DZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

Kristen Frosio

unread,
Feb 23, 2016, 3:15:53 PM2/23/16
to psychop...@googlegroups.com
Inline image 1



Inline image 2
Inline image 3

Kristen E. Frosio
Clinical Psychology Graduate Student
Laboratory of Emotion and Psychophysiology
Oklahoma State University
Email: kristen...@okstate.edu

CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may contain confidential and privileged information that is only to be used by the designated recipient(s) above. You are hereby notified that any review, disclosure, dissemination, distribution, or copying of it or its contents is prohibited. If you have received this communication in error, please contact the sender immediately and destroy all copies of this communication and any included attachments.


Michael MacAskill

unread,
Feb 23, 2016, 3:16:29 PM2/23/16
to psychop...@googlegroups.com

> On 24/02/2016, at 09:11, Kristen Frosio <kriste...@gmail.com> wrote:
>
> However, I cannot seem to figure out why my condition file with the varying ITIs ($ITIs) I'd like the "loud burst" to occur during will not go through. More, specifically, after one loud burst there are no more loud bursts.

Dear Karen,

Your message above is not a sufficiently-detailed description of either what you are doing or what has gone wrong.

Regards,

Michael

Kristen Frosio

unread,
Feb 23, 2016, 3:22:05 PM2/23/16
to psychop...@googlegroups.com
Hi Michael,

My apologies.

Placing the file pathway [C:\\PPI\whitenoise.wav] in sound helped pull the file. So, now I have 70dB white noise playing constantly and have heard one 115db "loud burst" occur during the 70dB constant.

However, the program is not implementing my condition file wherein I have varying interstimulus seconds that I would like the 115dB to be deliverd (see pictures) throughout the experimental block.

I am delivering 9 "loud bursts" 115dB vith varying 18-25 second inter-stimulus intervals. I can get one burst to occur, but not the other 8. 

Does this make sense? Thank you!



Kristen E. Frosio
Clinical Psychology Graduate Student
Laboratory of Emotion and Psychophysiology
Oklahoma State University
Email: kristen...@okstate.edu

CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may contain confidential and privileged information that is only to be used by the designated recipient(s) above. You are hereby notified that any review, disclosure, dissemination, distribution, or copying of it or its contents is prohibited. If you have received this communication in error, please contact the sender immediately and destroy all copies of this communication and any included attachments.


--
You received this message because you are subscribed to a topic in the Google Groups "psychopy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psychopy-users/GOd3m29-DZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

Richard Höchenberger

unread,
Feb 23, 2016, 3:38:47 PM2/23/16
to psychop...@googlegroups.com
Hi Kristen,

On Tue, Feb 23, 2016 at 9:12 PM, Kristen Frosio <kriste...@gmail.com> wrote:
> Unfortunately, for this pre-pulse inhibition experiment I need the white
> noise to play in the headphones for acclimation and proper buffering

I do not see how that should prevent you from playing the background
noise via e.g. Windows Media Player?

Richard

Kristen Frosio

unread,
Feb 23, 2016, 3:43:44 PM2/23/16
to psychop...@googlegroups.com
It's easier to use psychopy for calibrating the volume of the white noise, whether it be for background dB or pulse-alone (115dB) trials. Luckily Psychopy (as per sound meter measures) is ~70dB at .01 volume and ~115dB at 1 volume.



Kristen E. Frosio
Clinical Psychology Graduate Student
Laboratory of Emotion and Psychophysiology
Oklahoma State University
Email: kristen...@okstate.edu

CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may contain confidential and privileged information that is only to be used by the designated recipient(s) above. You are hereby notified that any review, disclosure, dissemination, distribution, or copying of it or its contents is prohibited. If you have received this communication in error, please contact the sender immediately and destroy all copies of this communication and any included attachments.


--
You received this message because you are subscribed to a topic in the Google Groups "psychopy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psychopy-users/GOd3m29-DZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.

Michael MacAskill

unread,
Feb 23, 2016, 6:33:46 PM2/23/16
to psychop...@googlegroups.com

> On 24/02/2016, at 09:22, Kristen Frosio <kriste...@gmail.com> wrote:
>
> However, the program is not implementing my condition file wherein I have varying interstimulus seconds that I would like the 115dB to be deliverd (see pictures) throughout the experimental block.
>
> I am delivering 9 "loud bursts" 115dB vith varying 18-25 second inter-stimulus intervals. I can get one burst to occur, but not the other 8.
Dear Karen,

I'm surprised it is working at all. It look like the trial has been specified to last $ITIS seconds but also that the onset of the pulse should be at $ITIS, which makes it coincide with the end of the trial.

But we still don't have a very good description of what is happening. Are the 8 remaining trials continuing to run, without the pulse? Are there any error messages? What does the loop dialog look like?

Maybe it is just an artefact, but it also looks like in one of your dialogs, you specify '$ITIs' rather than '$ITIS'. But that would likely have caused an error message on the first pulse.
Reply all
Reply to author
Forward
0 new messages