This file is part of simplecochlea.
simplecochlea is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
simplecochlea is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with simplecochlea. If not, see <https://www.gnu.org/licenses/>.
simplecochlea.cochlea.
BandPassFilterbank
(order, wn, fs, ftype='butter')[source]¶Bases: object
Band-pass Filterbank Class Defines a bank of band-pass filters. The Cochlea class uses it to model the inner hair cells.
Attributes: |
|
---|
Methods
filter_one_channel (input_sig, channel_pos[, …]) |
Filter input signal input_sig with channel specified by channel_pos |
filter_signal (input_sig[, do_plot, zi_in]) |
Filter input signal input_sig. |
plot_caracteristics ([n_freqs]) |
Plot the frequency response of the differents band-pass filters |
filter_one_channel
(input_sig, channel_pos, zi_in=[])[source]¶Filter input signal input_sig with channel specified by channel_pos
Parameters: |
|
---|---|
Returns: |
|
filter_signal
(input_sig, do_plot=0, zi_in=[])[source]¶Filter input signal input_sig. Input signal is passed through all the band-pass filters.
Parameters: |
|
---|---|
Returns: |
|
simplecochlea.cochlea.
Cochlea
(n_channels, fs, fmin, fmax, freq_scale, order=2, fbank_type='butter', rect_type='full', rect_lowpass_freq=[], comp_factor=0.3333333333333333, comp_gain=1, lif_tau=0.01, lif_v_thresh=0.02, lif_v_spike=0.035, lif_t_refract=0.001, lif_v_reset=[], inhib_vect=[], tau_j=[], alpha_j=[], omega=[])[source]¶Bases: object
Attributes: |
|
---|
Methods
plot_channel_evolution (input_sig[, channel_pos]) |
Plot the processing of input_sig signal through the cochlea, for channels specified by channel_pos. |
process_input (input_sig[, do_plot]) |
Process input signal through the Cochlea |
process_one_channel (input_sig, channel_pos) |
Process a signal with 1 channel of the cochlea |
process_test_signal (signal_type[, …]) |
Run a test signal through the cochlea. |
save (dirpath[, filename]) |
Save the cochlea. |
cf
¶compressionbank
¶filterbank
¶fmax
¶fmin
¶forder
¶freq_scale
¶fs
¶lifbank
¶n_channels
¶plot_channel_evolution
(input_sig, channel_pos=[])[source]¶Plot the processing of input_sig signal through the cochlea, for channels specified by channel_pos. If channel_pos is not provided, 4 channels are selected ranging from low-frequency channel to high-frequency channel.
Parameters: |
|
---|
process_input
(input_sig, do_plot=False)[source]¶Process input signal through the Cochlea
Parameters: |
|
---|---|
Returns: |
|
process_one_channel
(input_sig, channel_pos)[source]¶Process a signal with 1 channel of the cochlea
Parameters: |
|
---|---|
Returns: |
|
process_test_signal
(signal_type, channel_pos=[], do_plot=True, **kwargs)[source]¶Run a test signal through the cochlea. Test signals can be a sinusoidal signal, a step or an impulse signal. Argument signal_type selects the wanted signal. If channel_pos is provided and do_plot is True, channel evolution is plot.
Parameters: |
|
---|---|
Returns: |
|
rectifierbank
¶simplecochlea.cochlea.
CochleaEstimator
(fs, n_filters, fmin, fmax, freq_scale=['linearscale', 'erbscale'], forder=[2], fbank_type=['butter', 'bessel'], comp_gain=array([0.8]), comp_factor=array([0.33333333, 0.25 , 0.2 ]), lif_tau_coeff=[0.5, 1, 3], lif_v_thresh_start=[0.3, 0.4, 0.5], lif_v_thresh_stop=[0.1, 0.15], lif_v_thresh_mid=[])[source]¶Bases: object
Methods
grid_search | |
grid_search_atom | |
plot_param_scores | |
plot_results | |
print_cochlea_parameters | |
process_input |
plot_param_scores
(global_score, vr_score, spkchanvar_score, channel_with_spikes_ratio, n_spikes_mean, param_key=[], inner='box')[source]¶plot_results
(global_score, vr_score, spkchanvar_score, channel_with_spikes_ratio, n_spikes_mean, param_grid, params_to_plot=['fmin', 'fmax', 'forder', 'freq_scale', 'fbank_type', 'comp_gain', 'comp_factor', 'lif_tau_coeff', 'lif_v_thresh_start', 'lif_v_thresh_stop', 'lif_v_thresh_mid'], order=[])[source]¶simplecochlea.cochlea.
CompressionBank
(n_channels, fs, comp_factor, comp_gain)[source]¶Bases: object
CompressionBank Class Parralel association of compression units. Apply an amplitude compression using a logarithmic transform :
\(f(x) = comp_{gain} * x^{comp_{factor}}\)
Each channel can have a separate compression gain and compression factor. In the cochlea, the compression bank follows the rectifier bank and precede the LIF bank.
Attributes: |
|
---|
Methods
compress_one_channel (input_sig, channel_pos) |
Apply the compression to input signal input_sig with channel specified by channel_pos |
compress_signal (input_sig[, do_plot]) |
Compress input signal input_sig. |
compress_one_channel
(input_sig, channel_pos)[source]¶Apply the compression to input signal input_sig with channel specified by channel_pos
Parameters: |
|
---|---|
Returns: |
|
compress_signal
(input_sig, do_plot=0)[source]¶Compress input signal input_sig. Each channel of the input signal is compressed by its correponding compression unit.
Parameters: |
|
---|---|
Returns: |
|
simplecochlea.cochlea.
LIFBank
(n_channels, fs, tau, v_thresh=0.02, v_spike=0.035, t_refract=[], v_reset=[], inhib_vect=[], tau_j=[], alpha_j=[], omega=[])[source]¶Bases: object
Leaky Integrate and Fire (LIF) Bank Parralel association of LIF neuron model. The LIF neuron is a simple spiking neuron model where the neuron is modeled as a leaky integrator of the input synaptic current I(t).
A refractiory period can be defined preventing the neuron to fire just after emitting a spike.
By default each LIF unit (i.e. channel) is independant from the others. To model more complex comportement, lateral inhibition can be added between units (channels). This lateral inhibition is inspired from [1].
Adaptive threshold is another option. Instead of using a fixed spiking threshold defined bt v_thresh, it is possible to model an adaptive threshold using the tau_j, alpha_j and omega attributes. These variables implements the adaptive threshold model described in [2].
References
[1] | Gershon G. Furman and Lawrence S. Frishkopf. Model of Neural Inhibition in the Mammalian Cochlea. The Journal of the Acoustical Society of America 1964 36:11, 2194-2201 |
[2] | Kobayashi Ryota, Tsubo Yasuhiro, Shinomoto Shigeru. Made-to-order spiking neuron model equipped with a multi-timescale adaptive threshold. Frontiers in Computational Neuroscience. 2009 |
Attributes: |
|
---|
Methods
filter_one_channel (input_sig, i[, v_init, …]) |
Filter one channel | ||
filter_signal (input_sig[, v_init, t_start, …]) |
|
||
plot_caracteristics () |
Plot the LIFBank characteristics |
filter_one_channel
(input_sig, i, v_init=[], t_start=0, t_last_spike=[])[source]¶Filter one channel
Parameters: |
|
---|---|
Returns: |
|
filter_signal
(input_sig, v_init=[], t_start=0, t_last_spike=[])[source]¶Parameters: |
|
---|---|
Returns: |
|
simplecochlea.cochlea.
RectifierBank
(n_channels, fs, rtype='half', lowpass_freq=[], filtorder=1)[source]¶Bases: object
RectifierBank Class Parralel association of rectifier units. Half and full rectification are possible :
- half-rectification : \(f(x) = x if x > 0, 0 otherwise\)
- full-rectification : \(f(x) = abs(x)\)
Rectification can include a low-pass filtering using a Butterworth filters. Each channel can have its own filtering cutoff frequency. The cochlea uses a rectifier bank just after the band-pass filtering step.
Attributes: |
|
---|
Methods
rectify_one_channel (input_sig, channel_pos) |
Rectify input signal input_sig with channel specified by channel_pos |
rectify_signal (input_sig[, do_plot]) |
Rectify input signal input_sig. |
rectify_one_channel
(input_sig, channel_pos)[source]¶Rectify input signal input_sig with channel specified by channel_pos
Parameters: |
|
---|---|
Returns: |
|
rectify_signal
(input_sig, do_plot=0)[source]¶Rectify input signal input_sig. Each channel of the input signal is rectified by its correponding rectifier.
Parameters: |
|
---|---|
Returns: |
|
This file is part of simplecochlea.
simplecochlea is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
simplecochlea is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with simplecochlea. If not, see <https://www.gnu.org/licenses/>.
simplecochlea.generate_signals.
delete_zero_signal
(dirpath)[source]¶There are some null signals (only zero amplitude) in the ABS directory. This function delete them. Delete also constant signals (only one single amplitude)
simplecochlea.generate_signals.
generate_abs_stim
(dirpath, chunk_duration, n_repeat_target, n_noise_iter=1)[source]¶Generate a stimulus used for Audio Brain Spotting (ABS). The stimulus is composed of one repeating target sound, between n_noise_iter noise sound. It alternate between n_noise_iter noise sound (non-repeating one) and the target sound, starting with a noise sound.
Parameters: |
|
---|---|
Returns: |
|
simplecochlea.generate_signals.
generate_dirac
(fs, t_offset=0.2, t_max=1, amplitude=1)[source]¶Generate a impulse signal (mathematically defined by the Dirac delta function)
Parameters: |
|
---|---|
Returns: |
|
simplecochlea.generate_signals.
generate_sinus
(fs, f_sin, t_offset=0, t_max=1, amplitude=1)[source]¶Generate a signal containing one or more sinusoides. If multiples frequencies are defined by f_sin parameter, the output signal is the sum of the different sinusoides.
Parameters: |
|
---|---|
Returns: |
|
simplecochlea.generate_signals.
generate_step
(fs, t_offset=0.2, t_max=1, amplitude=1)[source]¶Generate a impulse signal (mathematically defined by the Dirac delta function)
Parameters: |
|
---|---|
Returns: |
|
simplecochlea.generate_signals.
get_abs_stim_params
(chunk_duration_s, n_repeat_target, n_noise_iter)[source]¶For a sequence when a target segment is repeating n_repeat_target timesand interleaved by n_noise_iter noise segments, returns the pattern of each segments
Parameters: |
|
---|---|
Returns: |
|
simplecochlea.generate_signals.
merge_wav_sound_from_dir
(dirpath, chunk_duration, n_sounds, n_repeat_per_sound=1, max_sound_repet=1)[source]¶Parameters: |
|
---|---|
Returns: |
|
Simple-Cochlea Main Package