Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ dependencies = [
]

[project.optional-dependencies]
torch = [
"torch>=2.0"
]
gui = [
"pyqtgraph>=0.13.7",
"PySide6>=6.6",
Expand All @@ -66,7 +63,6 @@ docs = [
"sphinxcontrib-spelling>=7.1.0"
]
all = [
"eegprep[torch]",
"eegprep[gui]",
"eegprep[console]",
"eegprep[docs]",
Expand Down
51 changes: 27 additions & 24 deletions src/eegprep/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"ExtensionStatus": ("eegprep.extensions", "ExtensionStatus"),
"ExtensionTestHarness": ("eegprep.extension_testing", "ExtensionTestHarness"),
"ExtensionValidationResult": ("eegprep.extensions", "ExtensionValidationResult"),
"ICL_feature_extractor": ("eegprep.plugins.ICLabel.ICL_feature_extractor", "ICL_feature_extractor"),
"LazyImport": ("eegprep.extensions", "LazyImport"),
"assert_extension_entry_point_loads": ("eegprep.extension_testing", "assert_extension_entry_point_loads"),
"bids_list_eeg_files": ("eegprep.plugins.EEG_BIDS.bids_list_eeg_files", "bids_list_eeg_files"),
Expand All @@ -59,16 +58,7 @@
"chancenter": ("eegprep.functions.sigprocfunc.chancenter", "chancenter"),
"check_extension_compatibility": ("eegprep.extensions", "check_extension_compatibility"),
"checkset": ("eegprep.functions.redefine_functions", "checkset"),
"clean_artifacts": ("eegprep.plugins.clean_rawdata.clean_artifacts", "clean_artifacts"),
"clean_asr": ("eegprep.plugins.clean_rawdata.clean_asr", "clean_asr"),
"clean_channels": ("eegprep.plugins.clean_rawdata.clean_channels", "clean_channels"),
"clean_channels_nolocs": ("eegprep.plugins.clean_rawdata.clean_channels_nolocs", "clean_channels_nolocs"),
"clean_drifts": ("eegprep.plugins.clean_rawdata.clean_drifts", "clean_drifts"),
"clean_flatlines": ("eegprep.plugins.clean_rawdata.clean_flatlines", "clean_flatlines"),
"clean_windows": ("eegprep.plugins.clean_rawdata.clean_windows", "clean_windows"),
"clean_rawdata_vis_artifacts": ("eegprep.plugins.clean_rawdata.vis_artifacts", "vis_artifacts"),
"clean_rawdata_vis_artifacts_diagnostics": (
"eegprep.plugins.clean_rawdata.vis_artifacts",
"vis_artifacts_diagnostics",
),
"compare": ("eegprep.functions.redefine_functions", "compare"),
Expand All @@ -79,16 +69,12 @@
"discover_extensions": ("eegprep.extensions", "discover_extensions"),
"eeg2mne": ("eegprep.functions.redefine_functions", "eeg2mne"),
"eeg_amica": ("eegprep.functions.popfunc.eeg_amica", "eeg_amica"),
"eeg_autocorr": ("eegprep.plugins.ICLabel.eeg_autocorr", "eeg_autocorr"),
"eeg_autocorr_fftw": ("eegprep.plugins.ICLabel.eeg_autocorr_fftw", "eeg_autocorr_fftw"),
"eeg_autocorr_welch": ("eegprep.plugins.ICLabel.eeg_autocorr_welch", "eeg_autocorr_welch"),
"eeg_checkset": ("eegprep.functions.adminfunc.eeg_checkset", "eeg_checkset"),
"eeg_checkset_strict_mode": ("eegprep.functions.adminfunc.eeg_checkset", "strict_mode"),
"eeg_compare": ("eegprep.functions.popfunc.eeg_compare", "eeg_compare"),
"eeg_decodechan": ("eegprep.functions.popfunc.eeg_decodechan", "eeg_decodechan"),
"eeg_eeg2mne": ("eegprep.functions.miscfunc.eeg_eeg2mne", "eeg_eeg2mne"),
"eeg_eegrej": ("eegprep.functions.popfunc.eeg_eegrej", "eeg_eegrej"),
"eeg_icalabelstat": ("eegprep.plugins.ICLabel.eeg_icalabelstat", "eeg_icalabelstat"),
"eeg_emptyset": ("eegprep.functions.popfunc.eeg_emptyset", "eeg_emptyset"),
"eeg_multieegplot": ("eegprep.functions.popfunc.eeg_multieegplot", "eeg_multieegplot"),
"eegplot": ("eegprep.functions.sigprocfunc.eegplot", "eegplot"),
Expand All @@ -104,7 +90,6 @@
"eeg_pvaf": ("eegprep.functions.sigprocfunc.ica_helpers", "eeg_pvaf"),
"eeg_rejsuperpose": ("eegprep.functions.popfunc.eeg_rejsuperpose", "eeg_rejsuperpose"),
"eeg_retrieve": ("eegprep.functions.adminfunc.eeg_retrieve", "eeg_retrieve"),
"eeg_rpsd": ("eegprep.plugins.ICLabel.eeg_rpsd", "eeg_rpsd"),
"eeg_runica": ("eegprep.functions.popfunc.eeg_runica", "eeg_runica"),
"eeg_store": ("eegprep.functions.adminfunc.eeg_store", "eeg_store"),
"eegh": ("eegprep.functions.adminfunc.eegh", "eegh"),
Expand All @@ -131,8 +116,6 @@
"icaact": ("eegprep.functions.sigprocfunc.ica_helpers", "icaact"),
"icaproj": ("eegprep.functions.sigprocfunc.ica_helpers", "icaproj"),
"icavar": ("eegprep.functions.sigprocfunc.ica_helpers", "icavar"),
"iclabel": ("eegprep.plugins.ICLabel.iclabel", "iclabel"),
"eeg_icflag": ("eegprep.plugins.ICLabel.eeg_icflag", "eeg_icflag"),
"inputgui": ("eegprep.functions.guifunc.inputgui", "inputgui"),
"interp": ("eegprep.functions.redefine_functions", "interp"),
"jointprob": ("eegprep.functions.sigprocfunc.jointprob", "jointprob"),
Expand Down Expand Up @@ -168,8 +151,6 @@
"rspdfsolv": ("eegprep.functions.timefreqfunc.rspdfsolv", "rspdfsolv"),
"rspfunc": ("eegprep.functions.timefreqfunc.rspfunc", "rspfunc"),
"tf_cycle_calc": ("eegprep.functions.timefreqfunc.tf_cycle_calc", "tf_cycle_calc"),
"vis_artifacts": ("eegprep.plugins.clean_rawdata.vis_artifacts", "vis_artifacts"),
"vis_artifacts_diagnostics": ("eegprep.plugins.clean_rawdata.vis_artifacts", "vis_artifacts_diagnostics"),
"options": ("eegprep.functions.redefine_functions", "options"),
"picard": ("eegprep.functions.redefine_functions", "picard"),
"plugin_menu": ("eegprep.functions.adminfunc.plugin_menu", "plugin_menu"),
Expand All @@ -186,7 +167,6 @@
"pop_chanplot": ("eegprep.functions.studyfunc.pop_chanplot", "pop_chanplot"),
"pop_chancoresp": ("eegprep.functions.popfunc.pop_chancoresp", "pop_chancoresp"),
"pop_chansel": ("eegprep.functions.popfunc.pop_chansel", "pop_chansel"),
"pop_clean_rawdata": ("eegprep.plugins.clean_rawdata.pop_clean_rawdata", "pop_clean_rawdata"),
"pop_chanedit": ("eegprep.functions.popfunc.pop_chanedit", "pop_chanedit"),
"pop_comments": ("eegprep.functions.popfunc.pop_comments", "pop_comments"),
"pop_clust": ("eegprep.functions.studyfunc.pop_clust", "pop_clust"),
Expand Down Expand Up @@ -234,8 +214,6 @@
"pop_firwsord": ("eegprep.plugins.firfilt.pop_firwsord", "pop_firwsord"),
"pop_fusechanrej": ("eegprep.functions.popfunc.pop_fusechanrej", "pop_fusechanrej"),
"pop_headplot": ("eegprep.functions.popfunc.pop_headplot", "pop_headplot"),
"pop_icflag": ("eegprep.plugins.ICLabel.pop_icflag", "pop_icflag"),
"pop_iclabel": ("eegprep.plugins.ICLabel.pop_iclabel", "pop_iclabel"),
"pop_icathresh": ("eegprep.functions.popfunc.pop_icathresh", "pop_icathresh"),
"pop_jointprob": ("eegprep.functions.popfunc.pop_jointprob", "pop_jointprob"),
"pop_kaiserbeta": ("eegprep.plugins.firfilt.pop_kaiserbeta", "pop_kaiserbeta"),
Expand Down Expand Up @@ -266,7 +244,6 @@
"pop_preclust": ("eegprep.functions.studyfunc.pop_preclust", "pop_preclust"),
"pop_precomp": ("eegprep.functions.studyfunc.pop_precomp", "pop_precomp"),
"pop_prop": ("eegprep.functions.popfunc.pop_prop", "pop_prop"),
"pop_prop_extended": ("eegprep.plugins.ICLabel.pop_prop_extended", "pop_prop_extended"),
"pop_rejchan": ("eegprep.functions.popfunc.pop_rejchan", "pop_rejchan"),
"pop_rejcont": ("eegprep.functions.popfunc.pop_rejcont", "pop_rejcont"),
"pop_rejepoch": ("eegprep.functions.popfunc.pop_rejepoch", "pop_rejepoch"),
Expand Down Expand Up @@ -300,7 +277,6 @@
"pop_timef": ("eegprep.functions.popfunc.pop_timef", "pop_timef"),
"pop_topochansel": ("eegprep.functions.popfunc.pop_topochansel", "pop_topochansel"),
"pop_topoplot": ("eegprep.functions.popfunc.pop_topoplot", "pop_topoplot"),
"pop_viewprops": ("eegprep.plugins.ICLabel.pop_viewprops", "pop_viewprops"),
"pop_writeeeg": ("eegprep.functions.popfunc.pop_writeeeg", "pop_writeeeg"),
"pop_writelocs": ("eegprep.functions.popfunc.pop_writelocs", "pop_writelocs"),
"pop_xfirws": ("eegprep.plugins.firfilt.pop_xfirws", "pop_xfirws"),
Expand Down Expand Up @@ -400,8 +376,35 @@
__all__ = ["__version__", *_LAZY_EXPORTS]


_DECOUPLED_PLUGINS = {
"pop_iclabel": "eegprep-iclabel",
"iclabel": "eegprep-iclabel",
"pop_icflag": "eegprep-iclabel",
"eeg_icalabelstat": "eegprep-iclabel",
"eeg_icflag": "eegprep-iclabel",
"ICL_feature_extractor": "eegprep-iclabel",
"pop_viewprops": "eegprep-iclabel",
"pop_prop_extended": "eegprep-iclabel",
"pop_clean_rawdata": "eegprep-clean-rawdata",
"clean_artifacts": "eegprep-clean-rawdata",
"clean_asr": "eegprep-clean-rawdata",
"clean_channels": "eegprep-clean-rawdata",
"clean_channels_nolocs": "eegprep-clean-rawdata",
"clean_drifts": "eegprep-clean-rawdata",
"clean_flatlines": "eegprep-clean-rawdata",
"clean_windows": "eegprep-clean-rawdata",
"vis_artifacts": "eegprep-clean-rawdata",
}

def __getattr__(name: str) -> Any:
"""Load public EEGPrep exports on first access."""
if name in _DECOUPLED_PLUGINS:
pkg = _DECOUPLED_PLUGINS[name]
raise RuntimeError(
f"The feature {name!r} requires an uninstalled plugin package. "
f"Please install it using: pip install {pkg}"
)

try:
module_name, attr_name = _LAZY_EXPORTS[name]
except KeyError as exc:
Expand Down
1 change: 0 additions & 1 deletion src/eegprep/cli/commands/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from eegprep.functions.popfunc.pop_resample import pop_resample
from eegprep.functions.popfunc.pop_runica import pop_runica
from eegprep.functions.popfunc.pop_saveset import pop_saveset
from eegprep.plugins.clean_rawdata.pop_clean_rawdata import pop_clean_rawdata
from eegprep.plugins.firfilt.pop_eegfiltnew import pop_eegfiltnew


Expand Down
58 changes: 0 additions & 58 deletions src/eegprep/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
eeg_bids_import_items,
eeg_bids_tools_menu,
)
from eegprep.plugins.ICLabel.menu import iclabel_menu, viewprops_plot_menus
from eegprep.plugins.clean_rawdata.menu import clean_rawdata_menu
from eegprep.plugins.dipfit.menu import dipfit_menu
from eegprep.plugins.firfilt.menu import firfilt_filter_items

Expand Down Expand Up @@ -328,62 +326,6 @@ def get(self, name: str) -> ExtensionRecord | None:

def _bundled_records(self) -> list[ExtensionRecord]:
specs = (
ExtensionSpec(
name="clean_rawdata",
display_name="clean_rawdata",
version="bundled",
package_name="eegprep.plugins.clean_rawdata",
source_type=ExtensionSourceType.BUNDLED,
description="Artifact Subspace Reconstruction and related channel/window cleaning workflows.",
capabilities=("artifact", "preprocessing"),
menus=(
_extension_menu_from_spec(
clean_rawdata_menu(),
path=("tools",),
insert_after="pop_eegplot:data",
),
),
pop_functions=(
ExtensionPopFunction(
name="pop_clean_rawdata",
target=LazyImport(
"eegprep.plugins.clean_rawdata.pop_clean_rawdata",
"pop_clean_rawdata",
),
),
),
),
ExtensionSpec(
name="ICLabel",
display_name="ICLabel",
version="bundled",
package_name="eegprep.plugins.ICLabel",
source_type=ExtensionSourceType.BUNDLED,
description="Independent-component classification, flagging, and extended component properties.",
capabilities=("ica", "classification"),
menus=(
_extension_menu_from_spec(
iclabel_menu(),
path=("tools",),
insert_after="pop_selectcomps",
),
*(_extension_menu_from_spec(item, path=("plot",)) for item in viewprops_plot_menus()),
),
pop_functions=(
ExtensionPopFunction(
name="pop_iclabel",
target=LazyImport("eegprep.plugins.ICLabel.pop_iclabel", "pop_iclabel"),
),
ExtensionPopFunction(
name="pop_icflag",
target=LazyImport("eegprep.plugins.ICLabel.pop_icflag", "pop_icflag"),
),
ExtensionPopFunction(
name="pop_viewprops",
target=LazyImport("eegprep.plugins.ICLabel.pop_viewprops", "pop_viewprops"),
),
),
),
ExtensionSpec(
name="firfilt",
display_name="firfilt",
Expand Down
43 changes: 0 additions & 43 deletions src/eegprep/functions/guifunc/menu_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"pop_chanplot",
"pop_clust",
"pop_clustedit",
"pop_clean_rawdata",
"pop_chanedit",
"pop_comperp",
"pop_delset",
Expand Down Expand Up @@ -78,8 +77,6 @@
"pop_firpm",
"pop_firws",
"pop_headplot",
"pop_icflag",
"pop_iclabel",
"pop_jointprob",
"pop_leadfield",
"pop_importbids",
Expand Down Expand Up @@ -125,7 +122,6 @@
"pop_timtopo",
"pop_taskinfo",
"pop_topoplot",
"pop_viewprops",
"pop_participantinfo",
"pop_mergeset",
"pop_multifit",
Expand All @@ -150,16 +146,13 @@
EEGPREP_SOURCE_URL = f"{EEGPREP_REPO_URL}/blob/develop"

_MULTIPLE_DATASET_ACTIONS = {
"pop_clean_rawdata",
"pop_chanedit",
"pop_eegfilt",
"pop_eegfiltnew",
"pop_epoch",
"pop_firma",
"pop_firpm",
"pop_firws",
"pop_icflag",
"pop_iclabel",
"pop_reref",
"pop_rmdat",
"pop_resample",
Expand Down Expand Up @@ -198,7 +191,6 @@
}

_NEWSET_COMMIT_ACTIONS = {
"pop_clean_rawdata",
"pop_eegfilt",
"pop_eegfiltnew",
"pop_epoch",
Expand All @@ -225,7 +217,6 @@
"pop_editeventfield",
"pop_editeventvals",
"pop_chanedit",
"pop_clean_rawdata",
"pop_eegfilt",
"pop_eegfiltnew",
"pop_epoch",
Expand All @@ -240,8 +231,6 @@
"pop_runica",
"pop_select",
"pop_selectevent",
"pop_iclabel",
"pop_icflag",
"pop_subcomp",
}

Expand Down Expand Up @@ -400,7 +389,6 @@ def dispatch(self, action: str, parent: Any | None = None) -> None:
"pop_rejspec",
"pop_rejtrend",
"pop_selectcomps",
"pop_viewprops",
}:
self._run_pop_function(base, parent, variant=variant)
return
Expand Down Expand Up @@ -1065,10 +1053,6 @@ def _run_pop_function(self, name: str, parent: Any | None, *, variant: str = "")
from eegprep.functions.popfunc.pop_chanedit import pop_chanedit

out = pop_chanedit(selection, return_com=True)
elif name == "pop_clean_rawdata":
from eegprep.plugins.clean_rawdata.pop_clean_rawdata import pop_clean_rawdata

out = pop_clean_rawdata(selection, return_com=True)
elif name == "pop_eegfilt":
from eegprep.functions.popfunc.pop_eegfilt import pop_eegfilt

Expand Down Expand Up @@ -1101,14 +1085,6 @@ def _run_pop_function(self, name: str, parent: Any | None, *, variant: str = "")
from eegprep.functions.popfunc.pop_interp import pop_interp

out = pop_interp(selection, alleeg=self.session.ALLEEG, return_com=True)
elif name == "pop_iclabel":
from eegprep.plugins.ICLabel.pop_iclabel import pop_iclabel

out = pop_iclabel(selection, return_com=True)
elif name == "pop_icflag":
from eegprep.plugins.ICLabel.pop_icflag import pop_icflag

out = pop_icflag(selection, return_com=True)
elif name == "pop_resample":
from eegprep.functions.popfunc.pop_resample import pop_resample

Expand Down Expand Up @@ -1238,33 +1214,14 @@ def accept_browser_result(eeg_out: Any, command: str) -> None:
from eegprep.functions.popfunc.pop_selectcomps import pop_selectcomps

out = pop_selectcomps(selection, return_com=True)
elif name == "pop_viewprops":
from eegprep.plugins.ICLabel.pop_viewprops import pop_viewprops

target_index = list(self.session.CURRENTSET)

def commit_component_rejection(eeg_out: Any, _states: dict[int, bool]) -> None:
with self.session.gui_action("pop_viewprops"):
self._store_current_from_gui(eeg_out, command="", index=target_index)
self._refresh()

out = pop_viewprops(
selection,
typecomp=0 if variant == "components" else 1,
reject_callback=commit_component_rejection,
return_com=True,
)
else:
self.show_coming_soon(name, parent)
return
if isinstance(out, tuple):
eeg_out, command = out[0], out[1] if len(out) > 1 else ""
else:
eeg_out, command = out, ""
if name == "pop_viewprops":
self._add_history_from_gui(command)
self._refresh()
return
if command:
if name in _NEWSET_COMMIT_ACTIONS:
self._commit_processed_dataset_from_gui(eeg_out, command=command, parent=parent)
Expand Down
11 changes: 9 additions & 2 deletions src/eegprep/functions/sigprocfunc/runica.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@

import numpy as np
from scipy.linalg import sqrtm, pinv, eig
from ...plugins.clean_rawdata.private.ransac import rand_permutation
from ..miscfunc.misc import finite_pinv
from ..miscfunc.misc import finite_pinv, round_mat

logger = logging.getLogger(__name__)

def rand_permutation(n: int, stream: np.random.RandomState) -> np.ndarray:
"""Random permutation with MATLAB parity using Fisher-Yates shuffle."""
result = np.arange(n)
for k in range(n - 1, 0, -1):
j = int(round_mat(k * stream.rand()))
result[k], result[j] = result[j], result[k]
return result


def _matmul(left, right):
# MATLAB mtimes does not surface BLAS floating-point status warnings for
Expand Down
Loading
Loading