Skip to content

Commit

Permalink
Add rest of the raw action tests
Browse files Browse the repository at this point in the history
  • Loading branch information
teekuningas committed Mar 1, 2024
1 parent 41323ba commit 21ebd02
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 22 deletions.
12 changes: 6 additions & 6 deletions meggie/actions/raw_events_from_annotations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ class EventsFromAnnotations(Action):
applies a conversion from annotations to events.
"""

def run(self):
evs_from_annots_dialog = EventsFromAnnotationsDialog(
self.window, self.experiment, self.handler
)
evs_from_annots_dialog.show()

@subject_action
def handler(self, subject, params):
""" """
Expand All @@ -29,9 +35,3 @@ def conv_fun():
subject.save()

conv_fun(do_meanwhile=self.window.update_ui)

def run(self):
evs_from_annots_dialog = EventsFromAnnotationsDialog(
self.window, self.experiment, self.handler
)
evs_from_annots_dialog.show()
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import mne

from meggie.utilities.testing import BaseTestAction
from meggie.actions.raw_events_from_annotations import EventsFromAnnotations
from meggie.actions.raw_events_from_annotations.dialogs.eventsFromAnnotationsDialogMain import (
EventsFromAnnotationsDialog,
)


class TestRawEventsFromAnnotations(BaseTestAction):

def setup_experiment(self):
BaseTestAction.setup_experiment(self)
raw = self.experiment.active_subject.get_raw()

# create one annotation named "CAT"
annotations = mne.Annotations([2], [1], ["CAT"])
raw.set_annotations(annotations)

def test_raw_events_from_annotations(self):
self.run_action(
action_name="raw_events_from_annotations",
handler=EventsFromAnnotations,
patch_paths=[
"meggie.actions.raw_events_from_annotations.dialogs.eventsFromAnnotationsDialogMain"
],
)
dialog = self.find_dialog(EventsFromAnnotationsDialog)
dialog.items = [("CAT", 99, True)]
dialog.accept()
8 changes: 4 additions & 4 deletions meggie/actions/raw_filter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class Filter(Action):
filtering the raw data.
"""

def run(self):
filter_dialog = FilterDialog(self.window, self.experiment, self.handler)
filter_dialog.show()

@subject_action
def handler(self, subject, params):
""" """
Expand All @@ -24,7 +28,3 @@ def filter_fun():
filter_data(subject, params)

filter_fun(do_meanwhile=self.window.update_ui)

def run(self):
filter_dialog = FilterDialog(self.window, self.experiment, self.handler)
filter_dialog.show()
17 changes: 17 additions & 0 deletions meggie/actions/raw_filter/tests/test_raw_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from meggie.utilities.testing import BaseTestAction
from meggie.actions.raw_filter import Filter
from meggie.actions.raw_filter.dialogs.filterDialogMain import (
FilterDialog,
)


class TestRawFilter(BaseTestAction):
def test_raw_filter(self):

self.run_action(
action_name="raw_filter",
handler=Filter,
patch_paths=["meggie.actions.raw_filter.dialogs.filterDialogMain"],
)
dialog = self.find_dialog(FilterDialog)
dialog.accept()
37 changes: 37 additions & 0 deletions meggie/actions/raw_ica/tests/test_raw_ica.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from meggie.utilities.testing import BaseTestAction
from meggie.actions.raw_ica import ICA
from meggie.actions.raw_ica.dialogs.icaDialogMain import (
ICADialog,
)


class TestRawICA(BaseTestAction):
def test_raw_ica(self):

self.run_action(
action_name="raw_ica",
handler=ICA,
patch_paths=["meggie.actions.raw_ica.dialogs.icaDialogMain"],
)
dialog = self.find_dialog(ICADialog)

# Compute the components
dialog.ui.doubleSpinBoxNComponents.setValue(0.3)
dialog.ui.pushButtonCompute.click()

# Select first item
dialog.ui.listWidgetNotRemoved.setCurrentRow(0)

# Try all the plots
dialog.ui.pushButtonPlotTopographies.click()
dialog.ui.pushButtonPlotSources.click()
dialog.ui.pushButtonPlotProperties.click()

# Transfer to be removed
dialog.ui.pushButtonTransfer.click()

# Try plotting changes
dialog.ui.pushButtonPlotChanges.click()

# Finish
dialog.accept()
2 changes: 0 additions & 2 deletions meggie/actions/raw_montage/dialogs/montageDialogMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ def __init__(self, parent, experiment, handler):
self.current_montage_fname = None
self.ui.radioButtonMontageFromList.setChecked(True)

# find out if montage already set.

self.batching_widget = BatchingWidget(
experiment_getter=self._experiment_getter,
parent=self,
Expand Down
33 changes: 33 additions & 0 deletions meggie/actions/raw_montage/tests/test_raw_montage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from meggie.utilities.testing import BaseTestAction
from meggie.actions.raw_montage import Montage
from meggie.actions.raw_montage.dialogs.montageDialogMain import (
MontageDialog,
)


class TestRawMontage(BaseTestAction):

def setup_experiment(self):
BaseTestAction.setup_experiment(self)
raw = self.experiment.active_subject.get_raw()

# rename channels to match the one lucky montage that comes in mne
raw.rename_channels(
dict(
[
(old, old.split(" ")[0] + old.split(" ")[1])
for old in raw.info["ch_names"]
]
)
)

def test_raw_montage(self):

self.run_action(
action_name="raw_montage",
handler=Montage,
patch_paths=["meggie.actions.raw_montage.dialogs.montageDialogMain"],
)
dialog = self.find_dialog(MontageDialog)
dialog.ui.comboBoxSelectFromList.setCurrentText("mgh60.elc")
dialog.accept()
12 changes: 6 additions & 6 deletions meggie/actions/raw_rereference/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
class Rereference(Action):
"""Shows a dialog and then allows rereferencing eeg data."""

def run(self):
rereference_dialog = RereferencingDialog(
self.window, self.experiment, self.handler
)
rereference_dialog.show()

@subject_action
def handler(self, subject, params):
""" """
Expand All @@ -29,9 +35,3 @@ def rereference_fun():
rereference_fun(do_meanwhile=self.window.update_ui)
subject.rereferenced = True
subject.save()

def run(self):
rereference_dialog = RereferencingDialog(
self.window, self.experiment, self.handler
)
rereference_dialog.show()
19 changes: 19 additions & 0 deletions meggie/actions/raw_rereference/tests/test_raw_rereference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from meggie.utilities.testing import BaseTestAction
from meggie.actions.raw_rereference import Rereference
from meggie.actions.raw_rereference.dialogs.rereferencingDialogMain import (
RereferencingDialog,
)


class TestRawRereference(BaseTestAction):
def test_raw_rereference(self):

self.run_action(
action_name="raw_rereference",
handler=Rereference,
patch_paths=[
"meggie.actions.raw_rereference.dialogs.rereferencingDialogMain"
],
)
dialog = self.find_dialog(RereferencingDialog)
dialog.accept()
8 changes: 4 additions & 4 deletions meggie/actions/raw_resample/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class Resample(Action):
resampling data of the subject.
"""

def run(self):
resampling_dialog = ResamplingDialog(self.window, self.experiment, self.handler)
resampling_dialog.show()

@subject_action
def handler(self, subject, params):
""" """
Expand All @@ -24,7 +28,3 @@ def resample_fun():

resample_fun(do_meanwhile=self.window.update_ui)
subject.save()

def run(self):
resampling_dialog = ResamplingDialog(self.window, self.experiment, self.handler)
resampling_dialog.show()
17 changes: 17 additions & 0 deletions meggie/actions/raw_resample/tests/test_raw_resample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from meggie.utilities.testing import BaseTestAction
from meggie.actions.raw_resample import Resample
from meggie.actions.raw_resample.dialogs.resamplingDialogMain import (
ResamplingDialog,
)


class TestRawResample(BaseTestAction):
def test_raw_resample(self):

self.run_action(
action_name="raw_resample",
handler=Resample,
patch_paths=["meggie.actions.raw_resample.dialogs.resamplingDialogMain"],
)
dialog = self.find_dialog(ResamplingDialog)
dialog.accept()

0 comments on commit 21ebd02

Please sign in to comment.