I have recorded data from a neuron from different trials. Each trial we show a stimulus to a rat and then we measure the neural activity. I want to measure the PSTH which is peristimulus time histogram. However since each trial has a different duration, I can't just compute the PSTH where it needs to have a fixed trial duration.

If I want to make my question more general it would be stated as follows:

Suppose I have a point process with a defined underlying rate function (which may or may not be homogenous). Now I have different observations from this process, i,e., different trials with different durations.

Say, one time I have data from this process for 2 seconds and another trial for 5 seconds and so on.

How can I compute the underlying the rate function assuming that the underlying rate function doesn't change from one trial to another trial?

**Contents**hide

#### Best Answer

You could get fancier, but here's a simple, standard way to do it. Say you have a set of spike times for each trial and you want to calculate a binned PSTH. All times are measured relative to the stimulus at time 0. Set up a number of equally-sized, non-overlapping time bins covering the interval from the minimum to the maximum time point in any trial. Let $t_i$ be the center time of bin $i$ and $Delta t$ be the bin width (both measured in seconds). Let $s_i$ be the total number of spikes that fall into bin $i$ (summing over all trials). Let $o_i$ be the number of trials that are long enough to include $t_i$. The average number of spikes in bin $i$ (averaged across trials) is then $s_i / o_i$. Dividing by $o_i$ instead of the number of trials lets you deal with trials of different lengths. The firing rate in bin $i$ is $f_i = s_i / o_i / Delta t$ (spikes per second = Hz).

### Similar Posts:

- Solved – Correlated binomial distribution
- Solved – Determining the statistical significance of differences in a small dataset
- Solved – Statistical comparison between binomial distributions, two groups and many trials
- Solved – Relation between binomial and negative binomial
- Solved – Different variance-covariance matrices of random effects per fixed-effect group in lme4