Skip to content

Commit

Permalink
add test for bispectra feature and add dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
timonmerk committed Oct 2, 2023
1 parent b4522d6 commit e9cab20
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ dependencies = [
"scipy >= 1.7.1",
"seaborn >= 0.11",
"notebook",
"ipython"
"ipython",
"pybispectra"
]

[project.optional-dependencies]
Expand Down
67 changes: 67 additions & 0 deletions tests/test_bispectra.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import pytest
import mne
import numpy as np

from py_neuromodulation import (
nm_analysis,
nm_decode,
nm_define_nmchannels,
nm_IO,
nm_plots,
nm_settings,
nm_stream_offline
)

def test_bispectrum():

(
RUN_NAME,
PATH_RUN,
PATH_BIDS,
PATH_OUT,
datatype,
) = nm_IO.get_paths_example_data()

(
raw,
data,
sfreq,
line_noise,
coord_list,
coord_names,
) = nm_IO.read_BIDS_data(
PATH_RUN=PATH_RUN, BIDS_PATH=PATH_BIDS, datatype=datatype
)

ch_names = raw.ch_names[4]
ch_types = raw.get_channel_types()[4]

nm_channels = nm_define_nmchannels.set_channels(
ch_names=[ch_names],
ch_types=[ch_types],
reference="default",
bads=None,
new_names="default",
used_types=("ecog", "dbs", "seeg"),
target_keywords=("MOV_RIGHT_CLEAN",),
)

settings = nm_settings.get_default_settings()
settings = nm_settings.reset_settings(settings)

settings["features"]["bispectrum"] = True

stream = nm_stream_offline.Stream(
settings=settings,
nm_channels=nm_channels,
path_grids=None,
verbose=True,
sfreq=sfreq,
line_noise=line_noise,
coord_list=coord_list,
coord_names=coord_names,
)

features = stream.run(np.expand_dims(data[3, :], axis=0))

assert features["ECOG_RIGHT_1_Bispectrum_phase_mean_whole_fband_range"].sum() != 0

0 comments on commit e9cab20

Please sign in to comment.