NIM Code

The Nonlinear Input Model (NIM)

The Nonlinear Input Model (NIM) is a statistical model for describing nonlinear computation performed by sensory neurons. The predicted firing rate of this model is generated by an LNLN cascade, which is a sum over linear-nonlinear (LN) inputs followed by a 'spiking nonlinearity':

NIM Schematic

Each LN input performs linear stimulus processing, followed by a 'upstream nonlinearity' that is assumed to be some rectifying function, but can also encompass linear, quadratic, and non-parametric forms. The sign of the subunit output can be positive or negative, representing excitatory or suppressive terms, and thus is consistent with a physiological interpretation of a neuron that linearly integrates its excitatory and inhibitory inputs. It also might be viewed as a two-level neural network capable (in principle) of representing any nonlinear function of the stimulus.

The subunit filters, and the form of the 'upstream nonlinearities', can be inferred from the data (along with additional linear terms describing e.g. spike-history dependence), and it can operate on multiple stimulus covariates into calculating neural firing rates (each which can have associated non-linear subunits) as well as some forms of multiplicative (gain/normalization-like) interactions.

This model and methods for fitting -- as well as a number of applications to real and simulated data -- were described in our original paper:

  • McFarland JM, Cui Y, Butts DA (2013) Inferring nonlinear neuronal computation based on physiologically plausible inputs. PLoS Computational Biology 9(7): e1003142. [PDF on PLoS website, Supplemental Materials]

This model can implicitly be used to fit other previously suggested LN and LNLN cascade models of neural spiking:

  • Generalized Linear Model (GLM) [Paninski (2004); Truccolo et al. (2005)], where the upstream nonlinearities are fixed as linear.
  • Generalized Quadratic Model (GQM) [Park and Pillow (2011)], where the upstream nonlinearities are fixed to be linear and quadratic.
  • Generalized Nonlinear Model (GNM) [Butts et al. (2011)], which is an early version of the NIM applied to LGN data.


We have produced a Matlab toolbox for estimating parameters of the Nonlinear Input Model from spiking data (see links below). In addition to routines for estimating the stimulus filters and upstream nonlinearities associated with each nonlinear input, the toolbox contains functions for estimating parameters of the spiking nonlinearity function, and includes built-in support for modeling spike-history dependence. Likewise, upstream nonlinearities can be fixed to estimate the GLM and GQM. Several different forms of regularization on the stimulus filters and upstream nonlinearities are currently supported, including sparseness (L1 norm) and several forms of smoothness (L2 norm) regularization. Thus, this code provides a general tool to estimate a variety of model forms in the literature, as the example applications below illustrate.

The current version of the NIM code is written in object-oriented Matlab, and is accessible at Github and can be accessed here: NIMclass. Please see instructions on the GitHub site for different ways for downloading. Once downloaded, its directory should be added to your Matlab path. Notably, some extended features of the code use an optimization toolbox created by Mark Schmidt, which can be downloaded from his website. In particular, Mark Schmidt's L1-optimization routines must be installed to use L1-regularization.

This site also has a detailed manual for use, and we illustrate a range of applications through the following tutorials:

  • application to processed data from an LGN neuron in response to temporally modulated white noise stimuli, recorded in the Alonso Lab (SUNY), and described in detail in Butts et al. (2011). Includes demonstration of applications of spike-history terms, alternative models, regularization, and cross-validation.
  • More coming September 2019

See the references and help documentation for further details. Please report any bugs to: dab at umd dot edu.

Original (2013) Tutorials (to be updated):

  • simulated ON-OFF retinal ganglion cell in response to temporally modulated white noise (see Figures 1 and 3 in the manuscript).
  • application to processed data from an LGN neuron in response to temporally modulated white noise stimuli, recorded in the Alonso Lab (SUNY), and described in detail in Butts et al. (2011). Includes demonstration of applications of spike-history terms, and cross-validation.
  • simulated V1 neuron in response to optimally oriented "random bar" data (see Figure 6 in the manuscript).
  • simulated auditory neuron in response to naturalistic sound (represented in a spectrogram). Includes demonstration of nested cross-validation and regularization.
  • More applications (to simulated and real data) to be added...

Contributed applications of the NIM welcome!

Additional Background

The LNLN cascade model is now one of many forms of statistical model that can now be fit using modern methods, and we recently covered this broader context (and what can be learned) in a review paper:

  • Butts DA (2019) Data-driven approaches to understanding visual neuron activity. Annual Review of Vision Science 5: 451-77. [Link]

Other Related Papers:

  • Lau B, Stanley GB, Dan Y (2002) Computational subunits of visual cortical neurons revealed by artificial neural networks. PNAS 99: 8974–79.
  • Prenger R, Wu MCK, David SV, Gallant JL (2004) Nonlinear V1 responses to natural scenes revealed by neural network analysis. Neural Networks. 17: 663–79.
  • Butts DA, Weng C, Jin JZ, Alonso JM, Paninski L (2011) Temporal precision in the visual pathway through the interplay of excitation and stimulus-driven suppression. J. Neurosci. 31: 11313-27. [PDF, Additional information]
  • Schinkel-Bielefeld N, David SV, Shamma SA, Butts DA (2012) Inferring the role of inhibition in auditory processing of complex natural stimuli. J. Neurophysiol. 107: 3296. [PDF]
  • Lochmann T, Blanche TJ, Butts DA (2013) Pooling of local features as a basis for direction selectivity in the primary visual cortex. PLoS One 8: e58666. [PDF]
  • Paninski L (2004) Maximum likelihood estimation of cascade point-process neural encoding models. Network 15: 243-262.
  • Truccolo W, Eden UT, Fellows MR, Donoghue JP, Brown EN (2005) A point process framework for relating neural spiking activity to spiking history, neural ensemble, and extrinsic covariate effects. J Neurophysiol 93: 1074-1089.
  • Park IM, Pillow JW (2011) Bayesian spike-triggered covariance analysis. Adv Neural Inf Process Syst (NIPS) 24: 1692-1700.