# Matlab code for "Cancellation model of pitch perception", submitted to JASA.

This page is freely accessible to anyone who knows its address, but it is not a public page. Please do not put a link to it from any public page without my permission.

This page is a walk-through of the bits of matlab code.
Before you try to use this stuff: get Malcolm Slaney's
AuditoryToolbox matlab code in its Macintosh or Unix versions. Put it in your local matlab toolbox directory. I made a few modifications to MakeVowel.m and MeddisHairCell.m which are included together with my other files, where they should override the originals. Get my matlab code in gzipped tar format. It has been tested on Matlab 5.0, but it should work with 4.2.
## Ingredients

Just in case I forgot to put a link or mispelled something, here is a list of files in the ./matlab/ directory.
### Stimulus generation

Here are scripts to generate various stimuli, including those used in the paper. synth_complex1.m is the 10-harmonic complex used in the paper. There are also synth_complex2.m
and synth_complex3.m. synth_ramp.m and synth_damp.m are Patterson's ramped and damped stimuli, synth_noise.m is gaussian noise, synth_ripple_plus.m and synth_ripple_minus.m are rippled noise, synth_AM_noise.m is AM moise and synth_QFM.m is a QFM complex.
### Processing

bm_haircell.m calls Malcolm Slaney's implementation of the gammatone filter bank and Meddis's haircell model. cfilt.m applies a cancellation filter, and hwrect.m does halfwave rectification.
acf2.m calculates the ACF, sdf2.m the SDF, and rdf2.m the RDF. rdf3.m is a modified RDF that squares the difference before integration, and rdf4.m is a modified RDF that applies a factor (alpha) to one term before subtraction.

spike_train.m is the spike generation model. It calls poisson.m for the poisson model, and spike_dead.m to implement refractory effects. discharge_rate.m measures the discharge rate. ach1.m calculates the autocorrelation histogram. ac_pattern.m implements the excitatory interaction model (basically an autocorrelation histogram), and ad_pattern.m the inhibitory interaction model.

### Display

plot0.m encapsulates matlab's stairs() command, and plot1.m and plot1_bis.m encapsulate matlab's plot() command, to display 1D arrays. plot2.m displays 2D arrays with matlab's waterfall() command.
### Miscellaneous

abscissa.m makes an abscissa array for plotting. dump.m dumps arrays in ascii format. fromdB.m transforms dB to linear factors. histogram.m is faster than matlab's hist().

## Scripts

### Figures of the JASA paper

- fig1.m
- fig2a.m, fig2b.m
- fig3a.m, fig3b.m
- fig4a.m, fig4b.m
- fig5a.m, fig5b.m
- fig7a.m, fig7b.m
- fig8a.m, fig8b.m
- fig9a.m, fig9b.m
- fig10a.m, fig10b.m
- fig11a.m, fig11b.m
- fig12a.m, fig12b.m, fig12c.m

### Scripts for other stimuli

A: comparison of ACF and SDF, B: comparison of mutichannel ACF (Meddis and Hewitt) and RDF, C: comparison of SACF and SRDF.

Alain's home page.