3

Acoustic Stimulus

Embed Size (px)

DESCRIPTION

sound stimulus

Citation preview

Page 1: Acoustic Stimulus

3/27/2015 Acoustic stimulus

http://www.neural­code.com/index.php/tutorials/stimulus/sound/52­acoustic­stimulus 1/3

Acoustic stimulus

Although a large number of acoustic stimuli can be found on the experimental PC, it is often desirable to design your own. A number of MATLAB routines have been developed togenerate single channel wav­files.

CookbookIn principle, you need to:

1.  generate a signal2.  filter the signal3.  apply a ramp4.  check for setup idiosyncrasies5.  write the signal to a file

These steps are shown in figure 1, and described below.

Figure 1. Steps in generating an acoustic stimulus.

This figure is created with pa_how2createsounds_example

1. SignalThe following MATLAB routines can be used for the most frequently used stimulus types:

pa_gengwn ­ generate Gaussian White Noise (by defining a randomly distributed timesignal). This sound is most often used for sound localization experiments. See below for example.pa_gengwnflat ­ generate Gaussian White Noise (by defining a flat magnitude and randomphase in the frequency domain)pa_gensweep ­ generate a frequency sweep with a flat power spectrum. This is used to record head­related transfer functions.  Guide

pa_gentone ­ generate a pure tone, for sound elevation localization experimentspa_genripple ­ generate a ripple, for spectrotemporal­resolution electrophysiological and psychophysical measurements  Guide

pa_gendmr ­ generate dynamic moving ripple

For the hoop / sound localization setup, the sampling rate of the RP2.1 for DA­conversion is set at 48828.125 Hz, so that the inter­sampling distance is 20.48 μsec.

2. Filter

Page 2: Acoustic Stimulus

3/27/2015 Acoustic stimulus

http://www.neural­code.com/index.php/tutorials/stimulus/sound/52­acoustic­stimulus 2/3

After the generation of a signal, you generally want to filter your signal, either to bandpass your signal:

pa_lowpass ­ low­pass filter the signal (remove high­frequency frequencies that are not heard, to prevent aliasing, or for specific research questions)pa_highpass ­ high­pass filter the signal (important to remove low­frequency signals that usually end up distorted when played by the speaker)

or to equalize the signal:

pa_equalizer ­ so the played stimulus has a flat spectrum

3. RampTo prevent onset distortions, you need to ramp the data

pa_ramp ­ add a squared­sine onset and squared­cosine offset

4. Level RampBecause of an idiosyncrasy in our set­up, we need to pre­ and append 20 milliseconds of zeros to the signal. This is because the second TDT RP2.1 DA­channel is used to controlthe sound level. Switching this on will also create a sudden onset peak, that needs to be prevented. This is solved by a level­ramp within the RCO. We need to consider this level­ramp by applying:

pa_fart_levelramp

All steps (generation, filtering, equalizing, and ramping) can be done by TDT, but at present this takes precious time.

5. Save wav-fileAnd when this is done, we need to save the data, so that it can be used by the TDT system:

pa_ writewav ­ saves the stimulus as a wav file for the DA converter (this also applies a normalization)

You can check whether the stimulus generation has succeeded, with:

wavread ­ MATLAB routine to read an existing wav­file in MATLAB formataudioplayer ­ Matlab routine to play sounds (wavplay)psd ­ Matlab routine, to determine power spectral densitypa_getpower ­ get power spectrum

Some examplesLet‟s generate a GWN stimulus. Stimulus 3.0 sec, bandwidth from 0.5 to 20 kHz, with on­ and offset envelopes.In Matlab:

    Noise  = pa_gengwn(3); % Default envelope (250 pnts) and filter   % noise is lp‐filtered at 20 kHz   % and hp‐filtered at 500 Hz   psd(Noise);

Frequencies below 500 Hz are never useful, and produce distortions on speakers, so they should be filtered out with a highpass­filter. This is already done by default in gengwn.The GWN stimulus is a well­localizable sound eliciting all binaural difference (ITD and ILD) cues and spectral cues. Sometimes, it is desirable to use lowpass­ or highpass­filterednoise, to separate the effects of ITD and ILD. These sounds are created by generating a GWN as above, and filtering it with the functions lowpassnoise and highpassnoise:

   HP = pa_highpass(Noise); % noise is hp‐filtered at 3 kHz   psd(HP);   LP = pa_lowpass(Noise); % noise is lp‐filtered at 3 kHz   psd(LP);  

You might want to equalize the signal:

   Noise = pa_equalizer(Noise);

Page 3: Acoustic Stimulus

3/27/2015 Acoustic stimulus

http://www.neural­code.com/index.php/tutorials/stimulus/sound/52­acoustic­stimulus 3/3

  HP = pa_equalizer(HP);  LP = pa_equalizer(LP);

Then apply a ramp:

   Noise = pa_ramp(Noise);  HP = pa_ramp(HP);  LP = pa_ramp(LP);  

In the FART1­setup, speakers will have on onset ramp produced by the TDT­system to ramp to a voltage on the speakers. You will have to take this into account, by putting zeros infront of the stimuli (of about 20 ms worth 20*48.8828125 978 samples):

   Noise = pa_levelramp(Noise); %This "prepends" the zerovector to the Noise   HP = pa_levelramp(HP);   LP =  pa_levelramp(LP); 

After this, you should save the matrix to a wav­file, that can be played with the TDT­system:

   writewav(Noise,"snd001.wav);   writewav(HP,"snd002.wav");   writewav(LP,"snd003.wav");