Skip to content

IPEM Toolbox' auditory peripheral module

Matthes-Moeer edited this page Apr 10, 2025 · 4 revisions

A python implementation of the IPEM toolbox' auditory peripheral module

Introduction

The auditory peripheral module described in this implementation is based closely on the framework presented by Van Immerseel in his 1992 paper, which laid out a detailed computational approach for simulating auditory processing mechanisms. While Van Immerseel’s work originally targeted language-related analysis, the IPEM toolbox—developed later—adapted many of the foundational ideas from this paper to a wider range of applications in auditory modeling. As such, this project aligns itself not only with the theoretical principles of Van Immerseel’s work but also with the broader goals of the IPEM toolbox, focusing on auditory perception and psychoacoustics.

The module, written in Python, aims to replicate key elements of the auditory pathway as described in Van Immerseel’s model. This includes processes such as the outer ear’s frequency response, the cochlear’s role in filtering, and the auditory nerve’s signal processing. While the IPEM toolbox itself was originally built in MATLAB, this implementation translates the core principles into Python, guided heavily by the details found in Van Immerseel’s paper.

The reliance on Van Immerseel’s work stems from its comprehensive treatment of auditory processing, particularly its mathematical rigor and system-level description of the auditory periphery. By rooting this implementation in his paper, the module remains grounded in a well-validated framework, ensuring consistency with prior research while adapting it for practical use in Python.

Motivations

This implementation of the auditory peripheral module was guided by a combination of theoretical considerations, computational constraints, and practical challenges encountered during development. At its foundation lies the goal of accurately translating Van Immerseel’s framework into Python, while addressing the limitations inherent to programming environments and hardware. The decisions made throughout this project reflect a balance between adhering to the principles of the original framework and the realities of practical implementation, particularly when operating outside the MATLAB ecosystem, which forms the basis for much of the IPEM toolbox.

Central to the design of this module is the decision to use a fixed sampling rate of 20 kHz. Van Immerseel’s paper frequently details analog filter transfer functions, such as those for the second-order low-pass filter modeling the outer ear’s frequency response. Typically, implementing such transfer functions in a digital domain would require bilinear transformations, dependent on the sampling rate. However, standardizing the sampling rate across all components of the module eliminates the need for recalculations of filter coefficients, transfer functions, and intermediary formulas. This standardization significantly reduces computational overhead while preserving the accuracy and theoretical consistency of the model.

The emphasis on a fixed sampling rate is particularly evident in the decimation unit, where both the filter coefficients and the associated transfer functions are explicitly designed for 20 kHz. Any deviation from this sampling rate would necessitate recalculating key parameters at every stage of the process, resulting in substantial complexity. By maintaining a consistent rate, we ensure that the implementation aligns with the theoretical expectations outlined in the paper while remaining computationally efficient in execution.

Another key decision was the reduction of the cochlear filterbank from 40 bandpass filters, as described in the IPEM toolbox, to 20 filters in this implementation. This decision was not taken lightly, as the reduced filter count inevitably affects the fidelity with which the module can represent the cochlear’s response to a wide range of frequencies. However, attempts to replicate the original MATLAB-based filterbank in Python resulted in substantial challenges, including a failure to achieve a functional implementation. Rather than compromise the integrity of the module, the team opted for a simpler filterbank that retains the core functionality of the original design. This reduction is a practical compromise, ensuring that the module remains functional and adaptable within a Python environment.

Further considerations include the decision to store filter definitions in a JSON file. This approach reflects a practical response to Python’s limitations in handling extensive computational workloads within the code itself. Calculating all filter coefficients dynamically at runtime would impose significant strain on the processing capabilities of most systems, potentially rendering the module impractical for widespread use. By precomputing the coefficients and storing them in an external file, this implementation avoids unnecessary clutter within the codebase and ensures that computational resources are allocated more efficiently.

In essence, this module represents a deliberate and considered adaptation of Van Immerseel’s framework, shaped by the needs of modern computational research and the constraints of the Python programming environment. It bridges the gap between theoretical rigor and practical utility, providing a foundation for further exploration and application of auditory modeling techniques.

Methods

The auditory peripheral module is structured into sequential stages, each modeled after distinct components of the human auditory pathway, following the framework laid out in Van Immerseel’s 1992 paper. While the implementation deviates from the original MATLAB-based IPEM toolbox, it retains its theoretical basis, albeit adapted for computational constraints and the Python programming environment. Below, each stage of the implementation is discussed in depth, with an emphasis on the mathematical rigor and practical considerations that shaped the code. Outer Ear Modeling

The outer ear's function in amplifying specific frequency bands is modeled using a second-order low-pass filter. Van Immerseel's paper specifies the transfer function in the analog domain. Given that the bilinear transformation necessary to convert this to a digital filter is dependent on the sampling rate, we opted to fix the sampling rate at 20 kHz. This decision eliminates the need for recalculations and ensures consistency. The transfer function implemented is as follows: $$H(z) = \frac{b_0 + b_1z^{-1} + b_2z^{-2}}{1 + a_1z^{-1} + a_2z^{-2}}$$ The coefficients for the numerator and denominator are predefined for the standardized sampling rate, simplifying computational overhead while adhering to the principles of auditory modeling. Decimation Unit

The decimation process is a cornerstone of this module, reducing the signal’s sampling rate while preserving relevant frequency information. The asymmetric loop implemented for decimation reflects a meticulous balance between filtering and downsampling, with delays introduced at each stage to ensure signal alignment. The filter transfer function, given by: $$H_m(z) = \sum_{k=0}^{N-1} h_k z^{-k},$$ is tailored explicitly to the 20 kHz sampling rate. Introducing a variable sampling rate would necessitate recalculating the filter coefficients and adjusting every formula related to decimation—an approach deemed impractical for this project.

The loop itself, with its carefully structured filtering and delay mechanisms, represents one of the most significant challenges faced during development. While not explicitly stated here, its asymmetry and precision are integral to achieving the desired signal processing outcomes. Cochlear Filtering via Filterbank

Cochlear filtering is modeled using a reduced filterbank of 20 bandpass filters, as opposed to the 40 filters in the original IPEM specification. This reduction was a necessary compromise due to limitations in translating the MATLAB-based filter definitions to Python. Despite extensive effort, the original implementation failed to produce a functional filterbank, prompting the decision to simplify the structure while retaining the core functionality. Each filter’s coefficients are stored in a JSON file, avoiding the computational strain of calculating them dynamically during runtime. While this approach departs from Van Immerseel’s original design, it maintains a level of practicality suitable for Python-based modeling. Hair Cell Modeling

Simulating cochlear hair cell behavior involves three distinct stages: rectification, compression, and envelope extraction. Rectification is implemented as a straightforward operation: $$y = \max(0, x)$$ Compression employs a non-linear relationship: $$y = x^\gamma,$$ where $$\gamma$$ denotes the compression factor, designed to mimic the dynamic range of human hearing. Finally, envelope extraction is achieved using low-pass filtering: $$H(z) = \frac{b_0 + b_1z^{-1}}{1 + a_1z^{-1} + a_2z^{-2}}$$ These components collectively model the biological processes of cochlear hair cells, providing a basis for further auditory signal analysis. Auditory Nerve and CPU Processing

The auditory nerve model applies additional low-pass filtering to refine the envelope extracted by the hair cell model, mimicking the temporal behavior of auditory nerve fibers. In the central processor unit, periodicity detection is performed using autocorrelation, combining outputs across channels to extract tonal and rhythmic features. The autocorrelation formula, expressed as: $$R(\tau) = \sum_{n=0}^{N-1} x(n) \cdot x(n+\tau),$$ represents the crux of CPU processing, enabling the module to analyze and interpret auditory signals effectively.

Implementation Details

This Python-based implementation of the auditory peripheral module adheres closely to the principles outlined by Van Immerseel in his 1992 paper, while acknowledging the practical constraints of modern programming environments. Each stage is meticulously designed, optimized for a 20kHz sampling rate, and executed in a modular fashion that ensures clarity and adaptability.

The code begins with loading and preprocessing the input signal, applying filtering to mimic the outer ear’s frequency response. This serves as the foundation for subsequent stages, where the signal undergoes decimation, cochlear filtering, hair cell modeling, and auditory nerve simulation. The final stage—CPU processing—analyzes periodicity through autocorrelation, combining outputs across multiple channels to generate high-level auditory features.

To enhance usability and computational efficiency, the cochlear filterbank definitions are stored in a JSON file, allowing the module to bypass runtime calculations of filter coefficients. This approach significantly reduces processing strain while maintaining the integrity of the auditory model. Declaration of AI Assistance

Development of this implementation benefited from AI support in various stages, including code generation, documentation, and structural guidance. Microsoft Copilot was employed as an auxiliary tool to streamline the process, ensuring efficiency while preserving the scientific rigor of the project. This acknowledgment is made to maintain transparency and align with ethical research practices.

References

Van Immerseel, L. M., & Martens, J.-P. (1992). Pitch and voiced/unvoiced determination with an auditory model. Journal of the Acoustical Society of America, 91(6), 3511–3526, available at: https://pubs.aip.org/asa/jasa/article-abstract/91/6/3511/968379/Pitch-and-voiced-unvoiced-determination-with-an

IPEM Toolbox Manual Retrieved April 10, 2025, from https://github.com/IPEM/IPEMToolbox

SciPy User Guide Retrieved April 10, 2025, from https://docs.scipy.org/doc/scipy/tutorial/index.html

Clone this wiki locally