etho.utils.sound#

etho.utils.sound.build_playlist(soundlist: List[numpy.array], duration: float, fs: float, shuffle=True, sound_order=None)[source]#

Block-shuffle playlist and concatenate to duration.

etho.utils.sound.make_pulse(pulseDur: float, pulsePau: float, pulseNumber: float, pulseDelay: float, samplingrate: float) numpy.array[source]#

Make square pulse train.

Parameters
  • [ms] (pulseDelay) –

  • [ms]

  • pulseNumber

  • [ms]

  • [Hz] (samplingrate) –

Returns

np.array with stimulus waveform

etho.utils.sound.make_sine(frequency: float, phase: float, duration: float, samplingrate: float) numpy.array[source]#

Make sinusoidal from parameters.

Parameters
  • [Hz] (samplingrate) –

  • [pi] (phase) –

  • [ms] (duration) –

  • [Hz]

Returns

np.array with stimulus waveform

etho.utils.sound.normalize_table(table: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame[source]#

Make sure each cell in a row has one entry for stimFileName.

E.g. if two stimFileName but only one intensity, will duplicate the intensity entries.

etho.utils.sound.parse_cell(cell, dtype: Optional[Callable] = None) List[source]#

Cast cell to desired type and wrap into list.

etho.utils.sound.parse_pulse_parameters(playlist, sounds, fs)[source]#

[summary]

Parameters
  • playlist ([type]) – [description]

  • sounds ([type]) – list of np.arrays, the length of which determines the trial period

  • fs (float) – sampling rate for translating nb_samples in sounds to seconds

Returns

[description]

Return type

[type]

etho.utils.sound.parse_table(table: typing.Union[pandas.core.frame.DataFrame, str], dtypes: typing.List[typing.Callable] = [<class 'str'>, <class 'float'>, <class 'float'>, <class 'float'>, <class 'float'>, <class 'float'>, <class 'str'>], normalize: bool = True) pandas.core.frame.DataFrame[source]#

Parse table to desired types.

Parameters
  • string (table - either) –

  • type (dtypes - types each col to cast to - methods which return the desired) –

Returns

table (dataframe)

etho.utils.sound.select_channels_from_playlist(playlist: pandas.core.frame.DataFrame, channels_to_keep: List[str])[source]#

[summary]

Parameters
  • playlist (pd.DataFrame) – [description]

  • channels_to_keep (List[str]) – [description]

Returns

playlist with selected channels

Return type

pd.DataFrame