an_model¶
cnmodel.an_model.cache¶
Utilities for generating and caching spike trains from AN model.
-
cnmodel.an_model.cache.detect_simulator()[source] Return the name of any available auditory periphery model.
Return ‘cochlea’ if the Rudnicki cochlea model can be imported. If not, return ‘matlab’ if the Zilany model can be accessed via MATLAB. If not, raise an exception.
-
cnmodel.an_model.cache.generate_spiketrain(cf, sr, stim, seed, simulator=None, **kwds)[source] Generate a new spike train from the auditory nerve model. Returns an array of spike times in seconds.
Parameters: - cf (float) – Center frequency of the fiber to simulate
- sr (int) – Spontaneous rate group of the fiber: 0=low, 1=mid, 2=high.
- stim (Sound instance) – Stimulus sound to be presented on each repetition
- seed (int >= 0) – Random seed
- simulator ('cochlea' | 'matlab' | None) – Specifies the auditory periphery simulator to use. If None, then a simulator will be automatically chosen based on availability.
- **kwds – All other keyword arguments are given to model_ihc() and model_synapse() based on their names. These include ‘species’, ‘nrep’, ‘reptime’, ‘cohc’, ‘cihc’, and ‘implnt’. ‘simulator’ is used to set the simulator (‘matlab’ or ‘cochlea’)
-
cnmodel.an_model.cache.get_cache_filename(cf, sr, seed, stim, **kwds)[source]
-
cnmodel.an_model.cache.get_spiketrain(cf, sr, stim, seed, **kwds)[source] Return an array of spike times in response to the given stimulus.
Arrays are automatically cached and may be returned from disk if available. See generate_spiketrain() for a description of arguments.
If the flag –ignore-an-cache was given on the command line, then spike times will be regenerated and cached, regardless of the current cache state.
If the flag –no-an-cache was given on the command line, then the cache will not be read or written. This can improve overall performance if there is little chance the cache would be re-used.
-
cnmodel.an_model.cache.make_key(**kwds)[source] Make a unique key used for caching spike time arrays.
cnmodel.an_model.wrapper¶
-
cnmodel.an_model.wrapper.get_matlab()[source] Return a running MatlabProcess instance.
-
cnmodel.an_model.wrapper.model_ihc(pin, CF, nrep=1, tdres=1e-05, reptime=1, cohc=1, cihc=1, species=1, **kwds)[source] Return the output of model_IHC() from the AN model (Zilany, Bruce, Ibrahim and Carney, 2014; requires MATLAB)
This function takes a sound waveform as input and models a single inner hair cell (IHC). The return values is the IHC potential in volts.
Parameters: - pin (array) – The input sound wave in Pa sampled at the rate specified by tdres
- CF (float) – The characteristic frequency of the IHC in Hz
- nrep (int) – The number of times to repeat the stimulus
- tdres (float) – The binsize in seconds, i.e., the reciprocal of the sampling rate
- reptime (float) – The time between stimulus repetitions in seconds. NOTE should be equal to or longer than the duration of pin
- cohc (float) – The OHC scaling factor: 1 is normal OHC function; 0 is complete OHC dysfunction
- cihc (float) – The IHC scaling factor: 1 is normal IHC function; 0 is complete IHC dysfunction
- species (int) – The model species: “1” for cat, “2” for human with BM tuning from Shera et al. (PNAS 2002), or “3” for human BM tuning from Glasberg & Moore (Hear. Res. 1990)
-
cnmodel.an_model.wrapper.model_synapse(vihc, CF, nrep=1, tdres=1e-05, fiberType=0, noiseType=1, implnt=1, **kwds)[source] Return the output of model_Synapse() from the AN model (Zilany, Bruce, Ibrahim and Carney, 2014; requires MATLAB)
This function takes an IHC voltage waveform as input (see model_ihc) and models a synapse and spiral ganglion cell. The return values are:
- meanrate: The estimated instantaneous mean rate (incl. refractoriness)
- varrate: The estimated instantaneous variance in the discharge rate (incl. refractoriness)
- psth: The peri-stimulus time histogram
Parameters: - vihc (array) – IHC voltage as generated by model_ihc()
- CF (float) – The characteristic frequency of the IHC in Hz
- nrep (int) – The number of times to repeat the stimulus
- tdres (float) – The binsize in seconds, i.e., the reciprocal of the sampling rate
- fiberType (int) – The type of the fiber based on spontaneous rate (SR) in spikes/s: 1 for Low SR; 2 for Medium SR; 3 for High SR
- noiseType (0 or 1) – Fixed fGn (noise will be same in every simulation) or variable fGn: “0” for fixed fGn and “1” for variable fGn
- implnt (0 or 1) – “Approxiate” or “actual” implementation of the power-law functions: “0” for approx. and “1” for actual implementation
-
cnmodel.an_model.wrapper.seed_rng(seed)[source] Seed the random number generator used by model_ihc and model_synapse.