py-neuromodulation 0.0.4__py3-none-any.whl → 0.0.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- py_neuromodulation/ConnectivityDecoding/_get_grid_hull.m +34 -34
- py_neuromodulation/ConnectivityDecoding/_get_grid_whole_brain.py +95 -106
- py_neuromodulation/ConnectivityDecoding/_helper_write_connectome.py +107 -119
- py_neuromodulation/FieldTrip.py +589 -589
- py_neuromodulation/__init__.py +74 -13
- py_neuromodulation/_write_example_dataset_helper.py +83 -65
- py_neuromodulation/data/README +6 -6
- py_neuromodulation/data/dataset_description.json +8 -8
- py_neuromodulation/data/participants.json +32 -32
- py_neuromodulation/data/participants.tsv +2 -2
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_space-mni_coordsystem.json +5 -5
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_space-mni_electrodes.tsv +11 -11
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_channels.tsv +11 -11
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.json +18 -18
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.vhdr +35 -35
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.vmrk +13 -13
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/sub-testsub_ses-EphysMedOff_scans.tsv +2 -2
- py_neuromodulation/grid_cortex.tsv +40 -40
- py_neuromodulation/liblsl/libpugixml.so.1.12 +0 -0
- py_neuromodulation/liblsl/linux/bionic_amd64/liblsl.1.16.2.so +0 -0
- py_neuromodulation/liblsl/linux/bookworm_amd64/liblsl.1.16.2.so +0 -0
- py_neuromodulation/liblsl/linux/focal_amd46/liblsl.1.16.2.so +0 -0
- py_neuromodulation/liblsl/linux/jammy_amd64/liblsl.1.16.2.so +0 -0
- py_neuromodulation/liblsl/linux/jammy_x86/liblsl.1.16.2.so +0 -0
- py_neuromodulation/liblsl/linux/noble_amd64/liblsl.1.16.2.so +0 -0
- py_neuromodulation/liblsl/macos/amd64/liblsl.1.16.2.dylib +0 -0
- py_neuromodulation/liblsl/macos/arm64/liblsl.1.16.0.dylib +0 -0
- py_neuromodulation/liblsl/windows/amd64/liblsl.1.16.2.dll +0 -0
- py_neuromodulation/liblsl/windows/x86/liblsl.1.16.2.dll +0 -0
- py_neuromodulation/nm_IO.py +413 -417
- py_neuromodulation/nm_RMAP.py +496 -531
- py_neuromodulation/nm_analysis.py +993 -1074
- py_neuromodulation/nm_artifacts.py +30 -25
- py_neuromodulation/nm_bispectra.py +154 -168
- py_neuromodulation/nm_bursts.py +292 -198
- py_neuromodulation/nm_coherence.py +251 -205
- py_neuromodulation/nm_database.py +149 -0
- py_neuromodulation/nm_decode.py +918 -992
- py_neuromodulation/nm_define_nmchannels.py +300 -302
- py_neuromodulation/nm_features.py +144 -116
- py_neuromodulation/nm_filter.py +219 -219
- py_neuromodulation/nm_filter_preprocessing.py +79 -91
- py_neuromodulation/nm_fooof.py +139 -159
- py_neuromodulation/nm_generator.py +45 -37
- py_neuromodulation/nm_hjorth_raw.py +52 -73
- py_neuromodulation/nm_kalmanfilter.py +71 -58
- py_neuromodulation/nm_linelength.py +21 -33
- py_neuromodulation/nm_logger.py +66 -0
- py_neuromodulation/nm_mne_connectivity.py +149 -112
- py_neuromodulation/nm_mnelsl_generator.py +90 -0
- py_neuromodulation/nm_mnelsl_stream.py +116 -0
- py_neuromodulation/nm_nolds.py +96 -93
- py_neuromodulation/nm_normalization.py +173 -214
- py_neuromodulation/nm_oscillatory.py +423 -448
- py_neuromodulation/nm_plots.py +585 -612
- py_neuromodulation/nm_preprocessing.py +83 -0
- py_neuromodulation/nm_projection.py +370 -394
- py_neuromodulation/nm_rereference.py +97 -95
- py_neuromodulation/nm_resample.py +59 -50
- py_neuromodulation/nm_run_analysis.py +325 -435
- py_neuromodulation/nm_settings.py +289 -68
- py_neuromodulation/nm_settings.yaml +244 -0
- py_neuromodulation/nm_sharpwaves.py +423 -401
- py_neuromodulation/nm_stats.py +464 -480
- py_neuromodulation/nm_stream.py +398 -0
- py_neuromodulation/nm_stream_abc.py +166 -218
- py_neuromodulation/nm_types.py +193 -0
- {py_neuromodulation-0.0.4.dist-info → py_neuromodulation-0.0.5.dist-info}/METADATA +29 -26
- py_neuromodulation-0.0.5.dist-info/RECORD +83 -0
- {py_neuromodulation-0.0.4.dist-info → py_neuromodulation-0.0.5.dist-info}/WHEEL +1 -1
- {py_neuromodulation-0.0.4.dist-info → py_neuromodulation-0.0.5.dist-info}/licenses/LICENSE +21 -21
- py_neuromodulation/nm_EpochStream.py +0 -92
- py_neuromodulation/nm_across_patient_decoding.py +0 -927
- py_neuromodulation/nm_cohortwrapper.py +0 -435
- py_neuromodulation/nm_eval_timing.py +0 -239
- py_neuromodulation/nm_features_abc.py +0 -39
- py_neuromodulation/nm_settings.json +0 -338
- py_neuromodulation/nm_stream_offline.py +0 -359
- py_neuromodulation/utils/_logging.py +0 -24
- py_neuromodulation-0.0.4.dist-info/RECORD +0 -72
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from typing import Protocol, TYPE_CHECKING
|
|
2
|
+
from inspect import getfullargspec
|
|
3
|
+
from typing import Type
|
|
4
|
+
from py_neuromodulation.nm_types import ImportDetails, get_class, PreprocessorName
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
import numpy as np
|
|
8
|
+
import pandas as pd
|
|
9
|
+
from py_neuromodulation.nm_settings import NMSettings
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class NMPreprocessor(Protocol):
|
|
13
|
+
def __init__(self, sfreq: float, settings: "NMSettings") -> None: ...
|
|
14
|
+
|
|
15
|
+
def process(self, data: "np.ndarray") -> "np.ndarray": ...
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
PREPROCESSOR_DICT: dict[PreprocessorName, ImportDetails] = {
|
|
19
|
+
"preprocessing_filter": ImportDetails(
|
|
20
|
+
"nm_filter_preprocessing", "PreprocessingFilter"
|
|
21
|
+
),
|
|
22
|
+
"notch_filter": ImportDetails("nm_filter", "NotchFilter"),
|
|
23
|
+
"raw_resampling": ImportDetails("nm_resample", "Resampler"),
|
|
24
|
+
"re_referencing": ImportDetails("nm_rereference", "ReReferencer"),
|
|
25
|
+
"raw_normalization": ImportDetails("nm_normalization", "RawNormalizer"),
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class NMPreprocessors:
|
|
30
|
+
"Class for initializing and holding data preprocessing classes"
|
|
31
|
+
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
settings: "NMSettings",
|
|
35
|
+
nm_channels: "pd.DataFrame",
|
|
36
|
+
sfreq: float,
|
|
37
|
+
line_noise: float | None = None,
|
|
38
|
+
) -> None:
|
|
39
|
+
possible_arguments = {
|
|
40
|
+
"sfreq": sfreq,
|
|
41
|
+
"settings": settings,
|
|
42
|
+
"nm_channels": nm_channels,
|
|
43
|
+
"line_noise": line_noise,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
for preprocessing_method in settings.preprocessing:
|
|
47
|
+
if preprocessing_method not in PREPROCESSOR_DICT.keys():
|
|
48
|
+
raise ValueError(
|
|
49
|
+
f"Invalid preprocessing method '{preprocessing_method}'. Must be one of {PREPROCESSOR_DICT.keys()}"
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
# Get needed preprocessor classes from settings
|
|
53
|
+
preprocessor_classes: dict[str, Type[NMPreprocessor]] = {
|
|
54
|
+
preprocessor_name: get_class(import_details)
|
|
55
|
+
for preprocessor_name, import_details in PREPROCESSOR_DICT.items()
|
|
56
|
+
if preprocessor_name in settings.preprocessing
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Function to instantiate preprocessor with settings
|
|
60
|
+
def instantiate_preprocessor(
|
|
61
|
+
preprocessor_class: Type[NMPreprocessor], preprocessor_name: str
|
|
62
|
+
) -> NMPreprocessor:
|
|
63
|
+
settings_str = f"{preprocessor_name}_settings"
|
|
64
|
+
# Filter out arguments that are not in the preprocessor's __init__ method
|
|
65
|
+
args = {
|
|
66
|
+
arg: possible_arguments[arg]
|
|
67
|
+
for arg in getfullargspec(preprocessor_class).args
|
|
68
|
+
if arg in possible_arguments
|
|
69
|
+
}
|
|
70
|
+
# Retrieve more possible arguments from settings
|
|
71
|
+
args |= getattr(settings, settings_str, {})
|
|
72
|
+
# Pass arguments to preprocessor class and return instance
|
|
73
|
+
return preprocessor_class(**args)
|
|
74
|
+
|
|
75
|
+
self.preprocessors: list[NMPreprocessor] = [
|
|
76
|
+
instantiate_preprocessor(preprocessor_class, preprocessor_name)
|
|
77
|
+
for preprocessor_name, preprocessor_class in preprocessor_classes.items()
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
def process_data(self, data: "np.ndarray") -> "np.ndarray":
|
|
81
|
+
for preprocessor in self.preprocessors:
|
|
82
|
+
data = preprocessor.process(data)
|
|
83
|
+
return data
|