.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/repeat-chirp.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_repeat-chirp.py: Repeating a stimulus ==================== This demonstrates how to generate stimuli for an interleaved chirp as described by Keefe et al. .. GENERATED FROM PYTHON SOURCE LINES 8-77 .. image-sg:: /gallery/images/sphx_glr_repeat-chirp_001.png :alt: repeat chirp :srcset: /gallery/images/sphx_glr_repeat-chirp_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from psiaudio import calibration, stim, util cal = calibration.FlatCalibration.as_attenuation() fs = 100e3 elicitor = stim.RepeatFactory( fs=fs, n=4, skip_n=0, rate=1/250e-3, delay=0, input_factory=stim.Cos2EnvelopeFactory( fs=fs, duration=150e-3, rise_time=5e-3, start_time=50e-3, input_factory=stim.BandlimitedNoiseFactory( fs=fs, seed=1, level=0, fl=8e3, fh=16e3, filter_rolloff=0.5, passband_attenuation=0.1, stopband_attenuation=90, polarity=1, calibration=cal, ) ) ) probe = stim.RepeatFactory( fs=fs, n=5, skip_n=0, rate=1/250e-3, delay=0, input_factory=stim.ChirpFactory( fs=fs, duration=2e-3, start_frequency=4e3, end_frequency=32e3, level=0, calibration=cal, ) ) figure, ax = plt.subplots(1, 1, figsize=(4, 4), constrained_layout=True) elicitor_waveform = elicitor.get_samples_remaining() t_elicitor = np.arange(len(elicitor_waveform)) / fs * 1e3 ax.plot(t_elicitor, elicitor_waveform) probe_waveform = probe.get_samples_remaining() t_probe = np.arange(len(probe_waveform)) / fs * 1e3 ax.plot(t_probe, probe_waveform) ax.set_xlabel('Time (msec)') ax.set_ylabel('Amplitude (Pascals)') plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.162 seconds) .. _sphx_glr_download_gallery_repeat-chirp.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: repeat-chirp.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: repeat-chirp.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: repeat-chirp.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_