repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
MCSE
MCSE-master/SentEval/senteval/tools/__init__.py
0
0
0
py
MCSE
MCSE-master/SentEval/senteval/tools/ranking.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # """ Image Annotation/Search for COCO with Pytorch """ from __future__ import absolute_import, division, unicode_literals impor...
15,275
41.433333
109
py
openqasm
openqasm-main/convert2pdf.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import sys import subprocess CONVERT_COMMAND = 'texi2pdf' def main(relative_tex_filepath): if not os.path.exists(relative_tex_filepath): print( 'File %s does not exist.' % relative_tex_filepath, file=sys.stderr) return -1 ...
1,138
24.886364
79
py
openqasm
openqasm-main/convert2svg.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import sys import subprocess CONVERT_COMMAND = 'pdftocairo' def main(relative_tex_filepath): if not os.path.exists(relative_tex_filepath): print( 'File %s does not exist.' % relative_tex_filepath, file=sys.stderr) return -1 ...
1,200
25.688889
79
py
openqasm
openqasm-main/source/conf.py
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
4,580
35.943548
100
py
openqasm
openqasm-main/source/grammar/openqasm_reference_parser/exceptions.py
__all__ = ["Qasm3ParserError"] class Qasm3ParserError(Exception): pass
77
12
34
py
openqasm
openqasm-main/source/grammar/openqasm_reference_parser/tools.py
import contextlib import io import antlr4 from antlr4.tree.Trees import Trees, ParseTree from . import Qasm3ParserError from .qasm3Lexer import qasm3Lexer from .qasm3Parser import qasm3Parser __all__ = ["pretty_tree"] def pretty_tree(*, program: str = None, file: str = None) -> str: """Get a pretty-printed str...
2,569
35.197183
83
py
openqasm
openqasm-main/source/grammar/openqasm_reference_parser/__init__.py
from .exceptions import * from .tools import * from .qasm3Lexer import qasm3Lexer from .qasm3Parser import qasm3Parser
119
23
36
py
openqasm
openqasm-main/source/grammar/tests/test_grammar.py
import itertools import os import pathlib from typing import List, Union, Sequence import pytest import yaml import openqasm_reference_parser TEST_DIR = pathlib.Path(__file__).parent REPO_DIR = TEST_DIR.parents[2] def find_files( directory: Union[str, os.PathLike], suffix: str = "", raw: bool = False ) -> List...
4,529
32.80597
80
py
openqasm
openqasm-main/source/openqasm/tools/update_antlr_version_requirements.py
import sys import re def parse_versions(): with open(sys.argv[2], "r") as version_file: for line in version_file: comment_start = line.find("#") if comment_start >= 0: line = line[: line.find("#")] line = line.strip() if not line: ...
1,687
32.76
99
py
openqasm
openqasm-main/source/openqasm/tests/conftest.py
import collections import pathlib import pytest import openqasm3 TEST_DIR = pathlib.Path(__file__).parent ROOT_DIR = TEST_DIR.parents[2] EXAMPLES_DIR = ROOT_DIR / "examples" EXAMPLES = tuple(EXAMPLES_DIR.glob("**/*.qasm")) # Session scoped because we want the parsed examples to be session scoped as well. @pytest.f...
1,012
30.65625
98
py
openqasm
openqasm-main/source/openqasm/tests/test_qasm_parser.py
import dataclasses import pytest from openqasm3.ast import ( AccessControl, AliasStatement, AngleType, Annotation, ArrayLiteral, ArrayReferenceType, ArrayType, AssignmentOperator, BinaryExpression, BinaryOperator, BitType, BitstringLiteral, BoolType, BooleanLiter...
60,537
31.901087
100
py
openqasm
openqasm-main/source/openqasm/tests/test_printer.py
import dataclasses import pytest import openqasm3 from openqasm3 import ast def _remove_spans(node): """Return a new ``QASMNode`` with all spans recursively set to ``None`` to reduce noise in test failure messages.""" if isinstance(node, list): return [_remove_spans(item) for item in node] i...
23,718
24.232979
99
py
openqasm
openqasm-main/source/openqasm/tests/test_openqasm_tests.py
import openqasm3 def test_examples(example_file): """Loop through all example files, verify that the ast_parser can parse the file. The `example_file` fixture is generated in `conftest.py`. These tests are automatically skipped if the examples directly cannot be found. """ with open(example_file...
386
28.769231
100
py
openqasm
openqasm-main/source/openqasm/tests/__init__.py
0
0
0
py
openqasm
openqasm-main/source/openqasm/docs/conf.py
# In general, we expect that `openqasm3` is installed and available on the path # without modification. import openqasm3 project = 'OpenQASM 3 Reference AST' copyright = '2021, OpenQASM 3 Team and Contributors' author = 'OpenQASM 3 Team and Contributors' release = openqasm3.__version__ extensions = [ # Allow aut...
534
25.75
79
py
openqasm
openqasm-main/source/openqasm/openqasm3/visitor.py
""" ===================================================== AST Visitors and Transformers (``openqasm3.visitor``) ===================================================== Implementation of an example AST visitor :obj:`~QASMVisitor`, which can be inherited from to make generic visitors of the reference AST. Deriving from t...
3,365
36.4
95
py
openqasm
openqasm-main/source/openqasm/openqasm3/parser.py
""" ============================= Parser (``openqasm3.parser``) ============================= Tools for parsing OpenQASM 3 programs into the :obj:`reference AST <openqasm3.ast>`. The quick-start interface is simply to call ``openqasm3.parse``: .. currentmodule:: openqasm3 .. autofunction:: openqasm3.parse The rest ...
34,306
38.34289
109
py
openqasm
openqasm-main/source/openqasm/openqasm3/printer.py
""" ============================================================== Generating OpenQASM 3 from an AST Node (``openqasm3.printer``) ============================================================== .. currentmodule:: openqasm3 It is often useful to go from the :mod:`AST representation <openqasm3.ast>` of an OpenQASM 3 pro...
33,232
37.688009
100
py
openqasm
openqasm-main/source/openqasm/openqasm3/properties.py
from . import ast __all__ = ["precedence"] _PRECEDENCE_TABLE = { ast.Concatenation: 0, # ... the rest of the binary operations come very early ... ast.UnaryExpression: 11, # ... power expression ... # "Call"-like expressions bind very tightly. ast.IndexExpression: 13, ast.FunctionCall: 13,...
2,522
32.64
89
py
openqasm
openqasm-main/source/openqasm/openqasm3/__init__.py
""" =================================== OpenQASM 3 Python reference package =================================== This package contains the reference abstract syntax tree (AST) for representing OpenQASM 3 programs, tools to parse text into this AST, and tools to manipulate the AST. The AST itself is in the :obj:`.ast` ...
922
27.84375
89
py
openqasm
openqasm-main/source/openqasm/openqasm3/ast.py
""" ======================================== Abstract Syntax Tree (``openqasm3.ast``) ======================================== .. currentmodule:: openqasm3.ast The reference abstract syntax tree (AST) for OpenQASM 3 programs. """ from __future__ import annotations from dataclasses import dataclass, field from typin...
19,394
16.777269
95
py
openqasm
openqasm-main/source/openqasm/openqasm3/_antlr/__init__.py
"""ANTLR-generated files for parsing OpenQASM 3 files. This package sets up its import contents to be taken from the generated files whose ANTLR version matches the installed version of the ANTLR runtime. The generated files should be placed in directories called ``_<major>_<minor>``, where `major` is 4, and `minor` ...
3,203
45.434783
100
py
openqasm
openqasm-main/source/_extensions/multifigure.py
# -*- coding: utf-8 -*- import itertools from docutils.parsers.rst import Directive, directives from docutils import nodes DEFAULT_ROW_ITEM_COUNT = 4 MULTIFIGURE_HTML_CONTENT_TAG = 'div' MULTIFIGURE_HTML_ITEM_TAG = 'div' MULTIFIGURE_HTML_CAPTION_TAG = 'span' class multifigure_content(nodes.General, nodes.Element):...
4,293
28.210884
79
py
NeuroKit
NeuroKit-master/setup.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """The setup script.""" import re from setuptools import find_packages, setup # Utilities with open("README.rst") as readme_file: readme = readme_file.read() with open("NEWS.rst") as history_file: history = history_file.read() history = history.replace("\n-----...
2,317
25.953488
121
py
NeuroKit
NeuroKit-master/studies/complexity_eeg/make_data.py
import os import mne import numpy as np import pandas as pd import neurokit2 as nk # ============================================================================= # Parameters # ============================================================================= datasets = [ "../../data/lemon/lemon/", # Path to local ...
12,454
34.585714
98
py
NeuroKit
NeuroKit-master/studies/ecg_benchmark/make_data.py
import pandas as pd import neurokit2 as nk # Load ECGs ecgs = ["../../data/gudb/ECGs.csv", "../../data/mit_arrhythmia/ECGs.csv", "../../data/mit_normal/ECGs.csv", "../../data/ludb/ECGs.csv", "../../data/fantasia/ECGs.csv"] # Load True R-peaks location rpeaks = [pd.read_csv("../../data...
5,866
32.335227
91
py
NeuroKit
NeuroKit-master/studies/hrv_frequency/make_data.py
import pandas as pd import numpy as np import neurokit2 as nk # Load True R-peaks location datafiles = [pd.read_csv("../../data/gudb/Rpeaks.csv"), pd.read_csv("../../data/mit_arrhythmia/Rpeaks.csv"), pd.read_csv("../../data/mit_normal/Rpeaks.csv"), pd.read_csv("../../data/fantasi...
1,516
31.978261
89
py
NeuroKit
NeuroKit-master/studies/erp_gam/script.py
import numpy as np import pandas as pd import neurokit2 as nk import matplotlib.pyplot as plt import mne # Download example dataset raw = mne.io.read_raw_fif(mne.datasets.sample.data_path() + '/MEG/sample/sample_audvis_filt-0-40_raw.fif') events = mne.read_events(mne.datasets.sample.data_path() + '/MEG/sample/sample_a...
3,394
32.613861
109
py
NeuroKit
NeuroKit-master/studies/microstates_howmany/script.py
import os import mne import scipy import numpy as np import pandas as pd import neurokit2 as nk import matplotlib.pyplot as plt import autoreject from autoreject.utils import interpolate_bads import scipy.stats data_path = "D:/Dropbox/RECHERCHE/N/NeuroKit/data/rs_eeg_texas/data/" files = os.listdir(data_path) resul...
1,816
22.294872
137
py
NeuroKit
NeuroKit-master/tests/tests_microstates.py
# -*- coding: utf-8 -*- import mne import numpy as np import neurokit2 as nk # ============================================================================= # Peaks # ============================================================================= def test_microstates_peaks(): # Load eeg data and calculate gfp ...
951
28.75
102
py
NeuroKit
NeuroKit-master/tests/tests_ecg.py
# -*- coding: utf-8 -*- import biosppy import matplotlib.pyplot as plt import numpy as np import pytest import neurokit2 as nk def test_ecg_simulate(): ecg1 = nk.ecg_simulate( duration=20, length=5000, method="simple", noise=0, random_state=0 ) assert len(ecg1) == 5000 ecg2 = nk.ecg_simulate...
12,392
32.136364
88
py
NeuroKit
NeuroKit-master/tests/tests_ecg_delineate.py
import pathlib import sys import matplotlib.pyplot as plt import numpy as np import pandas as pd import pytest import neurokit2 as nk SHOW_DEBUG_PLOTS = False MAX_SIGNAL_DIFF = 0.03 # seconds @pytest.fixture(name="test_data") def setup_load_ecg_data(): """Load ecg signal and sampling rate.""" def load_si...
2,795
30.772727
112
py
NeuroKit
NeuroKit-master/tests/tests.py
import doctest import pytest if __name__ == "__main__": doctest.testmod() pytest.main()
99
10.111111
26
py
NeuroKit
NeuroKit-master/tests/tests_eog.py
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt import mne import numpy as np import pytest import neurokit2 as nk def test_eog_clean(): # test with exported csv eog_signal = nk.data("eog_200hz")["vEOG"] eog_cleaned = nk.eog_clean(eog_signal, sampling_rate=200) assert eog_cleaned.size == eog...
5,372
31.96319
96
py
NeuroKit
NeuroKit-master/tests/tests_eda.py
import platform import biosppy import matplotlib.pyplot as plt import numpy as np import pandas as pd import pytest import neurokit2 as nk # ============================================================================= # EDA # ============================================================================= def test_e...
8,687
29.808511
101
py
NeuroKit
NeuroKit-master/tests/tests_events.py
import matplotlib.pyplot as plt import numpy as np import pytest import neurokit2 as nk # ============================================================================= # Events # ============================================================================= def test_events_find(): signal = np.cos(np.linspace(st...
1,897
26.911765
79
py
NeuroKit
NeuroKit-master/tests/tests_complexity.py
from collections.abc import Iterable import antropy import nolds import numpy as np import pandas as pd from pyentrp import entropy as pyentrp import sklearn.neighbors from packaging import version # import EntropyHub import neurokit2 as nk # For the testing of complexity, we test our implementations against existin...
23,316
32.94032
127
py
NeuroKit
NeuroKit-master/tests/tests_stats.py
import numpy as np import pandas as pd import neurokit2 as nk # ============================================================================= # Stats # ============================================================================= def test_standardize(): rez = np.sum(nk.standardize([1, 1, 5, 2, 1])) assert...
3,101
28.542857
110
py
NeuroKit
NeuroKit-master/tests/tests_epochs.py
import numpy as np import neurokit2 as nk def test_epochs_create(): # Get data data = nk.data("bio_eventrelated_100hz") # Find events events = nk.events_find(data["Photosensor"], threshold_keep='below', event_conditions=["Negative", "Neutral", "Neutral", "Negative"]) ...
1,507
33.272727
92
py
NeuroKit
NeuroKit-master/tests/tests_signal_fixpeaks.py
# -*- coding: utf-8 -*- import numpy as np import numpy.random import pytest import neurokit2 as nk from neurokit2.signal.signal_fixpeaks import _correct_artifacts, _find_artifacts, signal_fixpeaks def compute_rmssd(peaks): rr = np.ediff1d(peaks, to_begin=0) rr[0] = np.mean(rr[1:]) rmssd = np.sqrt(np.me...
9,417
35.362934
119
py
NeuroKit
NeuroKit-master/tests/tests_ecg_findpeaks.py
# -*- coding: utf-8 -*- import os.path import numpy as np import pandas as pd # Trick to directly access internal functions for unit testing. # # Using neurokit2.ecg.ecg_findpeaks._ecg_findpeaks_MWA doesn't # work because of the "from .ecg_findpeaks import ecg_findpeaks" # statement in neurokit2/ecg/__init.__.py. fro...
1,984
42.152174
118
py
NeuroKit
NeuroKit-master/tests/tests_ppg.py
# -*- coding: utf-8 -*- import itertools import numpy as np import pytest import neurokit2 as nk durations = (20, 200, 300) sampling_rates = (25, 50, 500) heart_rates = (50, 120) freq_modulations = (0.1, 0.4) params = [durations, sampling_rates, heart_rates, freq_modulations] params_combis = list(itertools.produ...
6,974
27.125
104
py
NeuroKit
NeuroKit-master/tests/tests_signal.py
import warnings import matplotlib.pyplot as plt import numpy as np import pandas as pd import pytest import scipy.signal import neurokit2 as nk # ============================================================================= # Signal # ============================================================================= d...
15,358
33.748869
125
py
NeuroKit
NeuroKit-master/tests/__init__.py
0
0
0
py
NeuroKit
NeuroKit-master/tests/tests_rsp.py
# -*- coding: utf-8 -*- import copy import random import biosppy import matplotlib.pyplot as plt import numpy as np import pytest import neurokit2 as nk random.seed(a=13, version=2) def test_rsp_simulate(): rsp1 = nk.rsp_simulate(duration=20, length=3000, random_state=42) assert len(rsp1) == 3000 rsp...
13,128
33.732804
106
py
NeuroKit
NeuroKit-master/tests/tests_hrv.py
import numpy as np import pandas as pd import pytest import neurokit2 as nk from neurokit2 import misc def test_hrv_time(): ecg_slow = nk.ecg_simulate(duration=60, sampling_rate=1000, heart_rate=60, random_state=42) ecg_fast = nk.ecg_simulate(duration=60, sampling_rate=1000, heart_rate=150, random_state=42) ...
7,652
35.099057
100
py
NeuroKit
NeuroKit-master/tests/tests_eeg.py
import mne import numpy as np import pooch import neurokit2 as nk # ============================================================================= # EEG # ============================================================================= def test_eeg_add_channel(): raw = mne.io.read_raw_fif( str(mne.datasets...
3,675
29.633333
144
py
NeuroKit
NeuroKit-master/tests/tests_bio.py
import numpy as np import neurokit2 as nk def test_bio_process(): sampling_rate = 1000 # Create data ecg = nk.ecg_simulate(duration=30, sampling_rate=sampling_rate) rsp = nk.rsp_simulate(duration=30, sampling_rate=sampling_rate) eda = nk.eda_simulate(duration=30, sampling_rate=sampling_rate, sc...
2,058
35.767857
116
py
NeuroKit
NeuroKit-master/tests/tests_data.py
import os import numpy as np import neurokit2 as nk path_data = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "data") # ============================================================================= # Data # ============================================================================= d...
1,187
30.263158
118
py
NeuroKit
NeuroKit-master/tests/tests_emg.py
import biosppy import matplotlib.pyplot as plt import numpy as np import pandas as pd import pytest import scipy.stats import neurokit2 as nk # ============================================================================= # EMG # ============================================================================= def test...
6,367
31.161616
135
py
NeuroKit
NeuroKit-master/docs/conf.py
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- REQUIREMENTS ----------------------------------------------------- # pip install s...
4,891
33.20979
293
py
NeuroKit
NeuroKit-master/docs/readme/README_examples.py
import matplotlib import matplotlib.cm import matplotlib.pyplot as plt import numpy as np import pandas as pd from mpl_toolkits.mplot3d import Axes3D import neurokit2 as nk # Setup matplotlib with Agg to run on server matplotlib.use("Agg") plt.rcParams["figure.figsize"] = (10, 6.5) plt.rcParams["savefig.facecolor"] =...
12,141
30.70235
100
py
NeuroKit
NeuroKit-master/data/eeg_1min_200hz.py
import pickle import mne raw = mne.io.read_raw_fif( mne.datasets.sample.data_path() / "MEG/sample/sample_audvis_raw.fif", preload=True, verbose=False, ) raw = raw.pick(["eeg", "eog", "stim"], verbose=False) raw = raw.crop(0, 60) raw = raw.resample(200) # raw.ch_names # raw.info["sfreq"] # Store data (s...
445
20.238095
73
py
NeuroKit
NeuroKit-master/data/eeg_resting_8min.py
import mne import numpy as np import TruScanEEGpy import neurokit2 as nk # EDF TO FIF # ========== # Read original file (too big to be uploaded on github) raw = mne.io.read_raw_edf("eeg_restingstate_3000hz.edf", preload=True) # Find event onset and cut event = nk.events_find(raw.copy().pick_channels(["Foto"]).to_dat...
1,318
27.673913
100
py
NeuroKit
NeuroKit-master/data/mit_arrhythmia/download_mit_arrhythmia.py
# -*- coding: utf-8 -*- """Script for formatting the MIT-Arrhythmia database Steps: 1. Download the ZIP database from https://alpha.physionet.org/content/mitdb/1.0.0/ 2. Open it with a zip-opener (WinZip, 7zip). 3. Extract the folder of the same name (named 'mit-bih-arrhythmia-database-1.0.0') to the same ...
2,522
33.561644
153
py
NeuroKit
NeuroKit-master/data/fantasia/download_fantasia.py
# -*- coding: utf-8 -*- """Script for formatting the Fantasia Database The database consists of twenty young and twenty elderly healthy subjects. All subjects remained in a resting state in sinus rhythm while watching the movie Fantasia (Disney, 1940) to help maintain wakefulness. The continuous ECG signals were digit...
1,886
34.603774
403
py
NeuroKit
NeuroKit-master/data/gudb/download_gudb.py
# -*- coding: utf-8 -*- """Script for downloading, formatting and saving the GUDB database (https://github.com/berndporr/ECG-GUDB). It contains ECGs from 25 subjects. Each subject was recorded performing 5 different tasks for two minutes: - sitting - a maths test on a tablet - walking on a treadmill - running on a tre...
2,114
33.112903
107
py
NeuroKit
NeuroKit-master/data/ludb/download_ludb.py
# -*- coding: utf-8 -*- """Script for formatting the Lobachevsky University Electrocardiography Database The database consists of 200 10-second 12-lead ECG signal records representing different morphologies of the ECG signal. The ECGs were collected from healthy volunteers and patients, which had various cardiovascula...
1,862
33.5
334
py
NeuroKit
NeuroKit-master/data/ptb_xl/download_ptbxl.py
# -*- coding: utf-8 -*- """Script for formatting the PTB-XL Database https://physionet.org/content/ptb-xl/1.0.1/ """
118
18.833333
44
py
NeuroKit
NeuroKit-master/data/testretest_restingstate_eeg/download_script.py
""" https://openneuro.org/datasets/ds003685/ """ import os import re import shutil import mne import numpy as np import openneuro as on import neurokit2 as nk # Download cleaned data (takes some time) on.download( dataset="ds003685", target_dir="eeg/raw", include="sub-*/ses-session1/*eyes*", ) # Convert...
2,061
32.258065
86
py
NeuroKit
NeuroKit-master/data/mit_long-term/download_mit_long-term.py
# -*- coding: utf-8 -*- """Script for formatting the MIT-Long-Term ECG Database Steps: 1. Download the ZIP database from https://physionet.org/content/ltdb/1.0.0/ 2. Open it with a zip-opener (WinZip, 7zip). 3. Extract the folder of the same name (named 'mit-bih-long-term-ecg-database-1.0.0') to the same f...
1,993
29.212121
142
py
NeuroKit
NeuroKit-master/data/srm_restingstate_eeg/download_script.py
""" https://openneuro.org/datasets/ds003775/versions/1.0.0 """ import os import shutil import mne import numpy as np import openneuro as on import neurokit2 as nk # Download cleaned data (takes some time) on.download( dataset="ds003775", target_dir="eeg/raw", include="sub-*", exclude="derivatives/cle...
1,101
23.488889
94
py
NeuroKit
NeuroKit-master/data/mit_normal/download_mit_normal.py
# -*- coding: utf-8 -*- """Script for formatting the MIT-Normal Sinus Rhythm Database Steps: 1. Download the ZIP database from https://physionet.org/content/nsrdb/1.0.0/ 2. Open it with a zip-opener (WinZip, 7zip). 3. Extract the folder of the same name (named 'mit-bih-normal-sinus-rhythm-database-1.0.0') ...
2,009
29.923077
154
py
NeuroKit
NeuroKit-master/data/lemon/download_lemon.py
# -*- coding: utf-8 -*- """Script for formatting the LEMON EEG dataset https://ftp.gwdg.de/pub/misc/MPI-Leipzig_Mind-Brain-Body-LEMON/EEG_MPILMBB_LEMON/EEG_Preprocessed_BIDS_ID/EEG_Preprocessed/ Steps: 1. Download the ZIP database from https://physionet.org/content/nstdb/1.0.0/ 2. Open it with a zip-opener (W...
2,996
30.21875
132
py
NeuroKit
NeuroKit-master/data/mit_nst/download_mit_nst.py
# -*- coding: utf-8 -*- """Script for formatting the MIT-Noise Stress Test database Steps: 1. Download the ZIP database from https://physionet.org/content/nstdb/1.0.0/ 2. Open it with a zip-opener (WinZip, 7zip). 3. Extract the folder of the same name (named 'mit-bih-noise-stress-test-database-1.0.0') to t...
2,000
32.915254
152
py
NeuroKit
NeuroKit-master/neurokit2/__init__.py
"""Top-level package for NeuroKit.""" import datetime import platform import matplotlib # Dependencies import numpy as np import pandas as pd import scipy import sklearn from .benchmark import * from .bio import * from .complexity import * from .data import * from .ecg import * from .eda import * from .eeg import * ...
3,105
23.650794
173
py
NeuroKit
NeuroKit-master/neurokit2/video/video_blinks.py
# !!!!!!!!!!!!!!!!!!!!!!!! # ! NEED HELP WITH THAT ! # !!!!!!!!!!!!!!!!!!!!!!!! # import numpy as np # from ..misc import progress_bar # def video_blinks(video, verbose=True): # """**Extract blinks from video**""" # # Try loading menpo # try: # import cv2 # import menpo.io # im...
2,574
35.267606
112
py
NeuroKit
NeuroKit-master/neurokit2/video/video_skin.py
import numpy as np from ..misc import find_closest def video_skin(face, show=False): """**Skin detection** This function detects the skin in a face. .. note:: This function is experimental. If you are interested in helping us improve that aspect of NeuroKit (e.g., by adding more detect...
4,237
31.6
97
py
NeuroKit
NeuroKit-master/neurokit2/video/video_ppg.py
import numpy as np from ..misc import progress_bar from .video_face import video_face from .video_skin import video_skin def video_ppg(video, sampling_rate=30, verbose=True): """**Remote Photoplethysmography (rPPG) from Video** Extracts the photoplethysmogram (PPG) from a webcam video using the Plane-Orthog...
3,488
30.718182
96
py
NeuroKit
NeuroKit-master/neurokit2/video/__init__.py
"""Submodule for NeuroKit.""" from .video_face import video_face from .video_plot import video_plot from .video_ppg import video_ppg from .video_skin import video_skin __all__ = ["video_plot", "video_face", "video_skin", "video_ppg"]
236
25.333333
65
py
NeuroKit
NeuroKit-master/neurokit2/video/video_plot.py
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt import numpy as np from ..signal import signal_resample def video_plot(video, sampling_rate=30, frames=3, signals=None): """**Visualize video** This function plots a few frames from a video as an image. Parameters ---------- video : np.nda...
3,435
26.934959
91
py
NeuroKit
NeuroKit-master/neurokit2/video/video_face.py
import numpy as np from ..misc import progress_bar def video_face(video, verbose=True): """**Extract face from video** This function extracts the faces from a video. This function requires the `cv2, `menpo` and `menpodetect` modules to be installed. .. note:: This function is experimental....
2,665
26.484536
97
py
NeuroKit
NeuroKit-master/neurokit2/events/events_find.py
# -*- coding: utf-8 -*- import itertools from warnings import warn import numpy as np from ..misc import NeuroKitWarning from ..signal import signal_binarize def events_find( event_channel, threshold="auto", threshold_keep="above", start_at=0, end_at=None, duration_min=1, duration_max=No...
7,961
31.365854
99
py
NeuroKit
NeuroKit-master/neurokit2/events/events_create.py
import numpy as np from .events_find import _events_find_label def events_create(event_onsets, event_durations=None, event_labels=None, event_conditions=None): """**Create events dictionnary from list of onsets** Parameters ---------- event_onsets : array or list A list of events onset. ...
1,821
29.881356
97
py
NeuroKit
NeuroKit-master/neurokit2/events/events_plot.py
# -*- coding: utf-8 -*- import matplotlib.cm import matplotlib.pyplot as plt import numpy as np import pandas as pd def events_plot(events, signal=None, color="red", linestyle="--"): """**Visualize Events** Plot events in signal. Parameters ---------- events : list or ndarray or dict Eve...
3,998
26.02027
97
py
NeuroKit
NeuroKit-master/neurokit2/events/__init__.py
"""Submodule for NeuroKit.""" from .events_find import events_find from .events_create import events_create from .events_plot import events_plot from .events_to_mne import events_to_mne __all__ = ["events_find", "events_create", "events_plot", "events_to_mne"]
263
28.333333
74
py
NeuroKit
NeuroKit-master/neurokit2/events/events_to_mne.py
# -*- coding: utf-8 -*- import numpy as np def events_to_mne(events, event_conditions=None): """**Create MNE-compatible events** Create `MNE <https://mne.tools/stable/index.html>`_ compatible events for integration with M/EEG. Parameters ---------- events : list or ndarray or dict Ev...
2,061
26.864865
113
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_noise.py
import numpy as np from ..misc import check_random_state def signal_noise(duration=10, sampling_rate=1000, beta=1, random_state=None): """**Simulate noise** This function generates pure Gaussian ``(1/f)**beta`` noise. The power-spectrum of the generated noise is proportional to ``S(f) = (1 / f)**beta``....
4,052
31.95122
106
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_timefrequency.py
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt import numpy as np import scipy.signal from ..signal.signal_detrend import signal_detrend def signal_timefrequency( signal, sampling_rate=1000, min_frequency=0.04, max_frequency=None, method="stft", window=None, window_type="hann", ...
21,035
35.20654
99
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_plot.py
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt import numpy as np import pandas as pd from ..events import events_plot from ..stats import standardize as nk_standardize def signal_plot( signal, sampling_rate=None, subplots=False, standardize=False, labels=None, **kwargs ): """**Plot signal with even...
6,532
31.665
107
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_period.py
# -*- coding: utf-8 -*- from warnings import warn import numpy as np from ..misc import NeuroKitWarning from .signal_formatpeaks import _signal_formatpeaks_sanitize from .signal_interpolate import signal_interpolate def signal_period( peaks, sampling_rate=1000, desired_length=None, interpolation_met...
4,293
38.394495
105
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_flatline.py
# -*- coding: utf-8 -*- import numpy as np def signal_flatline(signal, threshold=0.01): """**Return the Flatline Percentage of the Signal** Parameters ---------- signal : Union[list, np.array, pd.Series] The signal (i.e., a time series) in the form of a vector of values. threshold : float...
978
24.102564
100
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_distort.py
# -*- coding: utf-8 -*- from warnings import warn import numpy as np from ..misc import NeuroKitWarning, check_random_state, listify from .signal_resample import signal_resample from .signal_simulate import signal_simulate def signal_distort( signal, sampling_rate=1000, noise_shape="laplace", noise_...
10,658
30.35
106
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_surrogate.py
import numpy as np from ..misc import check_random_state def signal_surrogate(signal, method="IAAFT", random_state=None, **kwargs): """**Create Signal Surrogates** Generate a surrogate version of a signal. Different methods are available, such as: * **random**: Performs a random permutation of the sign...
5,520
34.619355
106
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_autocor.py
import numpy as np import scipy.signal import scipy.stats from matplotlib import pyplot as plt def signal_autocor(signal, lag=None, demean=True, method="auto", show=False): """**Autocorrelation (ACF)** Compute the autocorrelation of a signal. Parameters ----------- signal : Union[list, np.array,...
3,754
32.230088
101
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_merge.py
# -*- coding: utf-8 -*- import numpy as np from .signal_resample import signal_resample def signal_merge(signal1, signal2, time1=[0, 10], time2=[0, 10]): """**Arbitrary addition of two signals with different time ranges** Parameters ---------- signal1 : Union[list, np.array, pd.Series] The f...
2,770
32.792683
98
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_findpeaks.py
# -*- coding: utf-8 -*- import numpy as np import scipy.misc import scipy.signal from ..misc import as_vector, find_closest from ..stats import standardize def signal_findpeaks( signal, height_min=None, height_max=None, relative_height_min=None, relative_height_max=None, relative_mean=True, ...
7,447
29.276423
99
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_filter.py
# -*- coding: utf-8 -*- from warnings import warn import matplotlib.pyplot as plt import numpy as np import scipy.signal from ..misc import NeuroKitWarning from .signal_interpolate import signal_interpolate def signal_filter( signal, sampling_rate=1000, lowcut=None, highcut=None, method="butterw...
15,403
40.632432
116
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_recompose.py
import matplotlib.pyplot as plt import numpy as np import scipy.cluster from .signal_zerocrossings import signal_zerocrossings def signal_recompose(components, method="wcorr", threshold=0.5, keep_sd=None, **kwargs): """**Combine signal sources after decomposition** Combine and reconstruct meaningful signal ...
6,336
33.818681
95
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_psd.py
# -*- coding: utf-8 -*- from warnings import warn import numpy as np import pandas as pd import scipy.signal from ..misc import NeuroKitWarning def signal_psd( signal, sampling_rate=1000, method="welch", show=False, normalize=True, min_frequency="default", max_frequency=np.inf, windo...
19,000
33.6102
129
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_power.py
# -*- coding: utf-8 -*- import matplotlib.cm import matplotlib.pyplot as plt import numpy as np import pandas as pd from .signal_psd import signal_psd def signal_power( signal, frequency_band, sampling_rate=1000, continuous=False, show=False, normalize=True, **kwargs, ): """**Compute ...
7,879
28.961977
121
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_detrend.py
# -*- coding: utf-8 -*- import numpy as np import scipy.sparse from ..stats import fit_loess, fit_polynomial from .signal_decompose import signal_decompose def signal_detrend( signal, method="polynomial", order=1, regularization=500, alpha=0.75, window=1.5, stepsize=0.02, components=[...
10,122
41.894068
113
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_resample.py
# -*- coding: utf-8 -*- import numpy as np import pandas as pd import scipy.ndimage import scipy.signal def signal_resample( signal, desired_length=None, sampling_rate=None, desired_sampling_rate=None, method="interpolation", ): """**Resample a continuous signal to a different length or sampli...
6,386
32.615789
101
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_fixpeaks.py
# - * - coding: utf-8 - * - from warnings import warn import matplotlib.patches import matplotlib.pyplot as plt import numpy as np import pandas as pd from ..misc import NeuroKitWarning from ..stats import standardize from .signal_formatpeaks import _signal_formatpeaks_sanitize from .signal_period import signal_perio...
23,099
36.745098
116
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_synchrony.py
# -*- coding: utf-8 -*- import numpy as np import pandas as pd import scipy.signal def signal_synchrony(signal1, signal2, method="hilbert", window_size=50): """**Synchrony (coupling) between two signals** Signal coherence refers to the strength of the mutual relationship (i.e., the amount of shared infor...
4,293
35.084034
107
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_simulate.py
# -*- coding: utf-8 -*- from warnings import warn import numpy as np from ..misc import NeuroKitWarning, check_random_state, listify def signal_simulate( duration=10, sampling_rate=1000, frequency=1, amplitude=0.5, noise=0, silent=False, random_state=None, ): """**Simulate a continuo...
3,880
32.456897
106
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_binarize.py
# -*- coding: utf-8 -*- import numpy as np import pandas as pd import sklearn.mixture def signal_binarize(signal, method="threshold", threshold="auto"): """**Binarize a continuous signal** Convert a continuous signal into zeros and ones depending on a given threshold. Parameters ---------- signa...
3,686
33.138889
100
py
NeuroKit
NeuroKit-master/neurokit2/signal/signal_sanitize.py
# -*- coding: utf-8 -*- import numpy as np import pandas as pd def signal_sanitize(signal): """**Signal input sanitization** Reset indexing for Pandas Series. Parameters ---------- signal : Series The indexed input signal (``pandas Dataframe.set_index()``) Returns ------- Se...
942
21.452381
85
py
NeuroKit
NeuroKit-master/neurokit2/signal/__init__.py
"""Submodule for NeuroKit.""" from .signal_autocor import signal_autocor from .signal_binarize import signal_binarize from .signal_changepoints import signal_changepoints from .signal_decompose import signal_decompose from .signal_detrend import signal_detrend from .signal_distort import signal_distort from .signal_fil...
2,067
30.815385
54
py