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 |
|---|---|---|---|---|---|---|
NeuroKit | NeuroKit-master/neurokit2/hrv/intervals_utils.py | # -*- coding: utf-8 -*-
import numpy as np
import scipy
def _intervals_successive(intervals, intervals_time=None, thresh_unequal=10, n_diff=1):
"""Identify successive intervals.
Identification of intervals that are consecutive
(e.g. in case of missing data).
Parameters
----------
intervals :... | 7,239 | 34.145631 | 103 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/eeg_badchannels.py | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scipy.stats
from ..signal import signal_zerocrossings
from ..stats import hdi, mad, standardize
def eeg_badchannels(eeg, bad_threshold=0.5, distance_threshold=0.99, show=False):
"""**Find bad channels**
Fin... | 4,410 | 32.930769 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/eeg_source.py | def eeg_source(raw, src, bem, method="sLORETA", show=False, verbose="WARNING", **kwargs):
"""**Source Reconstruction for EEG data**
Currently only for mne.Raw objects.
Parameters
----------
raw : mne.io.Raw
Raw EEG data.
src : mne.SourceSpace
Source space. See :func:`mne_templa... | 2,658 | 31.036145 | 109 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/mne_crop.py | import numpy as np
def mne_crop(raw, tmin=0.0, tmax=None, include_tmax=True, smin=None, smax=None):
"""**Crop mne.Raw objects**
This function is similar to ``raw.crop()`` (same arguments), but with a few critical differences:
* It recreates a whole new Raw object, and as such drops all information pertai... | 4,041 | 32.966387 | 105 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/eeg_gfp.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from ..signal import signal_filter
from ..stats import mad, standardize
def eeg_gfp(
eeg,
sampling_rate=None,
method="l1",
normalize=False,
smooth=0,
robust=False,
standardize_eeg=False,
):
"""**Global Field Power (GFP)**
... | 4,869 | 29.061728 | 102 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/mne_data.py | # -*- coding: utf-8 -*-
def mne_data(what="raw", path=None):
"""**Access MNE Datasets**
Utility function to easily access MNE datasets.
Parameters
-----------
what : str
Can be ``"raw"`` or ``"filt-0-40_raw"`` (a filtered version).
path : str
Defaults to ``None``, assuming th... | 2,308 | 28.602564 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/eeg_rereference.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
def eeg_rereference(eeg, reference="average", robust=False, **kwargs):
"""**EEG Rereferencing**
This function can be used for arrays as well as MNE objects.
EEG recordings measure differences in electrical potentials between two points, whic... | 5,622 | 35.512987 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/eeg_1f.py | # -*- coding: utf-8 -*-
# import numpy as np
# import pandas as pd
# def mne_channel_extract(raw):
# """1/f Neural Noise
# Extract parameters related to the 1/f structure of the EEG power spectrum.
# Parameters
# ----------
# raw : mne.io.Raw
# Raw EEG data.
# Returns
# --------... | 996 | 22.738095 | 101 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/utils.py | import numpy as np
import pandas as pd
from .mne_to_df import mne_to_df
def _sanitize_eeg(eeg, sampling_rate=None, time=None):
"""Convert to DataFrame
Input can be an array (channels, time), or an MNE object.
Examples
---------
>>> import neurokit2 as nk
>>>
>>> # Raw objects
>>> ee... | 874 | 22.648649 | 66 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/eeg_source_extract.py | import pandas as pd
def eeg_source_extract(stc, src, segmentation="PALS_B12_Lobes", verbose="WARNING", **kwargs):
"""**Extract the activity from an anatomical source**
Returns a dataframe with the activity from each source in the segmentation.
Parcellation models include:
* 'aparc'
* 'aparc.a200... | 2,135 | 25.7 | 105 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/eeg_diss.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from .eeg_gfp import eeg_gfp
def eeg_diss(eeg, gfp=None, **kwargs):
"""**Global dissimilarity (DISS)**
Global dissimilarity (DISS) is an index of configuration differences between two electric
fields, independent of their strength. Like GFP,... | 2,026 | 27.957143 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/__init__.py | """Submodule for NeuroKit."""
from .eeg_badchannels import eeg_badchannels
from .eeg_diss import eeg_diss
from .eeg_gfp import eeg_gfp
from .eeg_power import eeg_power
from .eeg_rereference import eeg_rereference
from .eeg_simulate import eeg_simulate
from .eeg_source import eeg_source
from .eeg_source_extract import ... | 904 | 24.857143 | 52 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/mne_templateMRI.py | import os
def mne_templateMRI(verbose="WARNING"):
"""**Return Path of MRI Template**
This function is a helper that returns the path of the MRI template for adults (the ``src`` and
the ``bem``) that is made available through ``"MNE"``. It downloads the data if need be. These
templates can be used for... | 1,277 | 28.72093 | 105 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/mne_channel_extract.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
def mne_channel_extract(raw, what, name=None, add_firstsamples=False):
"""**Channel extraction from MNE objects**
Select one or several channels by name and returns them in a dataframe.
Parameters
----------
raw : mne.io.Raw
... | 3,844 | 38.639175 | 110 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/eeg_simulate.py | import numpy as np
from ..misc import check_random_state
def eeg_simulate(duration=1, length=None, sampling_rate=1000, noise=0.1, random_state=None):
"""**EEG Signal Simulation**
Simulate an artificial EEG signal. This is a crude implementation based on the MNE-Python raw
simulation example. Help is nee... | 3,600 | 32.654206 | 115 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/mne_to_df.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
def mne_to_df(eeg):
"""**Conversion from MNE to dataframes**
Convert MNE objects to dataframe or dict of dataframes.
Parameters
----------
eeg : Union[mne.io.Raw, mne.Epochs]
Raw or Epochs M/EEG data from MNE.
See Also
... | 4,091 | 24.416149 | 105 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/mne_channel_add.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
def mne_channel_add(
raw, channel, channel_type=None, channel_name=None, sync_index_raw=0, sync_index_channel=0
):
"""**Add channel as array to MNE**
Add a channel to a mne's Raw m/eeg file. It will basically synchronize the channel to the ee... | 3,693 | 32.889908 | 105 | py |
NeuroKit | NeuroKit-master/neurokit2/eeg/eeg_power.py | # -*- coding: utf-8 -*-
import pandas as pd
from ..signal import signal_power
from .utils import _sanitize_eeg
def eeg_power(
eeg, sampling_rate=None, frequency_band=["Gamma", "Beta", "Alpha", "Theta", "Delta"], **kwargs
):
"""**EEG Power in Different Frequency Bands**
See our `walkthrough <https://neur... | 3,963 | 30.460317 | 109 | py |
NeuroKit | NeuroKit-master/neurokit2/benchmark/benchmark_ecg.py | # -*- coding: utf-8 -*-
import datetime
import numpy as np
import pandas as pd
from ..signal import signal_period
def benchmark_ecg_preprocessing(function, ecg, rpeaks=None, sampling_rate=1000):
"""**Benchmark ECG preprocessing pipelines**
Parameters
----------
function : function
Must be a... | 5,347 | 33.727273 | 108 | py |
NeuroKit | NeuroKit-master/neurokit2/benchmark/benchmark_utils.py | from timeit import default_timer as timer
from wfdb.processing import compare_annotations
def benchmark_record(record, sampling_rate, annotation, tolerance, detector):
"""**Obtain detector performance for an annotated record**
Parameters
----------
record : array
The raw physiological record... | 2,161 | 28.216216 | 80 | py |
NeuroKit | NeuroKit-master/neurokit2/benchmark/__init__.py | """Submodule for NeuroKit."""
from .benchmark_ecg import benchmark_ecg_preprocessing
__all__ = [
"benchmark_ecg_preprocessing",
]
| 137 | 14.333333 | 54 | py |
NeuroKit | NeuroKit-master/neurokit2/data/write_csv.py | import numpy as np
def write_csv(data, filename, parts=None, **kwargs):
"""**Write data to multiple csv files**
Split the data into multiple CSV files. You can then re-create them as follows:
Parameters
----------
data : list
List of dictionaries.
filename : str
Name of the ... | 1,287 | 23.301887 | 93 | py |
NeuroKit | NeuroKit-master/neurokit2/data/read_bitalino.py | # -*- coding: utf-8 -*-
import json
import os
from warnings import warn
import numpy as np
import pandas as pd
from ..misc import NeuroKitWarning
def read_bitalino(filename):
"""**Read an OpenSignals file (from BITalino)**
Reads and loads a BITalino file into a Pandas DataFrame.
The function outputs bo... | 4,610 | 34.469231 | 98 | py |
NeuroKit | NeuroKit-master/neurokit2/data/read_video.py | # -*- coding: utf-8 -*-
import os
import numpy as np
def read_video(filename="video.mp4"):
"""**Reads a video file into an array**
Reads a video file (e.g., .mp4) into a numpy array of shape. This function requires OpenCV to
be installed via the ``opencv-python`` package.
Parameters
----------
... | 1,541 | 25.586207 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/data/data.py | # -*- coding: utf-8 -*-
import json
import os
import pickle
import urllib
import pandas as pd
from sklearn import datasets as sklearn_datasets
def data(dataset="bio_eventrelated_100hz"):
"""**NeuroKit Datasets**
NeuroKit includes datasets that can be used for testing. These datasets are not downloaded
a... | 7,455 | 29.432653 | 106 | py |
NeuroKit | NeuroKit-master/neurokit2/data/read_acqknowledge.py | # -*- coding: utf-8 -*-
import os
import numpy as np
import pandas as pd
from ..signal import signal_resample
def read_acqknowledge(
filename, sampling_rate="max", resample_method="interpolation", impute_missing=True
):
"""**Read and format a BIOPAC's AcqKnowledge file into a pandas' dataframe**
The fu... | 4,253 | 32.761905 | 104 | py |
NeuroKit | NeuroKit-master/neurokit2/data/__init__.py | """Submodule for NeuroKit."""
from .data import data
from .read_acqknowledge import read_acqknowledge
from .read_bitalino import read_bitalino
from .read_video import read_video
from .write_csv import write_csv
__all__ = ["read_acqknowledge", "read_bitalino", "read_video", "data", "write_csv"]
| 297 | 28.8 | 83 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/cluster_quality.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import scipy.spatial
import sklearn.cluster
import sklearn.metrics
import sklearn.mixture
import sklearn.model_selection
from ..misc import check_random_state
def cluster_quality(data, clustering, clusters=None, info=None, n_random=10, random_state=None,... | 12,509 | 36.794562 | 107 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/density_bandwidth.py | # -*- coding: utf-8 -*-
import warnings
import numpy as np
import scipy.stats
def density_bandwidth(x, method="KernSmooth", resolution=401):
"""**Bandwidth Selection for Density Estimation**
Bandwidth selector for :func:`.density` estimation. See ``bw_method`` argument in
:func:`.scipy.stats.gaussian_kd... | 4,949 | 28.464286 | 117 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/hdi.py | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
from ..misc import find_closest
from .density import density
def hdi(x, ci=0.95, show=False, **kwargs):
"""**Highest Density Interval (HDI)**
Compute the Highest Density Interval (HDI) of a distribution. All points within this interv... | 2,905 | 29.270833 | 98 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/correlation.py | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats
def cor(x, y, method="pearson", show=False):
"""**Density estimation**
Computes kernel density estimates.
Parameters
-----------
x : Union[list, np.array, pd.Series]
Vectors of values.
y : U... | 1,874 | 23.671053 | 87 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/density.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import scipy.stats
from .density_bandwidth import density_bandwidth
def density(x, desired_length=100, bandwidth="Scott", show=False, **kwargs):
"""Density estimation.
Computes kernel density estimates.
Parameters
-----------
x : Un... | 2,045 | 24.898734 | 87 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/cluster.py | # -*- coding: utf-8 -*-
import functools
import warnings
import numpy as np
import pandas as pd
import scipy.linalg
import scipy.spatial
import sklearn.cluster
import sklearn.decomposition
import sklearn.mixture
from ..misc import check_random_state
from .cluster_quality import _cluster_quality_distance
def cluster... | 28,345 | 35.812987 | 116 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/cluster_findnumber.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from .cluster import cluster
from .cluster_quality import cluster_quality
def cluster_findnumber(data, method="kmeans", n_max=10, show=False, **kwargs):
"""**Optimal Number of Clusters**
Find the optimal number of clusters based on different ind... | 2,697 | 28.977778 | 98 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/fit_loess.py | # -*- coding: utf-8 -*-
import numpy as np
import scipy.linalg
def fit_loess(y, X=None, alpha=0.75, order=2):
"""**Local Polynomial Regression (LOESS)**
Performs a LOWESS (LOcally WEighted Scatter-plot Smoother) regression.
Parameters
----------
y : Union[list, np.array, pd.Series]
The ... | 2,919 | 27.349515 | 102 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/standardize.py | # -*- coding: utf-8 -*-
from warnings import warn
import numpy as np
import pandas as pd
from ..misc import NeuroKitWarning
from ..misc.check_type import is_string
from .mad import mad
def standardize(data, robust=False, window=None, **kwargs):
"""**Standardization of data**
Performs a standardization of d... | 4,654 | 32.014184 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/rescale.py | # -*- coding: utf-8 -*-
import numpy as np
def rescale(data, to=[0, 1], scale=None):
"""**Rescale data**
Rescale a numeric variable to a new range.
Parameters
----------
data : Union[list, np.array, pd.Series]
Raw data.
to : list
New range of values of the data after rescalin... | 1,291 | 22.925926 | 79 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/fit_polynomial.py | # -*- coding: utf-8 -*-
import numpy as np
import sklearn.linear_model
import sklearn.metrics
from .fit_error import fit_rmse
def fit_polynomial(y, X=None, order=2, method="raw"):
"""**Polynomial Regression**
Performs a polynomial regression of given order.
Parameters
----------
y : Union[list... | 4,961 | 29.819876 | 126 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/mad.py | # -*- coding: utf-8 -*-
import numpy as np
def mad(x, constant=1.4826, **kwargs):
"""**Median Absolute Deviation: a "robust" version of standard deviation**
Parameters
----------
x : Union[list, np.array, pd.Series]
A vector of values.
constant : float
Scale factor. Use 1.4826 for... | 815 | 21.054054 | 78 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/fit_error.py | # -*- coding: utf-8 -*-
import numpy as np
def fit_error(y, y_predicted, n_parameters=2):
"""**Calculate the fit error for a model**
Also specific and direct access functions can be used, such as :func:`.fit_mse`,
:func:`.fit_rmse` and :func:`.fit_r2`.
Parameters
----------
y : Union[list, n... | 3,199 | 25.666667 | 105 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/__init__.py | """Submodule for NeuroKit."""
from .cluster import cluster
from .cluster_findnumber import cluster_findnumber
from .cluster_quality import cluster_quality
from .correlation import cor
from .density import density
from .density_bandwidth import density_bandwidth
from .distance import distance
from .fit_error import fit... | 1,009 | 23.047619 | 68 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/distance.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
import scipy
import scipy.spatial
from .standardize import standardize
def distance(X=None, method="mahalanobis"):
"""**Distance**
Compute distance using different metrics.
Parameters
----------
X : array or DataFrame
A data... | 2,251 | 24.590909 | 103 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/summary.py | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as st
from .density import density
from .rescale import rescale
def summary_plot(x, errorbars=0, **kwargs):
"""**Descriptive plot**
Visualize a distribution with density, histogram, boxplot and rugs plots all at on... | 1,845 | 25.753623 | 104 | py |
NeuroKit | NeuroKit-master/neurokit2/stats/fit_mixture.py | # -*- coding: utf-8 -*-
import pandas as pd
import sklearn.mixture
def fit_mixture(X=None, n_clusters=2):
"""**Gaussian Mixture Model**
Performs a polynomial regression of given order.
Parameters
----------
X : Union[list, np.array, pd.Series]
The values to classify.
n_clusters : int... | 1,465 | 25.178571 | 98 | py |
NeuroKit | NeuroKit-master/neurokit2/ppg/ppg_eventrelated.py | # -*- coding: utf-8 -*-
from ..epochs.eventrelated_utils import (
_eventrelated_addinfo,
_eventrelated_rate,
_eventrelated_sanitizeinput,
_eventrelated_sanitizeoutput,
)
def ppg_eventrelated(epochs, silent=False):
"""**Performs event-related PPG analysis on epochs**
Parameters
----------
... | 2,862 | 31.168539 | 98 | py |
NeuroKit | NeuroKit-master/neurokit2/ppg/ppg_process.py | # -*- coding: utf-8 -*-
import pandas as pd
from ..misc import as_vector
from ..misc.report import create_report
from ..signal import signal_rate
from ..signal.signal_formatpeaks import _signal_from_indices
from .ppg_clean import ppg_clean
from .ppg_findpeaks import ppg_findpeaks
from .ppg_methods import ppg_methods
f... | 3,664 | 29.289256 | 91 | py |
NeuroKit | NeuroKit-master/neurokit2/ppg/ppg_intervalrelated.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from ..hrv import hrv
def ppg_intervalrelated(data, sampling_rate=1000):
"""**Performs PPG analysis on longer periods of data (typically > 10 seconds), such as
resting-state data**
Parameters
----------
data : Union[dict, pd.DataFram... | 4,011 | 29.165414 | 105 | py |
NeuroKit | NeuroKit-master/neurokit2/ppg/ppg_plot.py | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
def ppg_plot(ppg_signals, sampling_rate=None, static=True):
"""**Visualize photoplethysmogram (PPG) data**
Visualize the PPG signal processing.
Parameters
----------
ppg_signals : DataFrame
Dat... | 5,587 | 28.723404 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/ppg/ppg_clean.py | # -*- coding: utf-8 -*-
from warnings import warn
import numpy as np
from ..misc import NeuroKitWarning, as_vector
from ..signal import signal_fillmissing, signal_filter
def ppg_clean(ppg_signal, sampling_rate=1000, heart_rate=None, method="elgendi"):
"""**Clean a photoplethysmogram (PPG) signal**
Prepare ... | 4,274 | 29.978261 | 103 | py |
NeuroKit | NeuroKit-master/neurokit2/ppg/ppg_findpeaks.py | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import scipy.signal
from ..signal import signal_smooth
def ppg_findpeaks(ppg_cleaned, sampling_rate=1000, method="elgendi", show=False, **kwargs):
"""**Find systolic peaks in a photoplethysmogram (PPG) signal**
Parameters
------... | 8,147 | 33.820513 | 119 | py |
NeuroKit | NeuroKit-master/neurokit2/ppg/ppg_methods.py | # -*- coding: utf-8 -*-
import numpy as np
from ..misc.report import get_kwargs
from .ppg_clean import ppg_clean
from .ppg_findpeaks import ppg_findpeaks
def ppg_methods(
sampling_rate=1000,
method="elgendi",
method_cleaning="default",
method_peaks="default",
**kwargs,
):
"""**PPG Preprocessi... | 6,124 | 36.576687 | 109 | py |
NeuroKit | NeuroKit-master/neurokit2/ppg/__init__.py | """Submodule for NeuroKit."""
# Aliases
from ..signal import signal_rate as ppg_rate
from .ppg_analyze import ppg_analyze
from .ppg_clean import ppg_clean
from .ppg_eventrelated import ppg_eventrelated
from .ppg_findpeaks import ppg_findpeaks
from .ppg_intervalrelated import ppg_intervalrelated
from .ppg_methods impor... | 654 | 23.259259 | 52 | py |
NeuroKit | NeuroKit-master/neurokit2/ppg/ppg_simulate.py | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
from ..misc import check_random_state, check_random_state_children
from ..signal import signal_distort, signal_interpolate
def ppg_simulate(
duration=120,
sampling_rate=1000,
heart_rate=70,
frequency_modulation=0.2,
ibi_r... | 11,257 | 38.780919 | 112 | py |
NeuroKit | NeuroKit-master/neurokit2/ppg/ppg_analyze.py | # -*- coding: utf-8 -*-
import pandas as pd
from .ppg_eventrelated import ppg_eventrelated
from .ppg_intervalrelated import ppg_intervalrelated
def ppg_analyze(data, sampling_rate=1000, method="auto"):
"""**Photoplethysmography (PPG) Analysis**.
Performs PPG analysis on either epochs (event-related analysis... | 4,193 | 34.542373 | 99 | py |
NeuroKit | NeuroKit-master/neurokit2/emg/emg_plot.py | # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
def emg_plot(emg_signals, sampling_rate=None, static=True):
"""**EMG Graph**
Visualize electromyography (EMG) data.
Parameters
----------
emg_signals : DataFrame
DataFrame obtained from ``emg_p... | 7,786 | 27.947955 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/emg/emg_analyze.py | # -*- coding: utf-8 -*-
import pandas as pd
from .emg_eventrelated import emg_eventrelated
from .emg_intervalrelated import emg_intervalrelated
def emg_analyze(data, sampling_rate=1000, method="auto"):
"""**EMG Analysis**
Performs EMG analysis on either epochs (event-related analysis) or on longer periods o... | 3,915 | 35.943396 | 127 | py |
NeuroKit | NeuroKit-master/neurokit2/emg/emg_eventrelated.py | # -*- coding: utf-8 -*-
from warnings import warn
import numpy as np
from ..epochs.eventrelated_utils import (
_eventrelated_addinfo,
_eventrelated_sanitizeinput,
_eventrelated_sanitizeoutput,
)
from ..misc import NeuroKitWarning
def emg_eventrelated(epochs, silent=False):
"""**Event-related EMG Ana... | 4,995 | 36.56391 | 100 | py |
NeuroKit | NeuroKit-master/neurokit2/emg/emg_amplitude.py | # -*- coding: utf-8 -*-
import numpy as np
from ..signal import signal_filter
def emg_amplitude(emg_cleaned):
"""**Compute electromyography (EMG) amplitude**
Compute electromyography amplitude given the cleaned respiration signal, done by calculating the
linear envelope of the signal.
Parameters
... | 4,219 | 29.142857 | 109 | py |
NeuroKit | NeuroKit-master/neurokit2/emg/emg_methods.py | # -*- coding: utf-8 -*-
import numpy as np
from ..misc.report import get_kwargs
from .emg_activation import emg_activation
def emg_methods(
sampling_rate=1000,
method_cleaning="biosppy",
method_activation="threshold",
**kwargs,
):
"""**EMG Preprocessing Methods**
This function analyzes and s... | 5,092 | 36.448529 | 111 | py |
NeuroKit | NeuroKit-master/neurokit2/emg/emg_activation.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
from ..events import events_find
from ..misc import as_vector
from ..signal import (signal_binarize, signal_changepoints, signal_formatpeaks,
signal_smooth)
def emg_activation(
emg_amplitude=None,
emg_cleaned=None,
sampl... | 15,435 | 34.731481 | 118 | py |
NeuroKit | NeuroKit-master/neurokit2/emg/emg_simulate.py | # -*- coding: utf-8 -*-
import numpy as np
from ..misc import check_random_state
from ..signal import signal_resample
def emg_simulate(
duration=10,
length=None,
sampling_rate=1000,
noise=0.01,
burst_number=1,
burst_duration=1.0,
random_state=None,
):
"""**Simulate an EMG signal**
... | 3,570 | 29.008403 | 112 | py |
NeuroKit | NeuroKit-master/neurokit2/emg/emg_process.py | # -*- coding: utf-8 -*-
import pandas as pd
from ..misc.report import create_report
from ..signal import signal_sanitize
from .emg_activation import emg_activation
from .emg_amplitude import emg_amplitude
from .emg_clean import emg_clean
from .emg_methods import emg_methods
from .emg_plot import emg_plot
def emg_pro... | 3,693 | 33.523364 | 98 | py |
NeuroKit | NeuroKit-master/neurokit2/emg/__init__.py | """Submodule for NeuroKit."""
from .emg_activation import emg_activation
from .emg_amplitude import emg_amplitude
from .emg_analyze import emg_analyze
from .emg_clean import emg_clean
from .emg_eventrelated import emg_eventrelated
from .emg_intervalrelated import emg_intervalrelated
from .emg_plot import emg_plot
from... | 593 | 22.76 | 52 | py |
NeuroKit | NeuroKit-master/neurokit2/emg/emg_intervalrelated.py | # -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
def emg_intervalrelated(data):
"""**EMG Analysis for Interval-related Data**
Performs EMG analysis on longer periods of data (typically > 10 seconds), such as resting-state data.
Parameters
----------
data : Union[dict, pd.DataFrame]... | 4,366 | 35.090909 | 105 | py |
NeuroKit | NeuroKit-master/neurokit2/emg/emg_clean.py | # -*- coding: utf-8 -*-
from warnings import warn
import numpy as np
import pandas as pd
import scipy.signal
from ..misc import NeuroKitWarning, as_vector
from ..signal import signal_detrend
def emg_clean(emg_signal, sampling_rate=1000, method="biosppy"):
"""**Preprocess an electromyography (emg) signal**
... | 3,220 | 28.550459 | 99 | py |
ULR | ULR-main/dual-encoder/L2/utils.py | import os
from transformers.data.processors.utils import DataProcessor, InputExample
from transformers import PreTrainedTokenizer
from tqdm import tqdm
import random
import code
from typing import List, Optional, Union
import json
from dataclasses import dataclass
import logging
logger = logging.getLogger(__name__)
@... | 6,812 | 31.913043 | 154 | py |
ULR | ULR-main/dual-encoder/L2/compute_acc_kmeans.py | import numpy as np
import sys
from sklearn.metrics import f1_score
from sklearn.kernel_approximation import RBFSampler
import code
if len(sys.argv) not in [4]:
print("Usage: python compute_acc.py test_file text_embeddings category_embeddings ")
exit(-1)
test_file = sys.argv[1]
text_file = sys.argv[2]
cat_fil... | 2,121 | 28.068493 | 137 | py |
ULR | ULR-main/dual-encoder/L2/eval_downstream_task.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 23,469 | 39.25729 | 164 | py |
ULR | ULR-main/dual-encoder/L2/train_natcat.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 33,817 | 41.753477 | 177 | py |
ULR | ULR-main/dual-encoder/cosine/utils.py | import os
from transformers.data.processors.utils import DataProcessor, InputExample
from transformers import PreTrainedTokenizer
from tqdm import tqdm
import random
import code
from typing import List, Optional, Union
import json
from dataclasses import dataclass
import logging
logger = logging.getLogger(__name__)
@... | 6,865 | 32.009615 | 154 | py |
ULR | ULR-main/dual-encoder/cosine/compute_acc_kmeans_cosine.py | import numpy as np
import sys
from sklearn.metrics import f1_score
import code
import random
random.seed(1)
if len(sys.argv) not in [4]:
print("Usage: python compute_acc.py test_file text_embeddings category_embeddings ")
exit(-1)
test_file = sys.argv[1]
text_file = sys.argv[2]
cat_file = sys.argv[3]
with ... | 2,231 | 24.953488 | 141 | py |
ULR | ULR-main/dual-encoder/cosine/eval_downstream_task.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 22,345 | 39.190647 | 164 | py |
ULR | ULR-main/dual-encoder/cosine/train_natcat.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 34,036 | 41.813836 | 177 | py |
ULR | ULR-main/single-encoder/utils.py | import os
from transformers.data.processors.utils import DataProcessor, InputExample
from tqdm import tqdm
import random
import code
class NatcatProcessor(DataProcessor):
"""Processor for the Natcat data set."""
def __init__(self):
super(NatcatProcessor, self).__init__()
def get_examples(self, f... | 3,716 | 29.975 | 154 | py |
ULR | ULR-main/single-encoder/compute_acc_kmeans.py | import numpy as np
import sys
from sklearn.metrics import f1_score
from scipy.spatial import distance
from scipy.special import softmax, kl_div
import code
if len(sys.argv) != 3:
print("Usage: python compute_acc.py preds_file test_file")
exit(-1)
test_file = sys.argv[1]
preds_file = sys.argv[2]
with open(tes... | 2,057 | 26.078947 | 86 | py |
ULR | ULR-main/single-encoder/eval_downstream_task.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 22,069 | 38.981884 | 150 | py |
ULR | ULR-main/single-encoder/train_natcat.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 31,833 | 41.902965 | 177 | py |
GlobalSfMpy | GlobalSfMpy-main/setup.py | import os
import re
import subprocess
import sys
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
# Convert distutils Windows platform specifiers to CMake -A arguments
PLAT_TO_CMAKE = {
"win32": "Win32",
"win-amd64": "x64",
"win-arm32": "ARM",
"win-arm64": "AR... | 5,750 | 41.286765 | 138 | py |
GlobalSfMpy | GlobalSfMpy-main/scripts/colmap_database.py |
import sys
import sqlite3
import numpy as np
IS_PYTHON3 = sys.version_info[0] >= 3
MAX_IMAGE_ID = 2**31 - 1
CREATE_CAMERAS_TABLE = """CREATE TABLE IF NOT EXISTS cameras (
camera_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
model INTEGER NOT NULL,
width INTEGER NOT NULL,
height INTEGER NOT NULL,
... | 10,542 | 31.946875 | 89 | py |
GlobalSfMpy | GlobalSfMpy-main/scripts/sfm_pipeline.py | import sys
import yaml
import os
import shutil
sys.path.append('../build')
import GlobalSfMpy as sfm
from loss_functions import *
def sfm_with_1dsfm_dataset(flagfile,dataset_path,
loss_func_rotation,
loss_func_position,
rotation_error... | 6,221 | 41.040541 | 134 | py |
GlobalSfMpy | GlobalSfMpy-main/scripts/loss_functions.py | from math import sqrt,log,atan2,exp,cosh
from pickle import FALSE
from re import S
import sys
sys.path.append('../build')
import GlobalSfMpy as sfm
# For a residual vector with squared 2-norm 'sq_norm', this method
# is required to fill in the value and derivatives of the loss
# function (rho in this example):
#
# o... | 17,372 | 36.849673 | 103 | py |
GlobalSfMpy | GlobalSfMpy-main/scripts/get_covariance_from_colmap.py | import sys
import yaml
import os
sys.path.append('../build')
import GlobalSfMpy as sfm
dataset_name = "facade"
flagfile = "../flags_1dsfm.yaml"
dataset_path = "../datasets/"+dataset_name
if os.path.exists(dataset_path+"/covariance_rot.txt"):
print("Covariance already exists!")
exit()
f = open(flagfile,"... | 1,071 | 26.487179 | 106 | py |
GlobalSfMpy | GlobalSfMpy-main/scripts/read_colmap_database.py | from colmap_database import *
import os
import argparse
from scipy.spatial.transform import Rotation
import cv2 as cv
import poselib
parser = argparse.ArgumentParser()
parser.add_argument("--dataset_path", default="../datasets/facade")
args = parser.parse_args()
dataset_path = args.dataset_path
class Pose:
def... | 5,742 | 35.814103 | 134 | py |
GlobalSfMpy | GlobalSfMpy-main/scripts/sfm_with_colmap_feature.py | import sys
import yaml
import os
sys.path.append('../build')
import GlobalSfMpy as sfm
from loss_functions import *
from sfm_pipeline import *
flagfile = "../flags_1dsfm.yaml"
f = open(flagfile,"r")
config = yaml.safe_load(f)
glog_directory = config['glog_directory']
glog_verbose = config['v']
log_to_stderr = config[... | 1,233 | 29.85 | 95 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/main.py | import argparse
from os import path, makedirs
from experiments import select_experiment
import torch
import yaml
import os
def create_dir_structure(config):
subdirs = ["ckpt", "config", "generated", "log"]
structure = {subdir: path.join(config["base_dir"],config["experiment"],subdir,config["project_name"]) for... | 4,862 | 44.448598 | 188 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/models/discriminator.py | import torch
from torch import nn
from torch.optim import Adam
import functools
from torch.nn.utils import spectral_norm
import math
import numpy as np
from utils.general import get_member
from models.blocks import SPADE
class GANTrainer(object):
def __init__(self, config, load_fn,logger,spatial_size=128, paral... | 17,349 | 37.988764 | 191 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/models/latent_flow_net.py | import torch
from torch import nn
from torch.nn import functional as F
import numpy as np
import math
from models.blocks import Conv2dBlock, ResBlock, AdaINLinear, NormConv2d,ConvGRU
class OscillatorModel(nn.Module):
def __init__(self,spatial_size,config,n_no_motion=2, logger=None):
super().__init__()
... | 45,992 | 39.274081 | 181 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/models/blocks.py | import torch
from torch import nn
from torch.nn import functional as F
from torch.nn.utils import weight_norm, spectral_norm
from torch.nn import init
class ResBlock(nn.Module):
def __init__(
self,
dim_in,
dim_out,
norm="in",
activation="elu",
pad_type="zero",
... | 17,622 | 33.690945 | 143 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/experiments/experiment.py | from abc import abstractmethod
import torch
import wandb
import os
from os import path
from glob import glob
import numpy as np
from utils.general import get_logger
WANDB_DISABLE_CODE = True
class Experiment:
def __init__(self, config:dict, dirs: dict, device):
self.parallel = isinstance(device, list)
... | 6,865 | 40.361446 | 140 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/experiments/fixed_length_model.py | import torch
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
from torch.optim import Adam
from ignite.engine import Engine, Events
from ignite.handlers import ModelCheckpoint
from ignite.contrib.handlers import ProgressBar
from ignite.metrics import Average, MetricUsage
import numpy as np
impo... | 57,839 | 54.776278 | 210 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/experiments/__init__.py | from experiments.experiment import Experiment
from experiments.sequence_model import SequencePokeModel
from experiments.fixed_length_model import FixedLengthModel
__experiments__ = {
"sequence_poke_model": SequencePokeModel,
"fixed_length_model": FixedLengthModel,
}
def select_experiment(config,dirs, device... | 851 | 37.727273 | 102 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/experiments/sequence_model.py | import torch
from torch.utils.data import DataLoader
from torch.optim import Adam
from ignite.engine import Engine, Events
from ignite.handlers import ModelCheckpoint
from ignite.contrib.handlers import ProgressBar
from ignite.metrics import Average, MetricUsage
import numpy as np
import wandb
from functools import par... | 58,565 | 53.581547 | 210 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/utils/frechet_video_distance.py | # coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | 5,688 | 35.941558 | 83 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/utils/losses.py | import torch
from torch import nn
from torchvision.models import vgg19
from collections import namedtuple
from operator import mul
from functools import reduce
from utils.general import get_member
VGGOutput = namedtuple(
"VGGOutput",
["input", "relu1_2", "relu2_2", "relu3_2", "relu4_2", "relu5_2"],
)
StyleLay... | 9,190 | 33.423221 | 210 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/utils/metric_fvd.py | import numpy as np
import argparse
from os import path
import torch
import ssl
from glob import glob
from natsort import natsorted
ssl._create_default_https_context = ssl._create_unverified_context
import cv2
from utils.metrics import compute_fvd
from utils.general import get_logger
if __name__ == '__main__':
pa... | 3,569 | 30.59292 | 107 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/utils/testing.py | import numpy as np
import torch
from skimage.metrics import structural_similarity as ssim
import cv2
import math
import imutils
import matplotlib.pyplot as plt
import wandb
from os import path
import math
def make_flow_grid(src, poke, pred, tgt, n_logged, flow=None):
"""
:param src:
:param poke:
:para... | 33,806 | 43.424442 | 204 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/utils/fvd_models.py | from utils.general import get_logger
import os
from os import path
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("-b", "--base", type=str,
default="/export/scratch/ablattma/visual_poking/fixed_length_model/generated",
... | 1,429 | 25.481481 | 102 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/utils/flownet_loader.py | import torch
from torch.nn import functional as F
from PIL import Image
from models.flownet2.models import *
from torchvision import transforms
import matplotlib.pyplot as plt
import argparse
from utils.general import get_gpu_id_with_lowest_memory
class FlownetPipeline:
def __init__(self):
super(Flownet... | 4,882 | 37.753968 | 151 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/utils/metrics.py | import torch
from torch import nn
from torch.nn import functional as F
from torchvision.models import inception_v3
import numpy as np
from scipy import linalg
from skimage.metrics import peak_signal_noise_ratio as compare_psnr
from skimage.metrics import structural_similarity as ssim
from pytorch_lightning.metrics impo... | 12,279 | 33.985755 | 153 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/utils/eval_pretrained.py | import argparse
from os import path
import yaml
import os
from experiments import select_experiment
def create_dir_structure(model_name, base_dir):
subdirs = ["ckpt", "config", "generated", "log"]
structure = {subdir: path.join(base_dir,model_name, subdir) for subdir in subdirs}
[os.makedirs(structure[s... | 2,683 | 38.470588 | 137 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.