Skip to content

Commit

Permalink
better docstrings, added time support
Browse files Browse the repository at this point in the history
  • Loading branch information
kippfreud committed Jun 10, 2024
1 parent 4d41ca8 commit 09fc262
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions pynapple/process/signal_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@

def compute_fft(sig, fs):
"""
Performs numpy fft on sig, returns output
..todo: Make sig handle TsdFrame, TsdTensor
:param sig: :param fs: :return:
Parameters
----------
sig : pynapple.Tsd
The signal time series to obtain time frequency decomposition from
fs : int / float
The sampling frequency of sig
Returns
-------
"""
if not isinstance(sig, nap.Tsd):
raise TypeError("Currently compute_fft is only implemented for Tsd")
Expand Down Expand Up @@ -155,7 +162,7 @@ def compute_wavelet_transform(sig, fs, freqs, n_cycles=7, scaling=0.5, norm="amp
mwt = np.zeros([len(freqs), len(sig)], dtype=complex)
for ind, (freq, n_cycle) in enumerate(zip(freqs, n_cycles)):
mwt[ind, :] = _convolve_wavelet(sig, fs, freq, n_cycle, scaling, norm=norm)
return nap.TsdFrame(t=sig.index, d=np.transpose(mwt))
return nap.TsdFrame(t=sig.index, d=np.transpose(mwt), time_support=sig.time_support)
else:
mwt = np.zeros(
[sig.values.shape[0], len(freqs), sig.values.shape[1]], dtype=complex
Expand All @@ -165,7 +172,7 @@ def compute_wavelet_transform(sig, fs, freqs, n_cycles=7, scaling=0.5, norm="amp
mwt[:, ind, channel_i] = _convolve_wavelet(
sig[:, channel_i], fs, freq, n_cycle, scaling, norm=norm
)
return nap.TsdTensor(t=sig.index, d=mwt)
return nap.TsdTensor(t=sig.index, d=mwt, time_support=sig.time_support)


def _convolve_wavelet(
Expand Down

0 comments on commit 09fc262

Please sign in to comment.