Skip to content

Commit

Permalink
Add a few more action tests
Browse files Browse the repository at this point in the history
  • Loading branch information
teekuningas committed Feb 27, 2024
1 parent a2c24f4 commit 466586a
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
18 changes: 18 additions & 0 deletions meggie/actions/evoked_create/tests/test_evoked_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from meggie.utilities.testing import BaseTestAction
from meggie.actions.evoked_create import CreateEvoked
from meggie.utilities.dialogs.simpleDialogMain import SimpleDialog


class TestEvokedCreate(BaseTestAction):
def test_evoked_create(self):

data = {"inputs": {"epochs": ["Epochs"]}}

self.run_action(
action_name="evoked_create",
handler=CreateEvoked,
data=data,
patch_paths=["meggie.utilities.dialogs.simpleDialogMain"],
)
dialog = self.find_dialog(SimpleDialog)
dialog.accept()
15 changes: 15 additions & 0 deletions meggie/actions/evoked_delete/tests/test_evoked_delete.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from meggie.utilities.testing import BaseTestAction
from meggie.actions.evoked_delete import DeleteEvoked


class TestEvokedDelete(BaseTestAction):
def test_evoked_delete(self):

data = {"outputs": {"evoked": ["Evoked"]}}

self.run_action(
action_name="evoked_delete",
handler=DeleteEvoked,
data=data,
patch_paths=["meggie.actions.evoked_delete"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from meggie.utilities.testing import BaseTestAction
from meggie.actions.evoked_delete_from_all import DeleteEvokedFromAll


class TestEvokedDeleteFromAll(BaseTestAction):
def test_evoked_delete_from_all(self):

data = {"outputs": {"evoked": ["Evoked"]}}

self.run_action(
action_name="evoked_delete_from_all",
handler=DeleteEvokedFromAll,
data=data,
patch_paths=["meggie.actions.evoked_delete_from_all"],
)
14 changes: 12 additions & 2 deletions meggie/utilities/generate_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from meggie.utilities.events import find_events
from meggie.utilities.events import find_stim_channel
from meggie.datatypes.epochs.epochs import Epochs
from meggie.datatypes.evoked.evoked import Evoked


def create_experiment(
Expand Down Expand Up @@ -149,7 +150,7 @@ def create_test_experiment(experiment_folder, experiment_name, n_subjects=2):
experiment_folder, experiment_name, n_subjects=n_subjects
)

# create trivial epochs
# create trivial content
for subject in experiment.subjects.values():
raw = subject.get_raw()
stim_channel = find_stim_channel(raw)
Expand All @@ -163,6 +164,7 @@ def create_test_experiment(experiment_folder, experiment_name, n_subjects=2):
}
category = {"1": 1, "2": 2}

# create epochs
mne_epochs = mne.Epochs(
raw,
events,
Expand All @@ -171,12 +173,20 @@ def create_test_experiment(experiment_folder, experiment_name, n_subjects=2):
tmax=params["tmax"],
baseline=(params["bstart"], params["bend"]),
)

epochs_directory = subject.epochs_directory
epochs = Epochs("Epochs", epochs_directory, params, content=mne_epochs)
epochs.save_content()
subject.add(epochs, "epochs")

# create evoked
mne_evoked = mne_epochs.average()
params = {"conditions": ["epochs"]}
content = {"epochs": mne_evoked}
evoked_directory = subject.evoked_directory
evoked = Evoked("Evoked", evoked_directory, params, content=content)
evoked.save_content()
subject.add(evoked, "evoked")

return experiment


Expand Down

0 comments on commit 466586a

Please sign in to comment.