Skip to content

Commit

Permalink
Add automatic inspection for what mne calls are made from actions for…
Browse files Browse the repository at this point in the history
… documentation purposes
  • Loading branch information
teekuningas committed Apr 15, 2024
1 parent 9dee5e9 commit 7c23438
Show file tree
Hide file tree
Showing 54 changed files with 361 additions and 89 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ test:
update_docs:
rm -fr docs_updated
cp -fr docs docs_updated
python scripts/update_docs.py docs_updated
python -m scripts.update_docs docs_updated

.PHONY: serve_docs
serve_docs: update_docs
serve_docs:
mkdocs serve

.PHONY: cov
Expand Down
2 changes: 1 addition & 1 deletion docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Meggie focuses on:
1. **Multi-Subject Management**: It makes it easy to work with many subjects' data at once.
2. **Clear Analysis Steps**: It helps users go step by step from starting data to results.

Compared to other tools like FieldTrip, MNE-Python, EEGLAB, Brainstorm, and mnelab, Meggie is unique because it's built with Python, it's easy for anyone to use, and it's designed for handling multiple subjects' data efficiently.
Compared to other tools like FieldTrip, MNE-Python, EEGLAB, Brainstorm, and MNELAB, Meggie is unique because it's built with Python, it's easy for anyone to use, and it's designed for handling multiple subjects' data efficiently.

## Plugins

Expand Down
1 change: 0 additions & 1 deletion meggie/actions/epochs_delete/tests/test_epochs_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ def test_epochs_delete(self):
action_name="epochs_delete",
handler=DeleteEpochs,
data=data,
patch_paths=["meggie.actions.epochs_delete"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ def test_epochs_delete_from_all(self):
action_name="epochs_delete_from_all",
handler=DeleteEpochsFromAll,
data=data,
patch_paths=["meggie.actions.epochs_delete_from_all"],
)
1 change: 0 additions & 1 deletion meggie/actions/epochs_info/tests/test_epochs_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ def test_epochs_info(self):
action_name="epochs_info",
handler=Info,
data=data,
patch_paths=["meggie.actions.epochs_info"],
)
assert content
3 changes: 2 additions & 1 deletion meggie/actions/epochs_plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ def run(self):
@subject_action
def handler(self, subject, params):
epochs = subject.epochs.get(params["name"])
epochs.content.plot()
mne_epochs = epochs.content
mne_epochs.plot()
7 changes: 1 addition & 6 deletions meggie/actions/epochs_plot/tests/test_epochs_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,4 @@ def test_epochs_plot(self):

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

self.run_action(
action_name="epochs_plot",
handler=PlotEpochs,
data=data,
patch_paths=["meggie.actions.epochs_plot"],
)
self.run_action(action_name="epochs_plot", handler=PlotEpochs, data=data)
3 changes: 2 additions & 1 deletion meggie/actions/epochs_plot_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def run(self):
@subject_action
def handler(self, subject, params):
epochs = subject.epochs.get(params["name"])
figs = epochs.content.plot_image()
mne_epochs = epochs.content
figs = mne_epochs.plot_image()
for fig in figs:
ch_type = get_figure_title(fig)
title = "{0}_{1}".format(params["name"], ch_type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ def test_epochs_plot_image(self):
action_name="epochs_plot_image",
handler=PlotEpochsImage,
data=data,
patch_paths=["meggie.actions.epochs_plot_image"],
)
1 change: 0 additions & 1 deletion meggie/actions/evoked_delete/tests/test_evoked_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ def test_evoked_delete(self):
action_name="evoked_delete",
handler=DeleteEvoked,
data=data,
patch_paths=["meggie.actions.evoked_delete"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ def test_evoked_delete_from_all(self):
action_name="evoked_delete_from_all",
handler=DeleteEvokedFromAll,
data=data,
patch_paths=["meggie.actions.evoked_delete_from_all"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ def test_evoked_group_average(self):
action_name="evoked_group_average",
handler=GroupAverage,
data=data,
patch_paths=["meggie.actions.evoked_group_average"],
)
dialog = self.find_dialog(GroupSelectionDialog)

dialog.ui.checkBoxGroup_0.setCheckState(QtCore.Qt.Checked)
dialog.ui.spinBoxGroup_0.setValue(1)
dialog.ui.checkBoxGroup_1.setCheckState(QtCore.Qt.Checked)
dialog.ui.spinBoxGroup_1.setValue(2)
dialog.ui.spinBoxGroup_1.setValue(1)

dialog.accept()
1 change: 0 additions & 1 deletion meggie/actions/evoked_info/tests/test_evoked_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ def test_evoked_info(self):
action_name="evoked_info",
handler=Info,
data=data,
patch_paths=["meggie.actions.evoked_info"],
)
assert content
11 changes: 6 additions & 5 deletions meggie/actions/evoked_plot/controller/evoked.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def plot_evoked_topo(subject, evoked, ch_type):
"""Plots evoked time courses arranged as a topography"""
evokeds = []
labels = []
for key, evok in sorted(evoked.content.items()):
for key, mne_evoked in sorted(evoked.content.items()):

info = evok.info
info = mne_evoked.info
if ch_type == "eeg":
dropped_names = [
ch_name
Expand All @@ -87,11 +87,12 @@ def plot_evoked_topo(subject, evoked, ch_type):
if ch_idx not in mne.pick_types(info, eeg=False, meg=True)
]

evok = evok.copy().drop_channels(dropped_names)
mne_evoked = mne_evoked.copy().drop_channels(dropped_names)

ensure_montage(subject, mne_evoked, ch_type)

ensure_montage(subject, evok, ch_type)
evokeds.append(mne_evoked)

evokeds.append(evok)
labels.append(key)

colors = color_cycle(len(evoked.content.keys()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_evoked_plot_all_channels(self):
action_name="evoked_plot",
handler=PlotEvoked,
data=data,
patch_paths=["meggie.actions.evoked_plot"],
)
dialog = self.find_dialog(OutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_evoked_plot_channel_averages(self):
action_name="evoked_plot",
handler=PlotEvoked,
data=data,
patch_paths=["meggie.actions.evoked_plot"],
)
dialog = self.find_dialog(OutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(True)
Expand Down
6 changes: 3 additions & 3 deletions meggie/actions/evoked_plot_topomap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def handler(self, subject, params):
radius = params["radius"]
evoked = subject.evoked.get(name)

for key, evok in sorted(evoked.content.items()):
channels = get_channels_by_type(evok.info)
for key, mne_evoked in sorted(evoked.content.items()):
channels = get_channels_by_type(mne_evoked.info)
for ch_type in channels.keys():
title_elems = [name, key, ch_type]
times = np.arange(tmin, tmax, step)
Expand All @@ -80,7 +80,7 @@ def handler(self, subject, params):
if ch_type in ["mag", "grad"]:
sphere = radius

fig = evok.plot_topomap(
fig = mne_evoked.plot_topomap(
times=times, ch_type=ch_type, axes=axes, sphere=sphere
)
set_figure_title(fig, "_".join(title_elems))
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_evoked_save_all_channels(self):
action_name="evoked_save",
handler=SaveEvoked,
data=data,
patch_paths=["meggie.actions.evoked_save"],
)
dialog = self.find_dialog(OutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_evoked_save_channel_averages(self):
action_name="evoked_save",
handler=SaveEvoked,
data=data,
patch_paths=["meggie.actions.evoked_save"],
)
dialog = self.find_dialog(OutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(True)
Expand Down
1 change: 0 additions & 1 deletion meggie/actions/raw_event_info/tests/test_raw_event_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ def test_raw_event_info(self):
content = self.run_action(
action_name="raw_event_info",
handler=Info,
patch_paths=["meggie.actions.raw_event_info"],
)
assert content
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ def test_raw_measurement_info(self):
content = self.run_action(
action_name="raw_measurement_info",
handler=Info,
patch_paths=["meggie.actions.raw_measurement_info"],
)
assert content
1 change: 0 additions & 1 deletion meggie/actions/raw_plot/tests/test_raw_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ def test_raw_plot(self):
self.run_action(
action_name="raw_plot",
handler=PlotRaw,
patch_paths=["meggie.actions.raw_plot"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ def test_raw_plot_projections(self):
self.run_action(
action_name="raw_plot_projections",
handler=PlotProjections,
patch_paths=["meggie.actions.raw_plot_projections"],
)
3 changes: 2 additions & 1 deletion meggie/actions/raw_resample/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def handler(self, subject, params):

@threaded
def resample_fun():
subject.get_raw().resample(params["rate"])
raw = subject.get_raw()
raw.resample(params["rate"])

resample_fun(do_meanwhile=self.window.update_ui)
subject.save()
1 change: 1 addition & 0 deletions meggie/actions/spectrum_create/controller/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
@threaded
def create_power_spectrum(subject, spectrum_name, intervals, fmin, fmax, nfft, overlap):
"""Creates a power spectrum item."""

# get raw objects organized with average groups as keys
ival_times, raw_block_groups = get_raw_blocks_from_intervals(subject, intervals)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ def test_spectrum_delete(self):
action_name="spectrum_delete",
handler=DeleteSpectrum,
data=data,
patch_paths=["meggie.actions.spectrum_delete"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ def test_spectrum_delete_from_all(self):
action_name="spectrum_delete_from_all",
handler=DeleteSpectrumFromAll,
data=data,
patch_paths=["meggie.actions.spectrum_delete_from_all"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ def test_spectrum_group_average(self):
action_name="spectrum_group_average",
handler=GroupAverage,
data=data,
patch_paths=["meggie.actions.spectrum_group_average"],
)
dialog = self.find_dialog(GroupSelectionDialog)

dialog.ui.checkBoxGroup_0.setCheckState(QtCore.Qt.Checked)
dialog.ui.spinBoxGroup_0.setValue(1)
dialog.ui.checkBoxGroup_1.setCheckState(QtCore.Qt.Checked)
dialog.ui.spinBoxGroup_1.setValue(2)
dialog.ui.spinBoxGroup_1.setValue(1)

dialog.accept()
1 change: 0 additions & 1 deletion meggie/actions/spectrum_info/tests/test_spectrum_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ def test_spectrum_info(self):
action_name="spectrum_info",
handler=Info,
data=data,
patch_paths=["meggie.actions.spectrum_info"],
)
assert content
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_spectrum_plot_all_channels(self):
action_name="spectrum_plot",
handler=PlotSpectrum,
data=data,
patch_paths=["meggie.actions.spectrum_plot"],
)
dialog = self.find_dialog(OutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_spectrum_plot_channel_averages(self):
action_name="spectrum_plot",
handler=PlotSpectrum,
data=data,
patch_paths=["meggie.actions.spectrum_plot"],
)
dialog = self.find_dialog(OutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_spectrum_save_all_channels(self):
action_name="spectrum_save",
handler=SaveSpectrum,
data=data,
patch_paths=["meggie.actions.spectrum_save"],
)
dialog = self.find_dialog(OutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_spectrum_save_channel_averages(self):
action_name="spectrum_save",
handler=SaveSpectrum,
data=data,
patch_paths=["meggie.actions.spectrum_save"],
)
dialog = self.find_dialog(OutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(True)
Expand Down
1 change: 0 additions & 1 deletion meggie/actions/tfr_delete/tests/test_tfr_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ def test_tfr_delete(self):
action_name="tfr_delete",
handler=DeleteTFR,
data=data,
patch_paths=["meggie.actions.tfr_delete"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ def test_tfr_delete_from_all(self):
action_name="tfr_delete_from_all",
handler=DeleteTFRFromAll,
data=data,
patch_paths=["meggie.actions.tfr_delete_from_all"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ def test_tfr_group_average(self):
action_name="tfr_group_average",
handler=GroupAverage,
data=data,
patch_paths=["meggie.actions.tfr_group_average"],
)
dialog = self.find_dialog(GroupSelectionDialog)

dialog.ui.checkBoxGroup_0.setCheckState(QtCore.Qt.Checked)
dialog.ui.spinBoxGroup_0.setValue(1)
dialog.ui.checkBoxGroup_1.setCheckState(QtCore.Qt.Checked)
dialog.ui.spinBoxGroup_1.setValue(2)
dialog.ui.spinBoxGroup_1.setValue(1)

dialog.accept()
1 change: 0 additions & 1 deletion meggie/actions/tfr_info/tests/test_tfr_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ def test_tfr_info(self):
action_name="tfr_info",
handler=Info,
data=data,
patch_paths=["meggie.actions.tfr_info"],
)
assert content
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_tfr_plot_all_channels(self):
action_name="tfr_plot",
handler=PlotTFR,
data=data,
patch_paths=["meggie.actions.tfr_plot"],
)
dialog = self.find_dialog(TFROutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_tfr_plot_channel_averages(self):
action_name="tfr_plot",
handler=PlotTFR,
data=data,
patch_paths=["meggie.actions.tfr_plot"],
)
dialog = self.find_dialog(TFROutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_tfr_plot_tse_all_channels(self):
action_name="tfr_plot_tse",
handler=PlotTSE,
data=data,
patch_paths=["meggie.actions.tfr_plot_tse"],
)
dialog = self.find_dialog(TFROutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_tfr_plot_tse_channel_averages(self):
action_name="tfr_plot_tse",
handler=PlotTSE,
data=data,
patch_paths=["meggie.actions.tfr_plot_tse"],
)
dialog = self.find_dialog(TFROutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_tfr_save_all_channels(self):
action_name="tfr_save",
handler=SaveTFR,
data=data,
patch_paths=["meggie.actions.tfr_save"],
)
dialog = self.find_dialog(TFROutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_tfr_save_channel_averages(self):
action_name="tfr_save",
handler=SaveTFR,
data=data,
patch_paths=["meggie.actions.tfr_save"],
)
dialog = self.find_dialog(TFROutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_tfr_save_tse_all_channels(self):
action_name="tfr_save_tse",
handler=SaveTSE,
data=data,
patch_paths=["meggie.actions.tfr_save_tse"],
)
dialog = self.find_dialog(TFROutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def test_tfr_save_tse_channel_averages(self):
action_name="tfr_save_tse",
handler=SaveTSE,
data=data,
patch_paths=["meggie.actions.tfr_save_tse"],
)
dialog = self.find_dialog(TFROutputOptions)
dialog.ui.radioButtonChannelAverages.setChecked(True)
Expand Down
Loading

0 comments on commit 7c23438

Please sign in to comment.