Skip to content

Commit

Permalink
Update bispectra feature (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsbinns authored Oct 4, 2024
1 parent 21b6144 commit 6fc5f95
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions py_neuromodulation/features/bispectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,8 @@ def __init__(
def calc_feature(self, data: np.ndarray) -> dict:
from pybispectra import compute_fft, WaveShape

# PyBispectra's compute_fft uses PQDM to parallelize the calculation per channel
# Is this necessary? Maybe the overhead of parallelization is not worth it
# considering that we incur in it once per batch of data
fft_coeffs, freqs = compute_fft(
data=np.expand_dims(data, axis=(0)),
data=np.expand_dims(data, axis=0),
sampling_freq=self.sfreq,
n_points=data.shape[1],
verbose=False,
Expand All @@ -127,12 +124,11 @@ def calc_feature(self, data: np.ndarray) -> dict:
f1s=tuple(self.settings.f1s), # type: ignore
f2s=tuple(self.settings.f2s), # type: ignore
)
waveshape = waveshape.results.get_results(copy=False) # can overwrite obj with array

feature_results = {}
for ch_idx, ch_name in enumerate(self.ch_names):
bispectrum = waveshape._bicoherence[
ch_idx
] # Same as waveshape.results._data, skips a copy
bispectrum = waveshape[ch_idx]

for component in self.settings.components.get_enabled():
spectrum_ch = COMPONENT_DICT[component](bispectrum)
Expand Down

0 comments on commit 6fc5f95

Please sign in to comment.