Preprocessing routines (stnmf.preprocessing)

Data is brought into appropriate format to be used with and passed to stnmf.STNMF.

Spike-triggered analyses (stnmf.preprocessing.spiketriggered)

Collection of functions performing spike-triggered analyses for multiple cells

average(stimulus, spikes, tau[, continuous, ...])

Compute the spike-triggered average (STA) for multiple cells

stimulusensemble(stimulus, spikes, sta_temp)

Collect the effective spike-triggered stimulus ensemble (STE)

window(sta[, sd])

Obtain the spatial crop dimensions containing the receptive field for multiple cells

profiles(sta[, crop])

Obtain temporal and spatial profiles of the STA for multiple cells

Data preparation

stnmf.STNMF expects an effective spike-triggered stimulus ensemble (STE) as input. To format the stimulus and spike response into an STE the following pipeline can be utilized.

Data requirements

  • Spatiotemporal stimulus as iterator or iterable with each element yielding a (x,y,trial_length) array_like. For instance, that may be a (num_trials,x,y,trial_length) numpy.ndarray. The spatial dimensions should enclose the entire projector screen. It will be cropped for each cell. Each array element is a pixel contrast value deviating from zero either negatively (darker) or positively (brighter).

  • Binned spike counts as (num_trials,trial_length,num_cells) array_like. Each array element is a non-negative integer describing the number of spikes within the (equally sized) time bin.

Pipeline

>>> from stnmf.preprocessing import spiketriggered
  1. Calculate the spike-triggered averages (STAs) of all cells.

    >>> stas = spiketriggered.average(stimulus, spikes, tau)
    
  2. Find the relevant spatial windows around the STAs for all cells.

    >>> crops = spiketriggered.window(stas)
    
  3. Create the temporal profile of the STAs.

    >>> sta_space, sta_temp = spiketriggered.profiles(stas, crops)
    
  4. For each cell idx individually, select its respective data

    >>> stim = stimulus[:, crops[idx], :]
    >>> spk = spikes[..., idx]
    >>> temporal = sta_temp[idx]
    

    and create the STE, the input for STNMF.

    >>> ste = spiketriggered.stimulusensemble(stim, spk, temporal)
    

Note

Review the individual function signatures to specify additional parameters.