Skip to main content

Phenomological Adaptive STochastic auditory nerve fiber model

test-python

diagram

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},
}

Metadata

Release files for phastc 1.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for phastc 1.1.7
File Size Uploaded
phastc-1.1.7.tar.gz 41.7 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for phastc 1.1.7
File
phastc-1.1.7-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
phastc-1.1.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
phastc-1.1.7-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
phastc-1.1.7-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
phastc-1.1.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
phastc-1.1.7-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
phastc-1.1.7-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
phastc-1.1.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
phastc-1.1.7-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
phastc-1.1.7-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
phastc-1.1.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
phastc-1.1.7-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details

Total release size: 545.0 MB

Release files / phastc-1.1.7.tar.gz

Download URL phastc-1.1.7.tar.gz
Size 41.7 MB
Tags Source
SHA-256 checksum
How to use checksums
c61e6aa2e40c63bb5a5e1d9130d6eb1d6b0178794f4de5b486b324cf9eeec1f6
BLAKE2b-256 checksum
How to use checksums
58d19ea9a13f2e0a4cc06ee2724aa671569cd9817f989d1950f4b22ecf68f457
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / phastc-1.1.7-cp312-cp312-win_amd64.whl

Download URL phastc-1.1.7-cp312-cp312-win_amd64.whl
Size 41.9 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
a14b44c6ce91837e482f12d928b45a667dc6a1358db6443a6ca62b5ff2aaf9ef
BLAKE2b-256 checksum
How to use checksums
e714cdf4a55e824474161a6058554df711a2f539860c6d7c160194b74be359d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / phastc-1.1.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL phastc-1.1.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 42.0 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
64388ee316f195eafbe91999ef9eb5cdcf3544ee407e1f0803117a23e8f9b1b9
BLAKE2b-256 checksum
How to use checksums
0008d4b5f0c58be3caf2c77a1695e1e3ba73fab5e545761ff9791f3fa56fefb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / phastc-1.1.7-cp312-cp312-macosx_11_0_arm64.whl

Download URL phastc-1.1.7-cp312-cp312-macosx_11_0_arm64.whl
Size 41.9 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
72c34a4435378c3a2da6ded16b3d03ff7805f207b958a21994d04dd53e801951
BLAKE2b-256 checksum
How to use checksums
718990db275bcedffe818187191a608a6f3085cfa07255a8d0daa6609d4f4708
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / phastc-1.1.7-cp311-cp311-win_amd64.whl

Download URL phastc-1.1.7-cp311-cp311-win_amd64.whl
Size 41.9 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
cb4112b7cd366c6c1762e5d3ebc7675db51f8e6394105f8eb609ac31356f67a8
BLAKE2b-256 checksum
How to use checksums
4766836329841153231074dfa3b755bb65781845b776f4e08ca2da1680dd111f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / phastc-1.1.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL phastc-1.1.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 42.0 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
04b34a71731b09c809be1d1914a50bd8208ee5d0a9e5574c628c7bdc35cb6ae0
BLAKE2b-256 checksum
How to use checksums
d2b2413d6da649f1f29eb1bf516af87ef94b442443e7010a86466dbc7c152a8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / phastc-1.1.7-cp311-cp311-macosx_11_0_arm64.whl

Download URL phastc-1.1.7-cp311-cp311-macosx_11_0_arm64.whl
Size 41.9 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
52cc860d3e103a45488454c9fb01b21199f41d7a6b5425e6d7f39042656ea9e9
BLAKE2b-256 checksum
How to use checksums
3c1cbb414b31bd2386283b2dae3fcb037c5f9fd25ac10aace6788b56f2435ef7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / phastc-1.1.7-cp310-cp310-win_amd64.whl

Download URL phastc-1.1.7-cp310-cp310-win_amd64.whl
Size 41.9 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
7657e7ed17ef433fac262a821e0827a4effd17771d3853f6c9f15a22b7f4a49b
BLAKE2b-256 checksum
How to use checksums
704ddda103a76b3ecd9812b11b7e6d3f8a48bd67fc975c0cb50aade09513fe78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / phastc-1.1.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL phastc-1.1.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 42.0 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
65ffd34bb4ee5f26a9eb876698d6ff03d408acdf3a29d278da94a9f07399b878
BLAKE2b-256 checksum
How to use checksums
de78f415a2c6e3cf5453b181487d46b0f2e44f3f743e9120dc544da7e259ab99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / phastc-1.1.7-cp310-cp310-macosx_11_0_arm64.whl

Download URL phastc-1.1.7-cp310-cp310-macosx_11_0_arm64.whl
Size 41.9 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
09056fe5a30dd7fc3fea61d4ead29042c6cb5877406afa9448b73eeba6e259d7
BLAKE2b-256 checksum
How to use checksums
4723ee9fef72ad367ed6e94523c86e01b37b46d1fc035d0d50f3aad866fa38f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / phastc-1.1.7-cp39-cp39-win_amd64.whl

Download URL phastc-1.1.7-cp39-cp39-win_amd64.whl
Size 41.9 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
16395e500ef4092cc0b6a78b24084e2e8a76f6e3ed7a4ac16bd1c3b6a4d13e8f
BLAKE2b-256 checksum
How to use checksums
b0d6eb7c96a26bf737915cdf109968b8196eb3324046d6c243a680ada40d77a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / phastc-1.1.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL phastc-1.1.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 42.0 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
6e1f4afc27fd3e8b0aa02b05a4171debd12121b10538b3888f4daf4e9d1e6f11
BLAKE2b-256 checksum
How to use checksums
2f41ac70b5e95dc9758ff6692d95f054545c671086705340f76b5f6ff10aa294
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / phastc-1.1.7-cp39-cp39-macosx_11_0_arm64.whl

Download URL phastc-1.1.7-cp39-cp39-macosx_11_0_arm64.whl
Size 41.9 MB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9f61cb831b370b6549456074d9ac3db5e3f4e7ebb840a7b38546b8a3bad4bb99
BLAKE2b-256 checksum
How to use checksums
d61153a015dcd9ab9aeb163f7ef9dfe1bb95941e775e1a25dc9cc78b4502d7d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.7 This release

13 release files

1.1.5

13 release files

1.1.4

13 release files

1.1.3

13 release files

1.1.2

13 release files

1.1.1

13 release files

1.0.9

13 release files

1.0.8

13 release files

1.0.7

13 release files

1.0.6

20 release files

1.0.5

20 release files

1.0.1

20 release files

1.0.0

20 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page