Skip to main content

Represent acoustic stimuli and responses

Project description

ndx-sound Extension for NWB

NWB extension of sounds.

Installation

pip install ndx-sound

Usage

Python

Add to an NWB file

from pynwb import NWBFile
from scipy.io import wavfile
from ndx_sound import AcousticWaveformSeries

sampling_rate, samples = wavfile.read(filepath)

acoustic_waveform_series = AcousticWaveformSeries(
    name="acoustic_stimulus",
    data=samples,
    rate=sampling_rate,
    description="acoustic stimulus",
)

nwbfile = NWBFile(...)
# if a recording of behavior, add to acquisition
nwbfile.add_acquisition(acoustic_waveform_series)

# if a stimulus, add to stimulus
nwbfile.add_stimulus(acoustic_waveform_series)

Visualization

Use plot_sound on its own outside nwbwidgets.

from ndx_sound.widgets import plot_sound

plot_sound(nwbfile.stimulus["acoustic_stimulus"])

Use acoustic_waveform_widget to include an Audio element that plays the sound.

from ndx_sound.widgets import acoustic_waveform_widget

acoustic_waveform_widget(nwb.stimulus["acoustic_stimulus"])

You can also have the sound widget automatically loaded into nwb2widget.

from ndx_sound import widgets

Then run nwb2widget as normal.

from nwbwidgets import nwb2widget

nwb2widget(nwbfile)

This extension was created using ndx-template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ndx-sound-0.1.0.tar.gz (14.1 kB view hashes)

Uploaded source

Built Distribution

ndx_sound-0.1.0-py2.py3-none-any.whl (5.6 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page