示例#1
0
def test_textures():
    """Test stimulus textures."""
    texture_ERB()  # smoke test
    pytest.raises(TypeError, texture_ERB, seq='foo')
    pytest.raises(ValueError, texture_ERB, seq=('foo', ))
    with pytest.warns(UserWarning, match='LESS THAN 1 ERB'):
        x = texture_ERB(freq_lims=(200, 500))
    assert_allclose(len(x) / 24414., 4., rtol=1e-5)
示例#2
0
def test_textures():
    """Test stimulus textures."""
    texture_ERB()  # smoke test
    pytest.raises(TypeError, texture_ERB, seq='foo')
    pytest.raises(ValueError, texture_ERB, seq=('foo',))
    with pytest.warns(UserWarning, match='LESS THAN 1 ERB'):
        x = texture_ERB(freq_lims=(200, 500))
    assert_allclose(len(x) / 24414., 4., rtol=1e-5)
示例#3
0
def test_textures():
    """Test stimulus textures."""
    texture_ERB()  # smoke test
    assert_raises(TypeError, texture_ERB, seq='foo')
    assert_raises(ValueError, texture_ERB, seq=('foo',))
    with warnings.catch_warnings(record=True) as w:
        x = texture_ERB(freq_lims=(200, 500))
    assert_true(any('less than' in str(ww.message).lower() for ww in w))
    assert_allclose(len(x) / 24414., 4., rtol=1e-5)
示例#4
0
def test_textures():
    """Test stimulus textures."""
    texture_ERB()  # smoke test
    assert_raises(TypeError, texture_ERB, seq='foo')
    assert_raises(ValueError, texture_ERB, seq=('foo', ))
    with warnings.catch_warnings(record=True) as w:
        x = texture_ERB(freq_lims=(200, 500))
    assert_true(any('less than' in str(ww.message).lower() for ww in w))
    assert_allclose(len(x) / 24414., 4., rtol=1e-5)
示例#5
0
========================

This shows how to generate texture coherence stimuli.
"""

import numpy as np
import matplotlib.pyplot as plt

from expyfun.stimuli import texture_ERB, play_sound

fs = 24414
n_freqs = 20
n_coh = 18  # very coherent example

# let's make a textured stimilus and play it
sig = texture_ERB(n_freqs, n_coh, fs=fs, seq=('inc', 'nb', 'sam'))
play_sound(sig, fs, norm=True, wait=True)

###############################################################################
# Let's look at the time course
t = np.arange(len(sig)) / float(fs)
fig, ax = plt.subplots(1)
ax.plot(t, sig.T, color='k')
ax.set(xlabel='Time (sec)', ylabel='Amplitude (normalized)', xlim=t[[0, -1]])
fig.tight_layout()

###############################################################################
# And now the spectrogram:
fig, ax = plt.subplots(1, figsize=(8, 2))
img = ax.specgram(sig, NFFT=1024, Fs=fs, noverlap=800)[3]
img.set_clim([img.get_clim()[1] - 50, img.get_clim()[1]])
示例#6
0
========================

This shows how to generate texture coherence stimuli.
"""

import numpy as np
import matplotlib.pyplot as plt

from expyfun.stimuli import texture_ERB, play_sound

fs = 24414
n_freqs = 20
n_coh = 18  # very coherent example

# let's make a textured stimilus and play it
sig = texture_ERB(n_freqs, n_coh, fs=fs, seq=('inc', 'nb', 'sam'))
play_sound(sig, fs, norm=True, wait=True)

###############################################################################
# Let's look at the time course
t = np.arange(len(sig)) / float(fs)
fig, ax = plt.subplots(1)
ax.plot(t, sig.T, color='k')
ax.set(xlabel='Time (sec)', ylabel='Amplitude (normalized)', xlim=t[[0, -1]])
fig.tight_layout()

###############################################################################
# And now the spectrogram:
fig, ax = plt.subplots(1, figsize=(8, 2))
img = ax.specgram(sig, NFFT=1024, Fs=fs, noverlap=800)[3]
img.set_clim([img.get_clim()[1] - 50, img.get_clim()[1]])