spctrm generates results identical to the procedure of the same name described in Numerical Recipes in C (Press et al., Cambridge University Press), with Bartlett window and overlapping data segments. NEURON's spctrm differs in the following ways:
1. It takes only one argument--a vector of data sampled at regular intervals, which may contain any number of samples.
2. It handles zero padding and selects the number of data segments automatically. Consequently the number of frequency bins, and the number of data segments that are averaged to calculate the power density in these bins, are not subject to user control--see
Relationship between sample length and results below.
Given that the sample interval is dt, the Nyquist frequency is 1/(2*dt).
Given that the number of frequency bins is numf ( == length of result vector), then the frequency bin centers are at i/(2*dt*numf) where i = 0..numf-1. That is, the result vector contains signal power in numf frequency bins centered at 0, 1/(2*dt*numf), . . (numf-1)/(2*dt*numf).
Relationship between sample length and results
I ran some tests and found that the data vector must contain at least 16 samples in order to obtain a result vector with at least two elements (power at 0 Hz (DC) and one nonzero frequency). Furthermore, the number of frequencies in the result vector is a monotonically increasing staircase function of the number of data samples in the argument vector. The relationship between argument length and result length is summarized by this table, which lists the argument lengths (number of samples or "# S") at which the result length (number of frequencies or "# F") increases:
Code: Select all
# S # F
16 2
24 4
40 8
72 16
136 32
264 64
520 128
1032 256
One last note: there are many different ways to analyze the spectral content of signals, each with its own particular strengths and weaknesses. Almost certainly some of these have been implemented with Python, and should be callable directly from hoc.