Skip to content

Commit

Permalink
ENH load.wav(): expose name argument
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbrodbeck committed Nov 23, 2016
1 parent bd44578 commit 8d55be7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions eelbrain/_io/wav.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@
FILETYPES = [("WAV files", "*.wav")]


def load_wav(filename=None):
"""oad a wav file as NDVar
def load_wav(filename=None, name=None):
"""Load a wav file as NDVar
Parameters
----------
filename : str
Filename of the wav file. If not filename is specified, a file dialog is
shown to select one.
name : str
NDVar name (default is the file name).
Returns
-------
wav : NDVar
NDVar with the wav file's data. If the file contains a single channel,
the NDVar dimensions are ``(time,)``; if it contains several channels,
they are ``(channel, time)``.
they are ``(channel, time)``. ``wav.info`` contains entries for
``filename`` and ``samplingrate``.
Notes
-----
Expand All @@ -45,7 +48,8 @@ def load_wav(filename=None):

srate, data = wavfile.read(filename)
time = UTS(0, 1. / srate, data.shape[-1])
name = os.path.basename(filename)
if name is None:
name = os.path.basename(filename)
info = {'filename': filename, 'samplingrate': srate}
if data.ndim == 1:
return NDVar(data, (time,), info, name)
Expand Down

0 comments on commit 8d55be7

Please sign in to comment.