py-neuromodulation 0.0.3__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/Automated Anatomical Labeling 3 (Rolls 2020).nii +0 -0
- py_neuromodulation/ConnectivityDecoding/_get_grid_hull.m +34 -0
- py_neuromodulation/ConnectivityDecoding/_get_grid_whole_brain.py +95 -0
- py_neuromodulation/ConnectivityDecoding/_helper_write_connectome.py +107 -0
- py_neuromodulation/ConnectivityDecoding/mni_coords_cortical_surface.mat +0 -0
- py_neuromodulation/ConnectivityDecoding/mni_coords_whole_brain.mat +0 -0
- py_neuromodulation/ConnectivityDecoding/rmap_func_all.nii +0 -0
- py_neuromodulation/ConnectivityDecoding/rmap_struc.nii +0 -0
- 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 -0
- py_neuromodulation/data/dataset_description.json +8 -0
- py_neuromodulation/data/participants.json +32 -0
- py_neuromodulation/data/participants.tsv +2 -0
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_space-mni_coordsystem.json +5 -0
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_space-mni_electrodes.tsv +11 -0
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_channels.tsv +11 -0
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.eeg +0 -0
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.json +18 -0
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.vhdr +35 -0
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/ieeg/sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.vmrk +13 -0
- py_neuromodulation/data/sub-testsub/ses-EphysMedOff/sub-testsub_ses-EphysMedOff_scans.tsv +2 -0
- py_neuromodulation/grid_cortex.tsv +40 -0
- py_neuromodulation/grid_subcortex.tsv +1429 -0
- 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/plots/STN_surf.mat +0 -0
- py_neuromodulation/plots/Vertices.mat +0 -0
- py_neuromodulation/plots/faces.mat +0 -0
- py_neuromodulation/plots/grid.mat +0 -0
- {py_neuromodulation-0.0.3.dist-info → py_neuromodulation-0.0.5.dist-info}/METADATA +185 -182
- py_neuromodulation-0.0.5.dist-info/RECORD +83 -0
- {py_neuromodulation-0.0.3.dist-info → py_neuromodulation-0.0.5.dist-info}/WHEEL +1 -2
- {py_neuromodulation-0.0.3.dist-info → py_neuromodulation-0.0.5.dist-info/licenses}/LICENSE +21 -21
- docs/build/_downloads/09df217f95985497f45d69e2d4bdc5b1/plot_2_example_add_feature.py +0 -68
- docs/build/_downloads/3b4900a2b2818ff30362215b76f7d5eb/plot_1_example_BIDS.py +0 -233
- docs/build/_downloads/7e92dd2e6cc86b239d14cafad972ae4f/plot_3_example_sharpwave_analysis.py +0 -219
- docs/build/_downloads/c2db0bf2b334d541b00662b991682256/plot_6_real_time_demo.py +0 -97
- docs/build/_downloads/ce3914826f782cbd1ea8fd024eaf0ac3/plot_5_example_rmap_computing.py +0 -64
- docs/build/_downloads/da36848a41e6a3235d91fb7cfb6d59b4/plot_0_first_demo.py +0 -192
- docs/build/_downloads/eaa4305c75b19a1e2eea941f742a6331/plot_4_example_gridPointProjection.py +0 -210
- docs/build/html/_downloads/09df217f95985497f45d69e2d4bdc5b1/plot_2_example_add_feature.py +0 -68
- docs/build/html/_downloads/3b4900a2b2818ff30362215b76f7d5eb/plot_1_example_BIDS.py +0 -239
- docs/build/html/_downloads/7e92dd2e6cc86b239d14cafad972ae4f/plot_3_example_sharpwave_analysis.py +0 -219
- docs/build/html/_downloads/c2db0bf2b334d541b00662b991682256/plot_6_real_time_demo.py +0 -97
- docs/build/html/_downloads/ce3914826f782cbd1ea8fd024eaf0ac3/plot_5_example_rmap_computing.py +0 -64
- docs/build/html/_downloads/da36848a41e6a3235d91fb7cfb6d59b4/plot_0_first_demo.py +0 -192
- docs/build/html/_downloads/eaa4305c75b19a1e2eea941f742a6331/plot_4_example_gridPointProjection.py +0 -210
- docs/source/_build/html/_downloads/09df217f95985497f45d69e2d4bdc5b1/plot_2_example_add_feature.py +0 -76
- docs/source/_build/html/_downloads/0d0d0a76e8f648d5d3cbc47da6351932/plot_real_time_demo.py +0 -97
- docs/source/_build/html/_downloads/3b4900a2b2818ff30362215b76f7d5eb/plot_1_example_BIDS.py +0 -240
- docs/source/_build/html/_downloads/5d73cadc59a8805c47e3b84063afc157/plot_example_BIDS.py +0 -233
- docs/source/_build/html/_downloads/7660317fa5a6bfbd12fcca9961457fc4/plot_example_rmap_computing.py +0 -63
- docs/source/_build/html/_downloads/7e92dd2e6cc86b239d14cafad972ae4f/plot_3_example_sharpwave_analysis.py +0 -219
- docs/source/_build/html/_downloads/839e5b319379f7fd9e867deb00fd797f/plot_example_gridPointProjection.py +0 -210
- docs/source/_build/html/_downloads/ae8be19afe5e559f011fc9b138968ba0/plot_first_demo.py +0 -192
- docs/source/_build/html/_downloads/b8b06cacc17969d3725a0b6f1d7741c5/plot_example_sharpwave_analysis.py +0 -219
- docs/source/_build/html/_downloads/c2db0bf2b334d541b00662b991682256/plot_6_real_time_demo.py +0 -121
- docs/source/_build/html/_downloads/c31a86c0b68cb4167d968091ace8080d/plot_example_add_feature.py +0 -68
- docs/source/_build/html/_downloads/ce3914826f782cbd1ea8fd024eaf0ac3/plot_5_example_rmap_computing.py +0 -64
- docs/source/_build/html/_downloads/da36848a41e6a3235d91fb7cfb6d59b4/plot_0_first_demo.py +0 -189
- docs/source/_build/html/_downloads/eaa4305c75b19a1e2eea941f742a6331/plot_4_example_gridPointProjection.py +0 -210
- docs/source/auto_examples/plot_0_first_demo.py +0 -189
- docs/source/auto_examples/plot_1_example_BIDS.py +0 -240
- docs/source/auto_examples/plot_2_example_add_feature.py +0 -76
- docs/source/auto_examples/plot_3_example_sharpwave_analysis.py +0 -219
- docs/source/auto_examples/plot_4_example_gridPointProjection.py +0 -210
- docs/source/auto_examples/plot_5_example_rmap_computing.py +0 -64
- docs/source/auto_examples/plot_6_real_time_demo.py +0 -121
- docs/source/conf.py +0 -105
- examples/plot_0_first_demo.py +0 -189
- examples/plot_1_example_BIDS.py +0 -240
- examples/plot_2_example_add_feature.py +0 -76
- examples/plot_3_example_sharpwave_analysis.py +0 -219
- examples/plot_4_example_gridPointProjection.py +0 -210
- examples/plot_5_example_rmap_computing.py +0 -64
- examples/plot_6_real_time_demo.py +0 -121
- packages/realtime_decoding/build/lib/realtime_decoding/__init__.py +0 -4
- packages/realtime_decoding/build/lib/realtime_decoding/decoder.py +0 -104
- packages/realtime_decoding/build/lib/realtime_decoding/features.py +0 -163
- packages/realtime_decoding/build/lib/realtime_decoding/helpers.py +0 -15
- packages/realtime_decoding/build/lib/realtime_decoding/run_decoding.py +0 -345
- packages/realtime_decoding/build/lib/realtime_decoding/trainer.py +0 -54
- packages/tmsi/build/lib/TMSiFileFormats/__init__.py +0 -37
- packages/tmsi/build/lib/TMSiFileFormats/file_formats/__init__.py +0 -36
- packages/tmsi/build/lib/TMSiFileFormats/file_formats/lsl_stream_writer.py +0 -200
- packages/tmsi/build/lib/TMSiFileFormats/file_formats/poly5_file_writer.py +0 -496
- packages/tmsi/build/lib/TMSiFileFormats/file_formats/poly5_to_edf_converter.py +0 -236
- packages/tmsi/build/lib/TMSiFileFormats/file_formats/xdf_file_writer.py +0 -977
- packages/tmsi/build/lib/TMSiFileFormats/file_readers/__init__.py +0 -35
- packages/tmsi/build/lib/TMSiFileFormats/file_readers/edf_reader.py +0 -116
- packages/tmsi/build/lib/TMSiFileFormats/file_readers/poly5reader.py +0 -294
- packages/tmsi/build/lib/TMSiFileFormats/file_readers/xdf_reader.py +0 -229
- packages/tmsi/build/lib/TMSiFileFormats/file_writer.py +0 -102
- packages/tmsi/build/lib/TMSiPlotters/__init__.py +0 -2
- packages/tmsi/build/lib/TMSiPlotters/gui/__init__.py +0 -39
- packages/tmsi/build/lib/TMSiPlotters/gui/_plotter_gui.py +0 -234
- packages/tmsi/build/lib/TMSiPlotters/gui/plotting_gui.py +0 -440
- packages/tmsi/build/lib/TMSiPlotters/plotters/__init__.py +0 -44
- packages/tmsi/build/lib/TMSiPlotters/plotters/hd_emg_plotter.py +0 -446
- packages/tmsi/build/lib/TMSiPlotters/plotters/impedance_plotter.py +0 -589
- packages/tmsi/build/lib/TMSiPlotters/plotters/signal_plotter.py +0 -1326
- packages/tmsi/build/lib/TMSiSDK/__init__.py +0 -54
- packages/tmsi/build/lib/TMSiSDK/device.py +0 -588
- packages/tmsi/build/lib/TMSiSDK/devices/__init__.py +0 -34
- packages/tmsi/build/lib/TMSiSDK/devices/saga/TMSi_Device_API.py +0 -1764
- packages/tmsi/build/lib/TMSiSDK/devices/saga/__init__.py +0 -34
- packages/tmsi/build/lib/TMSiSDK/devices/saga/saga_device.py +0 -1366
- packages/tmsi/build/lib/TMSiSDK/devices/saga/saga_types.py +0 -520
- packages/tmsi/build/lib/TMSiSDK/devices/saga/xml_saga_config.py +0 -165
- packages/tmsi/build/lib/TMSiSDK/error.py +0 -95
- packages/tmsi/build/lib/TMSiSDK/sample_data.py +0 -63
- packages/tmsi/build/lib/TMSiSDK/sample_data_server.py +0 -99
- packages/tmsi/build/lib/TMSiSDK/settings.py +0 -45
- packages/tmsi/build/lib/TMSiSDK/tmsi_device.py +0 -111
- packages/tmsi/build/lib/__init__.py +0 -4
- packages/tmsi/build/lib/apex_sdk/__init__.py +0 -34
- packages/tmsi/build/lib/apex_sdk/device/__init__.py +0 -41
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_API.py +0 -1009
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_API_enums.py +0 -239
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_API_structures.py +0 -668
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_device.py +0 -1611
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_dongle.py +0 -38
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_event_reader.py +0 -57
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_structures/apex_channel.py +0 -44
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_structures/apex_config.py +0 -150
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_structures/apex_const.py +0 -36
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_structures/apex_impedance_channel.py +0 -48
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_structures/apex_info.py +0 -108
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/apex_structures/dongle_info.py +0 -39
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/measurements/download_measurement.py +0 -77
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/measurements/eeg_measurement.py +0 -150
- packages/tmsi/build/lib/apex_sdk/device/devices/apex/measurements/impedance_measurement.py +0 -129
- packages/tmsi/build/lib/apex_sdk/device/threads/conversion_thread.py +0 -59
- packages/tmsi/build/lib/apex_sdk/device/threads/sampling_thread.py +0 -57
- packages/tmsi/build/lib/apex_sdk/device/tmsi_channel.py +0 -83
- packages/tmsi/build/lib/apex_sdk/device/tmsi_device.py +0 -201
- packages/tmsi/build/lib/apex_sdk/device/tmsi_device_enums.py +0 -103
- packages/tmsi/build/lib/apex_sdk/device/tmsi_dongle.py +0 -43
- packages/tmsi/build/lib/apex_sdk/device/tmsi_event_reader.py +0 -50
- packages/tmsi/build/lib/apex_sdk/device/tmsi_measurement.py +0 -118
- packages/tmsi/build/lib/apex_sdk/sample_data_server/__init__.py +0 -33
- packages/tmsi/build/lib/apex_sdk/sample_data_server/event_data.py +0 -44
- packages/tmsi/build/lib/apex_sdk/sample_data_server/sample_data.py +0 -50
- packages/tmsi/build/lib/apex_sdk/sample_data_server/sample_data_server.py +0 -136
- packages/tmsi/build/lib/apex_sdk/tmsi_errors/error.py +0 -126
- packages/tmsi/build/lib/apex_sdk/tmsi_sdk.py +0 -113
- packages/tmsi/build/lib/apex_sdk/tmsi_utilities/apex/apex_structure_generator.py +0 -134
- packages/tmsi/build/lib/apex_sdk/tmsi_utilities/decorators.py +0 -60
- packages/tmsi/build/lib/apex_sdk/tmsi_utilities/logger_filter.py +0 -42
- packages/tmsi/build/lib/apex_sdk/tmsi_utilities/singleton.py +0 -42
- packages/tmsi/build/lib/apex_sdk/tmsi_utilities/support_functions.py +0 -72
- packages/tmsi/build/lib/apex_sdk/tmsi_utilities/tmsi_logger.py +0 -98
- 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_stream_offline.py +0 -358
- py_neuromodulation/utils/_logging.py +0 -24
- py_neuromodulation-0.0.3.dist-info/RECORD +0 -188
- py_neuromodulation-0.0.3.dist-info/top_level.txt +0 -5
- tests/__init__.py +0 -0
- tests/conftest.py +0 -117
- tests/test_all_examples.py +0 -10
- tests/test_all_features.py +0 -63
- tests/test_bispectra.py +0 -70
- tests/test_bursts.py +0 -105
- tests/test_feature_sampling_rates.py +0 -143
- tests/test_fooof.py +0 -16
- tests/test_initalization_offline_stream.py +0 -41
- tests/test_multiprocessing.py +0 -58
- tests/test_nan_values.py +0 -29
- tests/test_nm_filter.py +0 -95
- tests/test_nm_resample.py +0 -63
- tests/test_normalization_settings.py +0 -146
- tests/test_notch_filter.py +0 -31
- tests/test_osc_features.py +0 -424
- tests/test_preprocessing_filter.py +0 -151
- tests/test_rereference.py +0 -171
- tests/test_sampling.py +0 -57
- tests/test_settings_change_after_init.py +0 -76
- tests/test_sharpwave.py +0 -165
- tests/test_target_channel_add.py +0 -100
- tests/test_timing.py +0 -80
py_neuromodulation/__init__.py
CHANGED
|
@@ -1,13 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
from .
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import os
|
|
2
|
+
import platform
|
|
3
|
+
from pathlib import PurePath
|
|
4
|
+
from importlib.metadata import version
|
|
5
|
+
from .nm_logger import NMLogger
|
|
6
|
+
|
|
7
|
+
#####################################
|
|
8
|
+
# Globals and environment variables #
|
|
9
|
+
#####################################
|
|
10
|
+
|
|
11
|
+
__version__ = version(__package__) # get version from pyproject.toml
|
|
12
|
+
|
|
13
|
+
# Check if the module is running headless (no display) for tests and doc builds
|
|
14
|
+
PYNM_HEADLESS: bool = not os.environ.get("DISPLAY")
|
|
15
|
+
PYNM_DIR = PurePath(__file__).parent # Define constant for py_nm directory
|
|
16
|
+
|
|
17
|
+
os.environ["MPLBACKEND"] = "agg" if PYNM_HEADLESS else "qtagg" # Set matplotlib backend
|
|
18
|
+
|
|
19
|
+
# Set environment variable MNE_LSL_LIB (required to import Stream below)
|
|
20
|
+
LSL_DICT = {
|
|
21
|
+
"windows_32bit": "windows/x86/liblsl.1.16.2.dll",
|
|
22
|
+
"windows_64bit": "windows/amd64/liblsl.1.16.2.dll",
|
|
23
|
+
"darwin_i386": "macos/amd64/liblsl.1.16.2.dylib",
|
|
24
|
+
"darwin_arm": "macos/arm64/liblsl.1.16.0.dylib",
|
|
25
|
+
"linux_jammy_32bit": "linux/jammy_x86/liblsl.1.16.2.so",
|
|
26
|
+
"linux_jammy_64bit": "linux/jammy_amd64/liblsl.1.16.2.so",
|
|
27
|
+
"linux_focal_64bit": "linux/focal_amd64/liblsl.1.16.2.so",
|
|
28
|
+
"linux_bionic_64bit": "linux/bionic_amd64/liblsl.1.16.2.so",
|
|
29
|
+
"linux_bookworm_64bit": "linux/bookworm_amd64/liblsl.1.16.2.so",
|
|
30
|
+
"linux_noble_64bit": "linux/noble_amd64/liblsl.1.16.2.so",
|
|
31
|
+
"linux_32bit": "linux/jammy_x86/liblsl.1.16.2.so",
|
|
32
|
+
"linux_64bit": "linux/jammy_amd64/liblsl.1.16.2.so",
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
PLATFORM = platform.system().lower().strip()
|
|
36
|
+
ARCH = platform.architecture()[0]
|
|
37
|
+
match PLATFORM:
|
|
38
|
+
case "windows":
|
|
39
|
+
KEY = PLATFORM + "_" + ARCH
|
|
40
|
+
case "darwin":
|
|
41
|
+
KEY = PLATFORM + "_" + platform.processor()
|
|
42
|
+
case "linux":
|
|
43
|
+
DIST = platform.freedesktop_os_release()["VERSION_CODENAME"]
|
|
44
|
+
KEY = PLATFORM + "_" + DIST + "_" + ARCH
|
|
45
|
+
if KEY not in LSL_DICT:
|
|
46
|
+
KEY = PLATFORM + "_" + ARCH
|
|
47
|
+
case _:
|
|
48
|
+
KEY = ""
|
|
49
|
+
|
|
50
|
+
if KEY in LSL_DICT:
|
|
51
|
+
os.environ["MNE_LSL_LIB"] = str(PYNM_DIR / "liblsl" / LSL_DICT[KEY])
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# Create global dictionary to store user-defined features
|
|
55
|
+
user_features = {}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
######################################
|
|
59
|
+
# Logger initialization and settings #
|
|
60
|
+
######################################
|
|
61
|
+
|
|
62
|
+
logger = NMLogger(__name__) # logger initialization first to prevent circular import
|
|
63
|
+
|
|
64
|
+
####################################
|
|
65
|
+
# API: Exposed classes and methods #
|
|
66
|
+
####################################
|
|
67
|
+
from .nm_stream import Stream as Stream
|
|
68
|
+
from .nm_run_analysis import DataProcessor as DataProcessor
|
|
69
|
+
from .nm_settings import NMSettings as NMSettings
|
|
70
|
+
from .nm_features import (
|
|
71
|
+
add_custom_feature as add_custom_feature,
|
|
72
|
+
remove_custom_feature as remove_custom_feature,
|
|
73
|
+
NMFeature as NMFeature,
|
|
74
|
+
)
|
|
@@ -1,65 +1,83 @@
|
|
|
1
|
-
import mne
|
|
2
|
-
import mne_bids
|
|
3
|
-
import pybv # pip install pybv
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def set_chtypes(vhdr_raw):
|
|
8
|
-
"""
|
|
9
|
-
define MNE RawArray channel types
|
|
10
|
-
"""
|
|
11
|
-
print(
|
|
12
|
-
remapping_dict = {}
|
|
13
|
-
for ch_name in vhdr_raw.info[
|
|
14
|
-
if ch_name.startswith(
|
|
15
|
-
remapping_dict[ch_name] =
|
|
16
|
-
elif ch_name.startswith((
|
|
17
|
-
remapping_dict[ch_name] =
|
|
18
|
-
elif ch_name.startswith(
|
|
19
|
-
remapping_dict[ch_name] =
|
|
20
|
-
elif ch_name.startswith(
|
|
21
|
-
remapping_dict[ch_name] =
|
|
22
|
-
elif ch_name.startswith((
|
|
23
|
-
remapping_dict[ch_name] =
|
|
24
|
-
else:
|
|
25
|
-
remapping_dict[ch_name] =
|
|
26
|
-
vhdr_raw.set_channel_types(remapping_dict, verbose=False)
|
|
27
|
-
return vhdr_raw
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def write_bids_example():
|
|
31
|
-
# define run file to read and write from
|
|
32
|
-
PATH_RUN = r"C:\code\py_neuromodulation\examples\data\sub-000\ses-right\ieeg\sub-000_ses-right_task-force_run-3_ieeg.vhdr"
|
|
33
|
-
PATH_BIDS = r"C:\code\py_neuromodulation\examples\data"
|
|
34
|
-
PATH_OUT = r"C:\Users\ICN_admin\Downloads\BIDS_EXAMPLE"
|
|
35
|
-
PATH_OUT_TEMP = r"C:\Users\ICN_admin\Downloads\BIDS_EXAMPLE_TEMP"
|
|
36
|
-
|
|
37
|
-
entities = mne_bids.get_entities_from_fname(PATH_RUN)
|
|
38
|
-
|
|
39
|
-
bids_path = mne_bids.BIDSPath(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
1
|
+
import mne
|
|
2
|
+
import mne_bids
|
|
3
|
+
import pybv # pip install pybv
|
|
4
|
+
from pathlib import PurePath
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def set_chtypes(vhdr_raw):
|
|
8
|
+
"""
|
|
9
|
+
define MNE RawArray channel types
|
|
10
|
+
"""
|
|
11
|
+
print("Setting new channel types...")
|
|
12
|
+
remapping_dict = {}
|
|
13
|
+
for ch_name in vhdr_raw.info["ch_names"]:
|
|
14
|
+
if ch_name.startswith("ECOG"):
|
|
15
|
+
remapping_dict[ch_name] = "ecog"
|
|
16
|
+
elif ch_name.startswith(("LFP", "STN")):
|
|
17
|
+
remapping_dict[ch_name] = "dbs"
|
|
18
|
+
elif ch_name.startswith("EMG"):
|
|
19
|
+
remapping_dict[ch_name] = "emg"
|
|
20
|
+
elif ch_name.startswith("EEG"):
|
|
21
|
+
remapping_dict[ch_name] = "misc"
|
|
22
|
+
elif ch_name.startswith(("MOV", "ANALOG", "ROT", "ACC", "AUX", "X", "Y", "Z")):
|
|
23
|
+
remapping_dict[ch_name] = "misc"
|
|
24
|
+
else:
|
|
25
|
+
remapping_dict[ch_name] = "misc"
|
|
26
|
+
vhdr_raw.set_channel_types(remapping_dict, verbose=False)
|
|
27
|
+
return vhdr_raw
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def write_bids_example():
|
|
31
|
+
# define run file to read and write from
|
|
32
|
+
PATH_RUN = r"C:\code\py_neuromodulation\examples\data\sub-000\ses-right\ieeg\sub-000_ses-right_task-force_run-3_ieeg.vhdr"
|
|
33
|
+
PATH_BIDS = r"C:\code\py_neuromodulation\examples\data"
|
|
34
|
+
PATH_OUT = r"C:\Users\ICN_admin\Downloads\BIDS_EXAMPLE"
|
|
35
|
+
PATH_OUT_TEMP = r"C:\Users\ICN_admin\Downloads\BIDS_EXAMPLE_TEMP"
|
|
36
|
+
|
|
37
|
+
entities = mne_bids.get_entities_from_fname(PATH_RUN)
|
|
38
|
+
|
|
39
|
+
bids_path = mne_bids.BIDSPath(
|
|
40
|
+
subject=entities["subject"],
|
|
41
|
+
session=entities["session"],
|
|
42
|
+
task=entities["task"],
|
|
43
|
+
run=entities["run"],
|
|
44
|
+
acquisition=entities["acquisition"],
|
|
45
|
+
datatype="ieeg",
|
|
46
|
+
root=PATH_BIDS,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
raw_arr = mne_bids.read_raw_bids(bids_path)
|
|
50
|
+
|
|
51
|
+
# crop data
|
|
52
|
+
raw_arr.crop(0, 19) # pick three movements
|
|
53
|
+
|
|
54
|
+
data = raw_arr.get_data()[:10, :]
|
|
55
|
+
ch_names = raw_arr.ch_names[:10]
|
|
56
|
+
|
|
57
|
+
pybv.write_brainvision(
|
|
58
|
+
data=data,
|
|
59
|
+
sfreq=raw_arr.info["sfreq"],
|
|
60
|
+
ch_names=ch_names,
|
|
61
|
+
fname_base="example",
|
|
62
|
+
folder_out=PATH_OUT_TEMP,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
data_to_write = mne.io.read_raw_brainvision(PurePath(PATH_OUT_TEMP, "example.vhdr"))
|
|
66
|
+
|
|
67
|
+
# example.eeg / .vhdr need to be deleted afterwards
|
|
68
|
+
|
|
69
|
+
data_to_write = set_chtypes(data_to_write)
|
|
70
|
+
data_to_write.info["line_freq"] = 60
|
|
71
|
+
|
|
72
|
+
mne_bids.write_raw_bids(
|
|
73
|
+
data_to_write,
|
|
74
|
+
mne_bids.BIDSPath(
|
|
75
|
+
subject="testsub",
|
|
76
|
+
session="EphysMedOff",
|
|
77
|
+
task="gripforce",
|
|
78
|
+
datatype="ieeg",
|
|
79
|
+
run="0",
|
|
80
|
+
root=PATH_OUT,
|
|
81
|
+
),
|
|
82
|
+
overwrite=True,
|
|
83
|
+
)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
References
|
|
2
|
+
----------
|
|
3
|
+
Appelhoff, S., Sanderson, M., Brooks, T., Vliet, M., Quentin, R., Holdgraf, C., Chaumon, M., Mikulan, E., Tavabi, K., Höchenberger, R., Welke, D., Brunner, C., Rockhill, A., Larson, E., Gramfort, A. and Jas, M. (2019). MNE-BIDS: Organizing electrophysiological data into the BIDS format and facilitating their analysis. Journal of Open Source Software 4: (1896). https://doi.org/10.21105/joss.01896
|
|
4
|
+
|
|
5
|
+
Holdgraf, C., Appelhoff, S., Bickel, S., Bouchard, K., D'Ambrosio, S., David, O., … Hermes, D. (2019). iEEG-BIDS, extending the Brain Imaging Data Structure specification to human intracranial electrophysiology. Scientific Data, 6, 102. https://doi.org/10.1038/s41597-019-0105-7
|
|
6
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"participant_id": {
|
|
3
|
+
"Description": "Unique participant identifier"
|
|
4
|
+
},
|
|
5
|
+
"age": {
|
|
6
|
+
"Description": "Age of the participant at time of testing",
|
|
7
|
+
"Units": "years"
|
|
8
|
+
},
|
|
9
|
+
"sex": {
|
|
10
|
+
"Description": "Biological sex of the participant",
|
|
11
|
+
"Levels": {
|
|
12
|
+
"F": "female",
|
|
13
|
+
"M": "male"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"hand": {
|
|
17
|
+
"Description": "Handedness of the participant",
|
|
18
|
+
"Levels": {
|
|
19
|
+
"R": "right",
|
|
20
|
+
"L": "left",
|
|
21
|
+
"A": "ambidextrous"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"weight": {
|
|
25
|
+
"Description": "Body weight of the participant",
|
|
26
|
+
"Units": "kg"
|
|
27
|
+
},
|
|
28
|
+
"height": {
|
|
29
|
+
"Description": "Body height of the participant",
|
|
30
|
+
"Units": "m"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
name x y z size impedance
|
|
2
|
+
LFP_RIGHT_0 0.0118280802308701 -0.0151597482742092 -0.00776909845640809 n/a n/a
|
|
3
|
+
LFP_RIGHT_1 0.0123908351968705 -0.0142925082817827 -0.0059367986990887 n/a n/a
|
|
4
|
+
LFP_RIGHT_2 0.012930849148285701 -0.0134128499400548 -0.00409165661961333 n/a n/a
|
|
5
|
+
ECOG_RIGHT_0 0.037318173999999996 -0.048610126639999994 0.06179765474 n/a n/a
|
|
6
|
+
ECOG_RIGHT_1 0.0401598943 -0.037315929830000004 0.06431171618 n/a n/a
|
|
7
|
+
ECOG_RIGHT_2 0.040943035780000005 -0.02721778456 0.06409518407999999 n/a n/a
|
|
8
|
+
ECOG_RIGHT_3 0.03978395522 -0.01700523081 0.06386618136 n/a n/a
|
|
9
|
+
ECOG_RIGHT_4 0.03968813641 -0.005528024572 0.06168254254 n/a n/a
|
|
10
|
+
ECOG_RIGHT_5 0.03751915924 0.004304913414 0.060541263549999995 n/a n/a
|
|
11
|
+
MOV_RIGHT n/a n/a n/a n/a n/a
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
name type units low_cutoff high_cutoff description sampling_frequency status status_description
|
|
2
|
+
LFP_RIGHT_0 DBS µV 0.0 500.0 Deep Brain Stimulation 1000.0 good n/a
|
|
3
|
+
LFP_RIGHT_1 DBS µV 0.0 500.0 Deep Brain Stimulation 1000.0 good n/a
|
|
4
|
+
LFP_RIGHT_2 DBS µV 0.0 500.0 Deep Brain Stimulation 1000.0 good n/a
|
|
5
|
+
ECOG_RIGHT_0 ECOG µV 0.0 500.0 Electrocorticography 1000.0 good n/a
|
|
6
|
+
ECOG_RIGHT_1 ECOG µV 0.0 500.0 Electrocorticography 1000.0 good n/a
|
|
7
|
+
ECOG_RIGHT_2 ECOG µV 0.0 500.0 Electrocorticography 1000.0 good n/a
|
|
8
|
+
ECOG_RIGHT_3 ECOG µV 0.0 500.0 Electrocorticography 1000.0 good n/a
|
|
9
|
+
ECOG_RIGHT_4 ECOG µV 0.0 500.0 Electrocorticography 1000.0 good n/a
|
|
10
|
+
ECOG_RIGHT_5 ECOG µV 0.0 500.0 Electrocorticography 1000.0 good n/a
|
|
11
|
+
MOV_RIGHT MISC µV 0.0 500.0 Miscellaneous 1000.0 good n/a
|
|
Binary file
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"TaskName": "gripforce",
|
|
3
|
+
"Manufacturer": "Brain Products",
|
|
4
|
+
"PowerLineFrequency": 60.0,
|
|
5
|
+
"SamplingFrequency": 1000.0,
|
|
6
|
+
"SoftwareFilters": "n/a",
|
|
7
|
+
"RecordingDuration": 19.0,
|
|
8
|
+
"RecordingType": "continuous",
|
|
9
|
+
"iEEGReference": "n/a",
|
|
10
|
+
"ECOGChannelCount": 6,
|
|
11
|
+
"SEEGChannelCount": 3,
|
|
12
|
+
"EEGChannelCount": 0,
|
|
13
|
+
"EOGChannelCount": 0,
|
|
14
|
+
"ECGChannelCount": 0,
|
|
15
|
+
"EMGChannelCount": 0,
|
|
16
|
+
"MiscChannelCount": 1,
|
|
17
|
+
"TriggerChannelCount": 0
|
|
18
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Brain Vision Data Exchange Header File Version 1.0
|
|
2
|
+
; Written using pybv 0.7.5
|
|
3
|
+
|
|
4
|
+
[Common Infos]
|
|
5
|
+
Codepage=UTF-8
|
|
6
|
+
DataFile=sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.eeg
|
|
7
|
+
MarkerFile=sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.vmrk
|
|
8
|
+
DataFormat=BINARY
|
|
9
|
+
; Data orientation: MULTIPLEXED=ch1,pt1, ch2,pt1 ...
|
|
10
|
+
DataOrientation=MULTIPLEXED
|
|
11
|
+
NumberOfChannels=10
|
|
12
|
+
; Sampling interval in microseconds
|
|
13
|
+
SamplingInterval=1000.0
|
|
14
|
+
|
|
15
|
+
[Binary Infos]
|
|
16
|
+
BinaryFormat=IEEE_FLOAT_32
|
|
17
|
+
|
|
18
|
+
[Channel Infos]
|
|
19
|
+
; Each entry: Ch<Channel number>=<Name>,<Reference channel name>,
|
|
20
|
+
; <Resolution in "Unit">,<Unit>, Future extensions..
|
|
21
|
+
; Fields are delimited by commas, some fields might be omitted (empty).
|
|
22
|
+
; Commas in channel names are coded as "\1".
|
|
23
|
+
Ch1=LFP_RIGHT_0,,0.1,µV
|
|
24
|
+
Ch2=LFP_RIGHT_1,,0.1,µV
|
|
25
|
+
Ch3=LFP_RIGHT_2,,0.1,µV
|
|
26
|
+
Ch4=ECOG_RIGHT_0,,0.1,µV
|
|
27
|
+
Ch5=ECOG_RIGHT_1,,0.1,µV
|
|
28
|
+
Ch6=ECOG_RIGHT_2,,0.1,µV
|
|
29
|
+
Ch7=ECOG_RIGHT_3,,0.1,µV
|
|
30
|
+
Ch8=ECOG_RIGHT_4,,0.1,µV
|
|
31
|
+
Ch9=ECOG_RIGHT_5,,0.1,µV
|
|
32
|
+
Ch10=MOV_RIGHT,,0.1,µV
|
|
33
|
+
|
|
34
|
+
[Comment]
|
|
35
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Brain Vision Data Exchange Marker File, Version 1.0
|
|
2
|
+
; Exported using pybv 0.7.5
|
|
3
|
+
|
|
4
|
+
[Common Infos]
|
|
5
|
+
Codepage=UTF-8
|
|
6
|
+
DataFile=sub-testsub_ses-EphysMedOff_task-gripforce_run-0_ieeg.eeg
|
|
7
|
+
|
|
8
|
+
[Marker Infos]
|
|
9
|
+
; Each entry: Mk<Marker number>=<Type>,<Description>,<Position in data points>,
|
|
10
|
+
; <Size in data points>, <Channel number (0 = marker is related to all channels)>
|
|
11
|
+
; <Date (YYYYMMDDhhmmssuuuuuu)>
|
|
12
|
+
; Fields are delimited by commas, some fields might be omitted (empty).
|
|
13
|
+
; Commas in type or description text are coded as "\1".
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
x y z
|
|
2
|
+
-13.1 -67.7 69.1
|
|
3
|
+
-35.5 -60.0 66.0
|
|
4
|
+
-48.3 -55.1 58.2
|
|
5
|
+
-60.0 -51.8 48.0
|
|
6
|
+
-16.9 -51.6 78.0
|
|
7
|
+
-34.8 -49.3 71.7
|
|
8
|
+
-67.5 -47.1 31.0
|
|
9
|
+
-46.1 -43.7 61.1
|
|
10
|
+
-59.8 -39.6 53.3
|
|
11
|
+
-14.2 -39.1 81.1
|
|
12
|
+
-28.3 -31.2 76.0
|
|
13
|
+
-42.3 -30.7 70.2
|
|
14
|
+
-67.6 -30.1 41.2
|
|
15
|
+
-50.5 -24.4 64.4
|
|
16
|
+
-14.6 -22.7 80.2
|
|
17
|
+
-60.9 -18.7 50.9
|
|
18
|
+
-31.6 -16.9 75.2
|
|
19
|
+
-5.1 -12.6 77.3
|
|
20
|
+
-65.6 -10.8 37.8
|
|
21
|
+
-41.8 -10.2 67.0
|
|
22
|
+
-55.1 -4.01 53.2
|
|
23
|
+
-22.7 1.2 72.0
|
|
24
|
+
-5.8 2.8 74.8
|
|
25
|
+
-49.2 3.7 54.7
|
|
26
|
+
-34.5 3.9 66.5
|
|
27
|
+
-61.55 6.2 35.9
|
|
28
|
+
-63.6 8.3 25.7
|
|
29
|
+
-40.4 11.8 60.7
|
|
30
|
+
-48.7 14.5 50.5
|
|
31
|
+
-21.8 16.0 68.9
|
|
32
|
+
-58.2 18.2 27.3
|
|
33
|
+
-7.0 18.4 70.3
|
|
34
|
+
-36.3 19.9 59.6
|
|
35
|
+
-48.1 24.6 44.0
|
|
36
|
+
-56.8 28.52 20.8
|
|
37
|
+
-7.3 33.8 61.7
|
|
38
|
+
-22.2 35.0 57.2
|
|
39
|
+
-36.8 35.4 47.0
|
|
40
|
+
-46.8 35.6 36.0
|