Skip to main content

Phenomological Adaptive STochastic auditory nerve fiber model

Project description

Phenomological Adaptive STochastic auditory nerve fiber model

test-python

This repository contains an archive implementation of a phenomenological auditory nerve fiber model. The model is implemented in C++, with a runtime interface for Python. It can be easily installed via pip:

pip install phastc

The model has been tested and built for python versions 3.9-12, and is compiled using g++ for MacOS and Linux and msvc on Windows.

Running PHAST

The PHAST model simulates the response of a single auditory nerve fiber to electrical stimulation. As such, the model revolves arround two main inputs, the stimulus, and a list of fibers. These are both managed by objects in Python and explained in detail in the following sections.

Pulse Train

The pulse train encodes the stimulus to be used in the simulation. We differentiate between a ConstantPulseTrain object and a PulseTrain object. The former can be used when the stimulation has a constant interval and amplitude, and can be a lot more efficient. The latter should be used whenever each pulse in the pulse train can be different, for example when using stimuli produced by a speech coding strategy. The PulseTrain has the following signature:

stimulus = PulseTrain(
    pulse_train: np.ndarray = ...,
    time_step: float = 1e-6,
    ...
)

Only the first parameter is required, and should be a numpy array (matrix) of shape n electrodes x time steps. Then each element of the matrix encodes the amplitude of a pulse at given timestep for a given electrode. Ensure that the time steps of the matrix match the time_step parameter.

The ConstantPulseTrain has the following signature:

stimulus = ConstantPulseTrain(
    duration: float = ...,
    rate: float = ...,
    amplitude: float = ...,
    time_step: float = 1e-6,
)

Here, the duration denotes the total length in seconds of the pulse train, and rate the pulse rate, i.e. number of pulses per second. Each pulse in this pulse train has the same amplitude, specified by amplitude. Again, time_step encodes the time step of the pulse train. Note that this object can only be used for single electrode stimulation.

Fiber

The Fiber object encodes a single fiber to be analyzed by the PHAST model. Many can be analyzed at the same time, so often a list of several fibers can be considered at any given time. The object has the following signature:

fiber = Fiber(
    i_det: np.ndarray = ...,
    spatial_constant: np.ndarray = ...,
    sigma: np.ndarray = ...,
    fiber_id: int = ...,
    sigma_rs: float = ...,
    refractory_period: RefractoryPeriod = ...,
    decay: Decay = ...,
    store_stats: bool = False,
    spont_activity: float = 0.0
)

Here i_det, spatial_constant, sigma, are all vectors of length number of electrodes, which should match the number of electrodes in the PulseTrain used in stimulation. For i_det, this defines the deteriministic threshold after which the fiber spikes, for a pulse from a given electrode. The spatial_constant defines an electrode specific spatial constant, which is used to scale stimulation. The sigma parameter is another electrode specific parameter, which is the relative spread per i_det, i.e. relative_spread * i_det. fiber_id encodes a unique identifier, specified by the used to attach to the fiber. sigma_rs is used for stochasticy between trials. store_stats defines whether all statistics should be stored, such as the refractoriness at each time step. This defaults to False, and should be used with caution, as this significantly increases memory usage. spont_activity is an experimental feature, which denotes the spontaneous firing rate of the fiber, defined in spikes/s. RefractoryPeriod is a parameter wrapper for handling both absolute and relative refractoriness. It can be defined as follows, and if not given explicitly to the Fiber, the following default values are used:

ref = RefractoryPeriod(
    absolute_refractory_period: float = 4e-4,
    relative_refractory_period: float = 8e-4,
    sigma_absolute_refractory_period: float = 0.0,
    sigma_relative_refractory_period: float = 0.0
)

Decay

Several different versions of the model can be used, which use a different model for controlling spike rate decay.

  • Exponential: The first version of the model, as used in: van Gendt, Margriet J., et al. "A fast, stochastic, and adaptive model of auditory nerve responses to cochlear implant stimulation." Hearing research 341 (2016): 130-143. This model uses an exponential decay function.
  • Power Law: In a subsequent paper, the exponential decay was replaced by a power law function, to better approximate long duratioin fiber behaviour, presented in: van Gendt, Margriet J., et al. "Short and long-term adaptation in the auditory nerve stimulated with high-rate electrical pulse trains are better described by a power law." Hearing Research 398 (2020): 108090.
  • Leaky Integrator: In the latest paper, the power law decay was replaced by a leaky integrator, which was shown to approximate long duration fiber behavoir with comparable accuracy as the power law decay function, but using significantly less computational resources. This version should be prefered when performing large scale experiments with PHAST. The model was presented in: de Nobel, Jacob, et al. "Biophysics-inspired spike rate adaptation for computationally efficient phenomenological nerve modeling." Hearing Research 447 (2024): 109011.

To use any of the previously mentioned versions of the PHAST model, the decay parameter needs to be specific when constructing a Fiber object with the correct Decay object. For the exponential decay model, we need to pass:

decay = Exponential(
    adaptation_amplitude: float = 0.01,
    accommodation_amplitude: float = 0.0003,
    sigma_adaptation_amplitude: float = 0.0,
    sigma_accommodation_amplitude: float = 0.0,
    exponents: list[tuple] = [(0.6875, 0.088), (0.1981, 0.7), (0.0571, 5.564)],
)

For the power law model, the following is required:

decay = Powerlaw(
    adaptation_amplitude: float = 2e-4,
    accommodation_amplitude: float = 8e-6,
    sigma_adaptation_amplitude: float = 0.0,
    sigma_accommodation_amplitude: float = 0.0,
    offset: float = 0.06,
    exp: float = -1.5
)

Finally, for the model which uses the leaky integrator, the following decay object needs to be passed:

decay = LeakyIntegratorDecay(
    adaptation_amplitude: float = 7.142,
    accommodation_amplitude: float = 0.072,
    adaptation_rate: float = 0.014,
    accommodation_rate: float = 19.996
)

phast

Then finally, we can combine the above to run the phast model (for a single fiber):

fiber_stats = phast(
    [fiber],                        # A list of Fiber objects
    pt,                             # A PulseTrain object, either PulseTrain or ConstantPulseTrain
    n_jobs = -1,                    # The number of parallel cores to use (-1 is all available)
    n_trials = 1                    # The number of trials to generate for each fiber
    use_random = True               # Whether the experiment should use randomness
)

This yields a list of FiberStats objects which contains information about the experiment, such as the occurence of spikes (e.g.fiber_stats[0].spikes), or other statistics, when store_stats has been enabled. In order to get consitent results when enabling randomness i.e. when use_random = True, a proper seed should be set, using phast.set_seed(seed_value), similar to how one would use np.random.seed.

Creating Neurograms

We include a helper to easily aggregate FiberStats data into neurograms in matrix form. To do this, the following can be used:

neurogram = Neurogram(
    fiber_stats, 
    bin_size: float,    # The required binsize of the neurogram, every spike falling in the bin is summed
)

This then creates a neurogram matrix, which can be accessed via the data member, i.e. neurogram.data.

We provide the following plotting utility to easiliy visualize these neurograms:

fig, ax = plt.subplots()
plot_neurogram(
    neurogram,
    ax=ax,      # Optional
    fig=fig     # Optional
)

Speech Coding Strategies

Note that we include several options for sound encoding and integrated with PHAST, see the folder phast/scs for more information.

Citation

@article{de2024biophysics,
title = {Biophysics-inspired spike rate adaptation for computationally efficient phenomenological nerve modeling},
journal = {Hearing Research},
volume = {447},
pages = {109011},
year = {2024},
issn = {0378-5955},
doi = {https://doi.org/10.1016/j.heares.2024.109011},
url = {https://www.sciencedirect.com/science/article/pii/S0378595524000649},
author = {Jacob {de Nobel} and Savine S.M. Martens and Jeroen J. Briaire and Thomas H.W. Bäck and Anna V. Kononova and Johan H.M. Frijns},
}

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

phastc-1.1.2.tar.gz (41.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

phastc-1.1.2-cp312-cp312-win_amd64.whl (41.9 MB view details)

Uploaded CPython 3.12Windows x86-64

phastc-1.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (42.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

phastc-1.1.2-cp312-cp312-macosx_11_0_arm64.whl (41.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

phastc-1.1.2-cp311-cp311-win_amd64.whl (41.9 MB view details)

Uploaded CPython 3.11Windows x86-64

phastc-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (42.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

phastc-1.1.2-cp311-cp311-macosx_11_0_arm64.whl (41.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

phastc-1.1.2-cp310-cp310-win_amd64.whl (41.9 MB view details)

Uploaded CPython 3.10Windows x86-64

phastc-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (42.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

phastc-1.1.2-cp310-cp310-macosx_11_0_arm64.whl (41.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

phastc-1.1.2-cp39-cp39-win_amd64.whl (41.9 MB view details)

Uploaded CPython 3.9Windows x86-64

phastc-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (42.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

phastc-1.1.2-cp39-cp39-macosx_11_0_arm64.whl (41.9 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file phastc-1.1.2.tar.gz.

File metadata

  • Download URL: phastc-1.1.2.tar.gz
  • Upload date:
  • Size: 41.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for phastc-1.1.2.tar.gz
Algorithm Hash digest
SHA256 8e3aa243cc7eba5885e1cb166034c05248ae2bcdf3d121bf71a1261a82786ea3
MD5 2eee842e1847d32abb7d23034b6dd6ce
BLAKE2b-256 51350f145824089cf4e3e64be32d06d06f4f95fb302cf4c06a862783066301e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for phastc-1.1.2.tar.gz:

Publisher: python-publish.yml on jacobdenobel/PHAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phastc-1.1.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: phastc-1.1.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 41.9 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for phastc-1.1.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8a2dc11dab29ecb9d5ec66c8b498eacfb2b8be8f6ffa65894f65dea9c5937ca1
MD5 938535dea17b812b813a1aa25472a0d4
BLAKE2b-256 d954aafbace047adb3aadb6b93a808baedfa38d445896ee764c23f466f53401d

See more details on using hashes here.

Provenance

The following attestation bundles were made for phastc-1.1.2-cp312-cp312-win_amd64.whl:

Publisher: python-publish.yml on jacobdenobel/PHAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phastc-1.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for phastc-1.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e7aa053ba7c7970ce3fc456c3ffd6059dec7de7a4f30b9079c06e8c1607c1f45
MD5 a1d9e6036fff6c284b8a001549f0245d
BLAKE2b-256 9a32426a10e31b2a2077cd0eba5ff06173583af06d86dd6bfd45ac79817fce68

See more details on using hashes here.

Provenance

The following attestation bundles were made for phastc-1.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on jacobdenobel/PHAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phastc-1.1.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for phastc-1.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 06d4075a1dd0e76281d115c5f4b7babfbdc336d0e889dd60c90bdc2ab86f2d20
MD5 c0aa9230a00f0b346ff7bb431003882d
BLAKE2b-256 056fd67d040177fb6f06326e3422f8603a6810ae7714f944370482da14067965

See more details on using hashes here.

Provenance

The following attestation bundles were made for phastc-1.1.2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: python-publish.yml on jacobdenobel/PHAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phastc-1.1.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: phastc-1.1.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 41.9 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for phastc-1.1.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6a67a2cbca9b39a778b95965aa3abec95be7d9dfbe92826e8a4d976b10dd545c
MD5 08b306c16ed7a7610acb951be51f6b0e
BLAKE2b-256 2c3b20103f5735375027d8ec9b5f9bec5035f8ebbd98c1e0173181091e47ba36

See more details on using hashes here.

Provenance

The following attestation bundles were made for phastc-1.1.2-cp311-cp311-win_amd64.whl:

Publisher: python-publish.yml on jacobdenobel/PHAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phastc-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for phastc-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 33d9a3014633833a5929af9968a8163b818db6b66c656fc0182a0ba4b0a56961
MD5 77d78ca3b059ffc59d7a46a9fbc5ecef
BLAKE2b-256 84c947e5aed87d77045952caa68ee65a4df6d32077b8f78c36680c0dd16889ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for phastc-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on jacobdenobel/PHAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phastc-1.1.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for phastc-1.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b9f2765aad7c0b2f7c7c837a978c05944553bc8d0a03a45703784c59bd77e711
MD5 69a55928c174301612a436e0cf6a9149
BLAKE2b-256 9edc1056ad6806fd6264a148c0bdb3e8ec8a9fbbc6d18f953c5adbc58d0ff288

See more details on using hashes here.

Provenance

The following attestation bundles were made for phastc-1.1.2-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: python-publish.yml on jacobdenobel/PHAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phastc-1.1.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: phastc-1.1.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 41.9 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for phastc-1.1.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 80c80d5be0bfa66428618b795e4fe141bed365f898fa6032083fd3f30099e0a3
MD5 bc48c51ddb429e52e49c90c35ba3fcb3
BLAKE2b-256 4a5f87c18c4a4b952cf6d65e497a93d55c8a7b42ee5e3fc3c595a205cba50715

See more details on using hashes here.

Provenance

The following attestation bundles were made for phastc-1.1.2-cp310-cp310-win_amd64.whl:

Publisher: python-publish.yml on jacobdenobel/PHAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phastc-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for phastc-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9df3cacd1188b007b8c4ad862e71684f72258c4d1b877c9dba2a892f6f80b3ac
MD5 b5036aff54ea11a4e141d5bd4bb11043
BLAKE2b-256 f06b55d2f770d4c83f93e059199ecb68843a62ac0f20a60d178508e678bca5a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for phastc-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on jacobdenobel/PHAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phastc-1.1.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for phastc-1.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 09941e2aa49c7f98dfc406f9d62e382b111f047001d6d01779b7c0cd2c265279
MD5 056fa7ffc013b51ca9ca621710fc800f
BLAKE2b-256 e50a1fb543acae01b47a318bff174daaacd47c5a6ded679ec3baebaa47223a6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for phastc-1.1.2-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: python-publish.yml on jacobdenobel/PHAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phastc-1.1.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: phastc-1.1.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 41.9 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for phastc-1.1.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 4c5d8ea9cfffc549d05fcfde2a6758235b18192a13d8c63fd70e528b5fe6b97e
MD5 9c73e130695c9d7681ef950e57811199
BLAKE2b-256 2fb762585c25a31008ba8bc40317fc6df3c2649db810af3c6c9ff74aa5f9d976

See more details on using hashes here.

Provenance

The following attestation bundles were made for phastc-1.1.2-cp39-cp39-win_amd64.whl:

Publisher: python-publish.yml on jacobdenobel/PHAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phastc-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for phastc-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a3cb036f3a6d99fc424f995e294c08b0faae73aab27b9dcbf66b11e0757c69a4
MD5 6946c48ab39885b179a1897fe907643c
BLAKE2b-256 3b72fb58ffd55f2d4ee1ca5b04495a246ba0e09f4832cf91e0ace56af9b2051b

See more details on using hashes here.

Provenance

The following attestation bundles were made for phastc-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on jacobdenobel/PHAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phastc-1.1.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for phastc-1.1.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 94401625c93653031069b826c2628d5505926a9e92b33b2e27226152f373059b
MD5 0209bcaff192118986a7b9c4a8f1fe15
BLAKE2b-256 24ad53530354c864e9b5101915d62c8b98a6f5151318d0dd123332f47dc3fb1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for phastc-1.1.2-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: python-publish.yml on jacobdenobel/PHAST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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