Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: normalization of power spectra... #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions neurodynex/tools/spike_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ def _get_spike_train_power_spectrum(spike_train, delta_t, subtract_mean=False):
N_signal = data.size
ps = np.abs(np.fft.fft(data))**2
# normalize
ps = ps * delta_t / N_signal # TODO: verify: subtract 1 (N_signal-1)?
T_signal = N_signal * delta_t
ps = ps / T_signal # TODO: verify: subtract 1 (N_signal-1)?
freqs = np.fft.fftfreq(N_signal, delta_t)
ps = ps[:(N_signal/2)]
freqs = freqs[:(N_signal/2)]
Expand Down Expand Up @@ -420,7 +421,7 @@ def get_population_activity_power_spectrum(
k_ps = np.abs(np.fft.fft(data))**2
ps = np.mean(k_ps, 0)
# normalize
ps = ps * delta_t / N_signal # TODO: verify: subtract 1 (N_signal-1)?
ps = ps / T_signal # TODO: verify: subtract 1 (N_signal-1)?
freqs = np.fft.fftfreq(N_signal, delta_t)
ps = ps[:(N_signal/2)]
freqs = freqs[:(N_signal/2)]
Expand Down