id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
221,300
dask/dask-ml
dask_ml/cluster/spectral.py
_slice_mostly_sorted
def _slice_mostly_sorted(array, keep, rest, ind=None): """Slice dask array `array` that is almost entirely sorted already. We perform approximately `2 * len(keep)` slices on `array`. This is OK, since `keep` is small. Individually, each of these slices is entirely sorted. Parameters ----------...
python
def _slice_mostly_sorted(array, keep, rest, ind=None): """Slice dask array `array` that is almost entirely sorted already. We perform approximately `2 * len(keep)` slices on `array`. This is OK, since `keep` is small. Individually, each of these slices is entirely sorted. Parameters ----------...
[ "def", "_slice_mostly_sorted", "(", "array", ",", "keep", ",", "rest", ",", "ind", "=", "None", ")", ":", "if", "ind", "is", "None", ":", "ind", "=", "np", ".", "arange", "(", "len", "(", "array", ")", ")", "idx", "=", "np", ".", "argsort", "(", ...
Slice dask array `array` that is almost entirely sorted already. We perform approximately `2 * len(keep)` slices on `array`. This is OK, since `keep` is small. Individually, each of these slices is entirely sorted. Parameters ---------- array : dask.array.Array keep : ndarray[Int] ...
[ "Slice", "dask", "array", "array", "that", "is", "almost", "entirely", "sorted", "already", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/cluster/spectral.py#L339-L376
221,301
dask/dask-ml
dask_ml/datasets.py
make_counts
def make_counts( n_samples=1000, n_features=100, n_informative=2, scale=1.0, chunks=100, random_state=None, ): """ Generate a dummy dataset for modeling count data. Parameters ---------- n_samples : int number of rows in the output array n_features : int ...
python
def make_counts( n_samples=1000, n_features=100, n_informative=2, scale=1.0, chunks=100, random_state=None, ): """ Generate a dummy dataset for modeling count data. Parameters ---------- n_samples : int number of rows in the output array n_features : int ...
[ "def", "make_counts", "(", "n_samples", "=", "1000", ",", "n_features", "=", "100", ",", "n_informative", "=", "2", ",", "scale", "=", "1.0", ",", "chunks", "=", "100", ",", "random_state", "=", "None", ",", ")", ":", "rng", "=", "dask_ml", ".", "uti...
Generate a dummy dataset for modeling count data. Parameters ---------- n_samples : int number of rows in the output array n_features : int number of columns (features) in the output array n_informative : int number of features that are correlated with the outcome scale ...
[ "Generate", "a", "dummy", "dataset", "for", "modeling", "count", "data", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/datasets.py#L24-L73
221,302
dask/dask-ml
dask_ml/datasets.py
make_blobs
def make_blobs( n_samples=100, n_features=2, centers=None, cluster_std=1.0, center_box=(-10.0, 10.0), shuffle=True, random_state=None, chunks=None, ): """ Generate isotropic Gaussian blobs for clustering. This can be used to generate very large Dask arrays on a cluster of ...
python
def make_blobs( n_samples=100, n_features=2, centers=None, cluster_std=1.0, center_box=(-10.0, 10.0), shuffle=True, random_state=None, chunks=None, ): """ Generate isotropic Gaussian blobs for clustering. This can be used to generate very large Dask arrays on a cluster of ...
[ "def", "make_blobs", "(", "n_samples", "=", "100", ",", "n_features", "=", "2", ",", "centers", "=", "None", ",", "cluster_std", "=", "1.0", ",", "center_box", "=", "(", "-", "10.0", ",", "10.0", ")", ",", "shuffle", "=", "True", ",", "random_state", ...
Generate isotropic Gaussian blobs for clustering. This can be used to generate very large Dask arrays on a cluster of machines. When using Dask in distributed mode, the client machine only needs to allocate a single block's worth of data. Parameters ---------- n_samples : int or array-like, op...
[ "Generate", "isotropic", "Gaussian", "blobs", "for", "clustering", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/datasets.py#L76-L203
221,303
dask/dask-ml
dask_ml/datasets.py
make_regression
def make_regression( n_samples=100, n_features=100, n_informative=10, n_targets=1, bias=0.0, effective_rank=None, tail_strength=0.5, noise=0.0, shuffle=True, coef=False, random_state=None, chunks=None, ): """ Generate a random regression problem. The input se...
python
def make_regression( n_samples=100, n_features=100, n_informative=10, n_targets=1, bias=0.0, effective_rank=None, tail_strength=0.5, noise=0.0, shuffle=True, coef=False, random_state=None, chunks=None, ): """ Generate a random regression problem. The input se...
[ "def", "make_regression", "(", "n_samples", "=", "100", ",", "n_features", "=", "100", ",", "n_informative", "=", "10", ",", "n_targets", "=", "1", ",", "bias", "=", "0.0", ",", "effective_rank", "=", "None", ",", "tail_strength", "=", "0.5", ",", "noise...
Generate a random regression problem. The input set can either be well conditioned (by default) or have a low rank-fat tail singular profile. See :func:`sklearn.datasets.make_low_rank_matrix` for more details. This can be used to generate very large Dask arrays on a cluster of machines. When using...
[ "Generate", "a", "random", "regression", "problem", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/datasets.py#L206-L338
221,304
dask/dask-ml
dask_ml/decomposition/truncated_svd.py
TruncatedSVD.fit_transform
def fit_transform(self, X, y=None): """Fit model to X and perform dimensionality reduction on X. Parameters ---------- X : array-like, shape (n_samples, n_features) Training data. y : Ignored Returns ------- X_new : array, shape (n_samples, ...
python
def fit_transform(self, X, y=None): """Fit model to X and perform dimensionality reduction on X. Parameters ---------- X : array-like, shape (n_samples, n_features) Training data. y : Ignored Returns ------- X_new : array, shape (n_samples, ...
[ "def", "fit_transform", "(", "self", ",", "X", ",", "y", "=", "None", ")", ":", "X", "=", "self", ".", "_check_array", "(", "X", ")", "if", "self", ".", "algorithm", "not", "in", "{", "\"tsqr\"", ",", "\"randomized\"", "}", ":", "raise", "ValueError"...
Fit model to X and perform dimensionality reduction on X. Parameters ---------- X : array-like, shape (n_samples, n_features) Training data. y : Ignored Returns ------- X_new : array, shape (n_samples, n_components) Reduced version of X....
[ "Fit", "model", "to", "X", "and", "perform", "dimensionality", "reduction", "on", "X", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/decomposition/truncated_svd.py#L144-L186
221,305
dask/dask-ml
dask_ml/compose/_column_transformer.py
ColumnTransformer._hstack
def _hstack(self, Xs): """ Stacks X horizontally. Supports input types (X): list of numpy arrays, sparse arrays and DataFrames """ types = set(type(X) for X in Xs) if self.sparse_output_: return sparse.hstack(Xs).tocsr() elif dd.Series in...
python
def _hstack(self, Xs): """ Stacks X horizontally. Supports input types (X): list of numpy arrays, sparse arrays and DataFrames """ types = set(type(X) for X in Xs) if self.sparse_output_: return sparse.hstack(Xs).tocsr() elif dd.Series in...
[ "def", "_hstack", "(", "self", ",", "Xs", ")", ":", "types", "=", "set", "(", "type", "(", "X", ")", "for", "X", "in", "Xs", ")", "if", "self", ".", "sparse_output_", ":", "return", "sparse", ".", "hstack", "(", "Xs", ")", ".", "tocsr", "(", ")...
Stacks X horizontally. Supports input types (X): list of numpy arrays, sparse arrays and DataFrames
[ "Stacks", "X", "horizontally", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/compose/_column_transformer.py#L172-L200
221,306
dask/dask-ml
dask_ml/decomposition/pca.py
PCA.transform
def transform(self, X): """Apply dimensionality reduction on X. X is projected on the first principal components previous extracted from a training set. Parameters ---------- X : array-like, shape (n_samples, n_features) New data, where n_samples in the numb...
python
def transform(self, X): """Apply dimensionality reduction on X. X is projected on the first principal components previous extracted from a training set. Parameters ---------- X : array-like, shape (n_samples, n_features) New data, where n_samples in the numb...
[ "def", "transform", "(", "self", ",", "X", ")", ":", "check_is_fitted", "(", "self", ",", "[", "\"mean_\"", ",", "\"components_\"", "]", ",", "all_or_any", "=", "all", ")", "# X = check_array(X)", "if", "self", ".", "mean_", "is", "not", "None", ":", "X"...
Apply dimensionality reduction on X. X is projected on the first principal components previous extracted from a training set. Parameters ---------- X : array-like, shape (n_samples, n_features) New data, where n_samples in the number of samples and n_fea...
[ "Apply", "dimensionality", "reduction", "on", "X", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/decomposition/pca.py#L319-L344
221,307
dask/dask-ml
dask_ml/decomposition/pca.py
PCA.fit_transform
def fit_transform(self, X, y=None): """Fit the model with X and apply the dimensionality reduction on X. Parameters ---------- X : array-like, shape (n_samples, n_features) New data, where n_samples in the number of samples and n_features is the number of feature...
python
def fit_transform(self, X, y=None): """Fit the model with X and apply the dimensionality reduction on X. Parameters ---------- X : array-like, shape (n_samples, n_features) New data, where n_samples in the number of samples and n_features is the number of feature...
[ "def", "fit_transform", "(", "self", ",", "X", ",", "y", "=", "None", ")", ":", "# X = check_array(X)", "U", ",", "S", ",", "V", "=", "self", ".", "_fit", "(", "X", ")", "U", "=", "U", "[", ":", ",", ":", "self", ".", "n_components_", "]", "if"...
Fit the model with X and apply the dimensionality reduction on X. Parameters ---------- X : array-like, shape (n_samples, n_features) New data, where n_samples in the number of samples and n_features is the number of features. y : Ignored Returns ...
[ "Fit", "the", "model", "with", "X", "and", "apply", "the", "dimensionality", "reduction", "on", "X", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/decomposition/pca.py#L346-L373
221,308
dask/dask-ml
dask_ml/decomposition/pca.py
PCA.inverse_transform
def inverse_transform(self, X): """Transform data back to its original space. Returns an array X_original whose transform would be X. Parameters ---------- X : array-like, shape (n_samples, n_components) New data, where n_samples in the number of samples ...
python
def inverse_transform(self, X): """Transform data back to its original space. Returns an array X_original whose transform would be X. Parameters ---------- X : array-like, shape (n_samples, n_components) New data, where n_samples in the number of samples ...
[ "def", "inverse_transform", "(", "self", ",", "X", ")", ":", "check_is_fitted", "(", "self", ",", "\"mean_\"", ")", "if", "self", ".", "whiten", ":", "return", "(", "da", ".", "dot", "(", "X", ",", "np", ".", "sqrt", "(", "self", ".", "explained_vari...
Transform data back to its original space. Returns an array X_original whose transform would be X. Parameters ---------- X : array-like, shape (n_samples, n_components) New data, where n_samples in the number of samples and n_components is the number of componen...
[ "Transform", "data", "back", "to", "its", "original", "space", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/decomposition/pca.py#L375-L406
221,309
dask/dask-ml
dask_ml/decomposition/pca.py
PCA.score_samples
def score_samples(self, X): """Return the log-likelihood of each sample. See. "Pattern Recognition and Machine Learning" by C. Bishop, 12.2.1 p. 574 or http://www.miketipping.com/papers/met-mppca.pdf Parameters ---------- X : array, shape(n_samples, n_features) ...
python
def score_samples(self, X): """Return the log-likelihood of each sample. See. "Pattern Recognition and Machine Learning" by C. Bishop, 12.2.1 p. 574 or http://www.miketipping.com/papers/met-mppca.pdf Parameters ---------- X : array, shape(n_samples, n_features) ...
[ "def", "score_samples", "(", "self", ",", "X", ")", ":", "check_is_fitted", "(", "self", ",", "\"mean_\"", ")", "# X = check_array(X)", "Xr", "=", "X", "-", "self", ".", "mean_", "n_features", "=", "X", ".", "shape", "[", "1", "]", "precision", "=", "s...
Return the log-likelihood of each sample. See. "Pattern Recognition and Machine Learning" by C. Bishop, 12.2.1 p. 574 or http://www.miketipping.com/papers/met-mppca.pdf Parameters ---------- X : array, shape(n_samples, n_features) The data. Returns ...
[ "Return", "the", "log", "-", "likelihood", "of", "each", "sample", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/decomposition/pca.py#L408-L433
221,310
dask/dask-ml
dask_ml/utils.py
assert_estimator_equal
def assert_estimator_equal(left, right, exclude=None, **kwargs): """Check that two Estimators are equal Parameters ---------- left, right : Estimators exclude : str or sequence of str attributes to skip in the check kwargs : dict Passed through to the dask `assert_eq` method. ...
python
def assert_estimator_equal(left, right, exclude=None, **kwargs): """Check that two Estimators are equal Parameters ---------- left, right : Estimators exclude : str or sequence of str attributes to skip in the check kwargs : dict Passed through to the dask `assert_eq` method. ...
[ "def", "assert_estimator_equal", "(", "left", ",", "right", ",", "exclude", "=", "None", ",", "*", "*", "kwargs", ")", ":", "left_attrs", "=", "[", "x", "for", "x", "in", "dir", "(", "left", ")", "if", "x", ".", "endswith", "(", "\"_\"", ")", "and"...
Check that two Estimators are equal Parameters ---------- left, right : Estimators exclude : str or sequence of str attributes to skip in the check kwargs : dict Passed through to the dask `assert_eq` method.
[ "Check", "that", "two", "Estimators", "are", "equal" ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/utils.py#L58-L84
221,311
dask/dask-ml
dask_ml/utils.py
check_matching_blocks
def check_matching_blocks(*arrays): """Check that the partitioning structure for many arrays matches. Parameters ---------- *arrays : Sequence of array-likes This includes * Dask Array * Dask DataFrame * Dask Series """ if len(arrays) <= 1: return if...
python
def check_matching_blocks(*arrays): """Check that the partitioning structure for many arrays matches. Parameters ---------- *arrays : Sequence of array-likes This includes * Dask Array * Dask DataFrame * Dask Series """ if len(arrays) <= 1: return if...
[ "def", "check_matching_blocks", "(", "*", "arrays", ")", ":", "if", "len", "(", "arrays", ")", "<=", "1", ":", "return", "if", "all", "(", "isinstance", "(", "x", ",", "da", ".", "Array", ")", "for", "x", "in", "arrays", ")", ":", "# TODO: unknown ch...
Check that the partitioning structure for many arrays matches. Parameters ---------- *arrays : Sequence of array-likes This includes * Dask Array * Dask DataFrame * Dask Series
[ "Check", "that", "the", "partitioning", "structure", "for", "many", "arrays", "matches", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/utils.py#L190-L221
221,312
dask/dask-ml
dask_ml/utils.py
check_chunks
def check_chunks(n_samples, n_features, chunks=None): """Validate and normalize the chunks argument for a dask.array Parameters ---------- n_samples, n_features : int Give the shape of the array chunks : int, sequence, optional, default None * For 'chunks=None', this picks a "good" ...
python
def check_chunks(n_samples, n_features, chunks=None): """Validate and normalize the chunks argument for a dask.array Parameters ---------- n_samples, n_features : int Give the shape of the array chunks : int, sequence, optional, default None * For 'chunks=None', this picks a "good" ...
[ "def", "check_chunks", "(", "n_samples", ",", "n_features", ",", "chunks", "=", "None", ")", ":", "if", "chunks", "is", "None", ":", "chunks", "=", "(", "max", "(", "100", ",", "n_samples", "//", "cpu_count", "(", ")", ")", ",", "n_features", ")", "e...
Validate and normalize the chunks argument for a dask.array Parameters ---------- n_samples, n_features : int Give the shape of the array chunks : int, sequence, optional, default None * For 'chunks=None', this picks a "good" default number of chunks based on the number of CPU...
[ "Validate", "and", "normalize", "the", "chunks", "argument", "for", "a", "dask", ".", "array" ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/utils.py#L224-L261
221,313
dask/dask-ml
dask_ml/metrics/scorer.py
get_scorer
def get_scorer(scoring, compute=True): """Get a scorer from string Parameters ---------- scoring : str | callable scoring method as string. If callable it is returned as is. Returns ------- scorer : callable The scorer. """ # This is the same as sklearns, only we us...
python
def get_scorer(scoring, compute=True): """Get a scorer from string Parameters ---------- scoring : str | callable scoring method as string. If callable it is returned as is. Returns ------- scorer : callable The scorer. """ # This is the same as sklearns, only we us...
[ "def", "get_scorer", "(", "scoring", ",", "compute", "=", "True", ")", ":", "# This is the same as sklearns, only we use our SCORERS dict,", "# and don't have back-compat code", "if", "isinstance", "(", "scoring", ",", "six", ".", "string_types", ")", ":", "try", ":", ...
Get a scorer from string Parameters ---------- scoring : str | callable scoring method as string. If callable it is returned as is. Returns ------- scorer : callable The scorer.
[ "Get", "a", "scorer", "from", "string" ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/metrics/scorer.py#L22-L51
221,314
dask/dask-ml
dask_ml/model_selection/utils.py
to_indexable
def to_indexable(*args, **kwargs): """Ensure that all args are an indexable type. Conversion runs lazily for dask objects, immediately otherwise. Parameters ---------- args : array_like or scalar allow_scalars : bool, optional Whether to allow scalars in args. Default is False. """...
python
def to_indexable(*args, **kwargs): """Ensure that all args are an indexable type. Conversion runs lazily for dask objects, immediately otherwise. Parameters ---------- args : array_like or scalar allow_scalars : bool, optional Whether to allow scalars in args. Default is False. """...
[ "def", "to_indexable", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "\"allow_scalars\"", ",", "False", ")", ":", "indexable", "=", "_maybe_indexable", "else", ":", "indexable", "=", "_indexable", "for", "x", "in",...
Ensure that all args are an indexable type. Conversion runs lazily for dask objects, immediately otherwise. Parameters ---------- args : array_like or scalar allow_scalars : bool, optional Whether to allow scalars in args. Default is False.
[ "Ensure", "that", "all", "args", "are", "an", "indexable", "type", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/utils.py#L33-L54
221,315
dask/dask-ml
dask_ml/model_selection/utils.py
_index_param_value
def _index_param_value(num_samples, v, indices): """Private helper function for parameter value indexing. This determines whether a fit parameter `v` to a SearchCV.fit should be indexed along with `X` and `y`. Note that this differs from the scikit-learn version. They pass `X` and compute num_samples. ...
python
def _index_param_value(num_samples, v, indices): """Private helper function for parameter value indexing. This determines whether a fit parameter `v` to a SearchCV.fit should be indexed along with `X` and `y`. Note that this differs from the scikit-learn version. They pass `X` and compute num_samples. ...
[ "def", "_index_param_value", "(", "num_samples", ",", "v", ",", "indices", ")", ":", "if", "not", "_is_arraylike", "(", "v", ")", "or", "_num_samples", "(", "v", ")", "!=", "num_samples", ":", "# pass through: skip indexing", "return", "v", "if", "sp", ".", ...
Private helper function for parameter value indexing. This determines whether a fit parameter `v` to a SearchCV.fit should be indexed along with `X` and `y`. Note that this differs from the scikit-learn version. They pass `X` and compute num_samples. We pass `num_samples` instead.
[ "Private", "helper", "function", "for", "parameter", "value", "indexing", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/utils.py#L57-L70
221,316
dask/dask-ml
dask_ml/model_selection/utils.py
DeprecationDict.add_warning
def add_warning(self, key, *args, **kwargs): """Add a warning to be triggered when the specified key is read Parameters ---------- key : any hashable object The key """ self._deprecations[key] = (args, kwargs)
python
def add_warning(self, key, *args, **kwargs): """Add a warning to be triggered when the specified key is read Parameters ---------- key : any hashable object The key """ self._deprecations[key] = (args, kwargs)
[ "def", "add_warning", "(", "self", ",", "key", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_deprecations", "[", "key", "]", "=", "(", "args", ",", "kwargs", ")" ]
Add a warning to be triggered when the specified key is read Parameters ---------- key : any hashable object The key
[ "Add", "a", "warning", "to", "be", "triggered", "when", "the", "specified", "key", "is", "read" ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/utils.py#L141-L149
221,317
dask/dask-ml
dask_ml/preprocessing/label.py
_construct
def _construct(x, categories): """Make a sparse matrix from an encoded array. >>> construct(np.array([0, 1, 0]), np.array([0, 1])).toarray() array([[1., 0.], [0., 1.], [1., 0.]]) """ # type: (np.ndarray, np.ndarray) -> scipy.sparse.csr_matrix data = np.ones(len(x)) row...
python
def _construct(x, categories): """Make a sparse matrix from an encoded array. >>> construct(np.array([0, 1, 0]), np.array([0, 1])).toarray() array([[1., 0.], [0., 1.], [1., 0.]]) """ # type: (np.ndarray, np.ndarray) -> scipy.sparse.csr_matrix data = np.ones(len(x)) row...
[ "def", "_construct", "(", "x", ",", "categories", ")", ":", "# type: (np.ndarray, np.ndarray) -> scipy.sparse.csr_matrix", "data", "=", "np", ".", "ones", "(", "len", "(", "x", ")", ")", "rows", "=", "np", ".", "arange", "(", "len", "(", "x", ")", ")", "...
Make a sparse matrix from an encoded array. >>> construct(np.array([0, 1, 0]), np.array([0, 1])).toarray() array([[1., 0.], [0., 1.], [1., 0.]])
[ "Make", "a", "sparse", "matrix", "from", "an", "encoded", "array", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/label.py#L224-L238
221,318
dask/dask-ml
dask_ml/preprocessing/label.py
_encode_dask_array
def _encode_dask_array(values, uniques=None, encode=False, onehot_dtype=None): """One-hot or label encode a dask array. Parameters ---------- values : da.Array, shape [n_samples,] unqiques : np.ndarray, shape [n_uniques,] encode : bool, default False Whether to encode the values (True) ...
python
def _encode_dask_array(values, uniques=None, encode=False, onehot_dtype=None): """One-hot or label encode a dask array. Parameters ---------- values : da.Array, shape [n_samples,] unqiques : np.ndarray, shape [n_uniques,] encode : bool, default False Whether to encode the values (True) ...
[ "def", "_encode_dask_array", "(", "values", ",", "uniques", "=", "None", ",", "encode", "=", "False", ",", "onehot_dtype", "=", "None", ")", ":", "if", "uniques", "is", "None", ":", "if", "encode", "and", "onehot_dtype", ":", "raise", "ValueError", "(", ...
One-hot or label encode a dask array. Parameters ---------- values : da.Array, shape [n_samples,] unqiques : np.ndarray, shape [n_uniques,] encode : bool, default False Whether to encode the values (True) or just discover the uniques. onehot_dtype : np.dtype, optional Optional d...
[ "One", "-", "hot", "or", "label", "encode", "a", "dask", "array", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/preprocessing/label.py#L241-L301
221,319
dask/dask-ml
dask_ml/model_selection/methods.py
pipeline
def pipeline(names, steps): """Reconstruct a Pipeline from names and steps""" steps, times = zip(*map(_maybe_timed, steps)) fit_time = sum(times) if any(s is FIT_FAILURE for s in steps): fit_est = FIT_FAILURE else: fit_est = Pipeline(list(zip(names, steps))) return fit_est, fit_t...
python
def pipeline(names, steps): """Reconstruct a Pipeline from names and steps""" steps, times = zip(*map(_maybe_timed, steps)) fit_time = sum(times) if any(s is FIT_FAILURE for s in steps): fit_est = FIT_FAILURE else: fit_est = Pipeline(list(zip(names, steps))) return fit_est, fit_t...
[ "def", "pipeline", "(", "names", ",", "steps", ")", ":", "steps", ",", "times", "=", "zip", "(", "*", "map", "(", "_maybe_timed", ",", "steps", ")", ")", "fit_time", "=", "sum", "(", "times", ")", "if", "any", "(", "s", "is", "FIT_FAILURE", "for", ...
Reconstruct a Pipeline from names and steps
[ "Reconstruct", "a", "Pipeline", "from", "names", "and", "steps" ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/methods.py#L183-L191
221,320
dask/dask-ml
dask_ml/model_selection/methods.py
feature_union
def feature_union(names, steps, weights): """Reconstruct a FeatureUnion from names, steps, and weights""" steps, times = zip(*map(_maybe_timed, steps)) fit_time = sum(times) if any(s is FIT_FAILURE for s in steps): fit_est = FIT_FAILURE else: fit_est = FeatureUnion(list(zip(names, st...
python
def feature_union(names, steps, weights): """Reconstruct a FeatureUnion from names, steps, and weights""" steps, times = zip(*map(_maybe_timed, steps)) fit_time = sum(times) if any(s is FIT_FAILURE for s in steps): fit_est = FIT_FAILURE else: fit_est = FeatureUnion(list(zip(names, st...
[ "def", "feature_union", "(", "names", ",", "steps", ",", "weights", ")", ":", "steps", ",", "times", "=", "zip", "(", "*", "map", "(", "_maybe_timed", ",", "steps", ")", ")", "fit_time", "=", "sum", "(", "times", ")", "if", "any", "(", "s", "is", ...
Reconstruct a FeatureUnion from names, steps, and weights
[ "Reconstruct", "a", "FeatureUnion", "from", "names", "steps", "and", "weights" ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/methods.py#L194-L202
221,321
dask/dask-ml
dask_ml/model_selection/methods.py
feature_union_concat
def feature_union_concat(Xs, nsamples, weights): """Apply weights and concatenate outputs from a FeatureUnion""" if any(x is FIT_FAILURE for x in Xs): return FIT_FAILURE Xs = [X if w is None else X * w for X, w in zip(Xs, weights) if X is not None] if not Xs: return np.zeros((nsamples, 0...
python
def feature_union_concat(Xs, nsamples, weights): """Apply weights and concatenate outputs from a FeatureUnion""" if any(x is FIT_FAILURE for x in Xs): return FIT_FAILURE Xs = [X if w is None else X * w for X, w in zip(Xs, weights) if X is not None] if not Xs: return np.zeros((nsamples, 0...
[ "def", "feature_union_concat", "(", "Xs", ",", "nsamples", ",", "weights", ")", ":", "if", "any", "(", "x", "is", "FIT_FAILURE", "for", "x", "in", "Xs", ")", ":", "return", "FIT_FAILURE", "Xs", "=", "[", "X", "if", "w", "is", "None", "else", "X", "...
Apply weights and concatenate outputs from a FeatureUnion
[ "Apply", "weights", "and", "concatenate", "outputs", "from", "a", "FeatureUnion" ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/methods.py#L205-L214
221,322
dask/dask-ml
dask_ml/model_selection/_split.py
_generate_idx
def _generate_idx(n, seed, n_train, n_test): """Generate train, test indices for a length-n array. Parameters ---------- n : int The length of the array seed : int Seed for a RandomState n_train, n_test : int, 0 < n_train, n_test < n Number of samples to use for the trai...
python
def _generate_idx(n, seed, n_train, n_test): """Generate train, test indices for a length-n array. Parameters ---------- n : int The length of the array seed : int Seed for a RandomState n_train, n_test : int, 0 < n_train, n_test < n Number of samples to use for the trai...
[ "def", "_generate_idx", "(", "n", ",", "seed", ",", "n_train", ",", "n_test", ")", ":", "idx", "=", "check_random_state", "(", "seed", ")", ".", "permutation", "(", "n", ")", "ind_test", "=", "idx", "[", ":", "n_test", "]", "ind_train", "=", "idx", "...
Generate train, test indices for a length-n array. Parameters ---------- n : int The length of the array seed : int Seed for a RandomState n_train, n_test : int, 0 < n_train, n_test < n Number of samples to use for the train or test index. Notes -----
[ "Generate", "train", "test", "indices", "for", "a", "length", "-", "n", "array", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_split.py#L67-L87
221,323
dask/dask-ml
dask_ml/model_selection/_split.py
_blockwise_slice
def _blockwise_slice(arr, idx): """Slice an array that is blockwise-aligned with idx. Parameters ---------- arr : Dask array idx : Dask array Should have the following properties * Same blocks as `arr` along the first dimension * Contains only integers * Each block'...
python
def _blockwise_slice(arr, idx): """Slice an array that is blockwise-aligned with idx. Parameters ---------- arr : Dask array idx : Dask array Should have the following properties * Same blocks as `arr` along the first dimension * Contains only integers * Each block'...
[ "def", "_blockwise_slice", "(", "arr", ",", "idx", ")", ":", "objs", "=", "[", "]", "offsets", "=", "np", ".", "hstack", "(", "[", "0", ",", "np", ".", "cumsum", "(", "arr", ".", "chunks", "[", "0", "]", ")", "[", ":", "-", "1", "]", "]", "...
Slice an array that is blockwise-aligned with idx. Parameters ---------- arr : Dask array idx : Dask array Should have the following properties * Same blocks as `arr` along the first dimension * Contains only integers * Each block's values should be between ``[0, len(bl...
[ "Slice", "an", "array", "that", "is", "blockwise", "-", "aligned", "with", "idx", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/model_selection/_split.py#L317-L356
221,324
dask/dask-ml
dask_ml/feature_extraction/text.py
HashingVectorizer.transform
def transform(self, X): """Transform a sequence of documents to a document-term matrix. Transformation is done in parallel, and correctly handles dask collections. Parameters ---------- X : dask.Bag of raw text documents, length = n_samples Samples. Each sam...
python
def transform(self, X): """Transform a sequence of documents to a document-term matrix. Transformation is done in parallel, and correctly handles dask collections. Parameters ---------- X : dask.Bag of raw text documents, length = n_samples Samples. Each sam...
[ "def", "transform", "(", "self", ",", "X", ")", ":", "msg", "=", "\"'X' should be a 1-dimensional array with length 'num_samples'.\"", "if", "not", "dask", ".", "is_dask_collection", "(", "X", ")", ":", "return", "super", "(", "HashingVectorizer", ",", "self", ")"...
Transform a sequence of documents to a document-term matrix. Transformation is done in parallel, and correctly handles dask collections. Parameters ---------- X : dask.Bag of raw text documents, length = n_samples Samples. Each sample must be a text document (either...
[ "Transform", "a", "sequence", "of", "documents", "to", "a", "document", "-", "term", "matrix", "." ]
cc4837c2c2101f9302cac38354b55754263cd1f3
https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/feature_extraction/text.py#L10-L67
221,325
MIT-LCP/wfdb-python
wfdb/processing/peaks.py
correct_peaks
def correct_peaks(sig, peak_inds, search_radius, smooth_window_size, peak_dir='compare'): """ Adjust a set of detected peaks to coincide with local signal maxima, and Parameters ---------- sig : numpy array The 1d signal array peak_inds : np array Array of ...
python
def correct_peaks(sig, peak_inds, search_radius, smooth_window_size, peak_dir='compare'): """ Adjust a set of detected peaks to coincide with local signal maxima, and Parameters ---------- sig : numpy array The 1d signal array peak_inds : np array Array of ...
[ "def", "correct_peaks", "(", "sig", ",", "peak_inds", ",", "search_radius", ",", "smooth_window_size", ",", "peak_dir", "=", "'compare'", ")", ":", "sig_len", "=", "sig", ".", "shape", "[", "0", "]", "n_peaks", "=", "len", "(", "peak_inds", ")", "# Subtrac...
Adjust a set of detected peaks to coincide with local signal maxima, and Parameters ---------- sig : numpy array The 1d signal array peak_inds : np array Array of the original peak indices max_gap : int The radius within which the original peaks may be shifted. smoot...
[ "Adjust", "a", "set", "of", "detected", "peaks", "to", "coincide", "with", "local", "signal", "maxima", "and" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/peaks.py#L106-L188
221,326
MIT-LCP/wfdb-python
wfdb/processing/peaks.py
shift_peaks
def shift_peaks(sig, peak_inds, search_radius, peak_up): """ Helper function for correct_peaks. Return the shifted peaks to local maxima or minima within a radius. peak_up : bool Whether the expected peak direction is up """ sig_len = sig.shape[0] n_peaks = len(peak_inds) # The ...
python
def shift_peaks(sig, peak_inds, search_radius, peak_up): """ Helper function for correct_peaks. Return the shifted peaks to local maxima or minima within a radius. peak_up : bool Whether the expected peak direction is up """ sig_len = sig.shape[0] n_peaks = len(peak_inds) # The ...
[ "def", "shift_peaks", "(", "sig", ",", "peak_inds", ",", "search_radius", ",", "peak_up", ")", ":", "sig_len", "=", "sig", ".", "shape", "[", "0", "]", "n_peaks", "=", "len", "(", "peak_inds", ")", "# The indices to shift each peak ind by", "shift_inds", "=", ...
Helper function for correct_peaks. Return the shifted peaks to local maxima or minima within a radius. peak_up : bool Whether the expected peak direction is up
[ "Helper", "function", "for", "correct_peaks", ".", "Return", "the", "shifted", "peaks", "to", "local", "maxima", "or", "minima", "within", "a", "radius", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/peaks.py#L191-L223
221,327
MIT-LCP/wfdb-python
wfdb/plot/plot.py
get_plot_dims
def get_plot_dims(signal, ann_samp): "Figure out the number of plot channels" if signal is not None: if signal.ndim == 1: sig_len = len(signal) n_sig = 1 else: sig_len = signal.shape[0] n_sig = signal.shape[1] else: sig_len = 0 ...
python
def get_plot_dims(signal, ann_samp): "Figure out the number of plot channels" if signal is not None: if signal.ndim == 1: sig_len = len(signal) n_sig = 1 else: sig_len = signal.shape[0] n_sig = signal.shape[1] else: sig_len = 0 ...
[ "def", "get_plot_dims", "(", "signal", ",", "ann_samp", ")", ":", "if", "signal", "is", "not", "None", ":", "if", "signal", ".", "ndim", "==", "1", ":", "sig_len", "=", "len", "(", "signal", ")", "n_sig", "=", "1", "else", ":", "sig_len", "=", "sig...
Figure out the number of plot channels
[ "Figure", "out", "the", "number", "of", "plot", "channels" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L125-L143
221,328
MIT-LCP/wfdb-python
wfdb/plot/plot.py
create_figure
def create_figure(n_subplots, figsize): "Create the plot figure and subplot axes" fig = plt.figure(figsize=figsize) axes = [] for i in range(n_subplots): axes.append(fig.add_subplot(n_subplots, 1, i+1)) return fig, axes
python
def create_figure(n_subplots, figsize): "Create the plot figure and subplot axes" fig = plt.figure(figsize=figsize) axes = [] for i in range(n_subplots): axes.append(fig.add_subplot(n_subplots, 1, i+1)) return fig, axes
[ "def", "create_figure", "(", "n_subplots", ",", "figsize", ")", ":", "fig", "=", "plt", ".", "figure", "(", "figsize", "=", "figsize", ")", "axes", "=", "[", "]", "for", "i", "in", "range", "(", "n_subplots", ")", ":", "axes", ".", "append", "(", "...
Create the plot figure and subplot axes
[ "Create", "the", "plot", "figure", "and", "subplot", "axes" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L146-L154
221,329
MIT-LCP/wfdb-python
wfdb/plot/plot.py
plot_signal
def plot_signal(signal, sig_len, n_sig, fs, time_units, sig_style, axes): "Plot signal channels" # Extend signal style if necesary if len(sig_style) == 1: sig_style = n_sig * sig_style # Figure out time indices if time_units == 'samples': t = np.linspace(0, sig_len-1, sig_len) ...
python
def plot_signal(signal, sig_len, n_sig, fs, time_units, sig_style, axes): "Plot signal channels" # Extend signal style if necesary if len(sig_style) == 1: sig_style = n_sig * sig_style # Figure out time indices if time_units == 'samples': t = np.linspace(0, sig_len-1, sig_len) ...
[ "def", "plot_signal", "(", "signal", ",", "sig_len", ",", "n_sig", ",", "fs", ",", "time_units", ",", "sig_style", ",", "axes", ")", ":", "# Extend signal style if necesary", "if", "len", "(", "sig_style", ")", "==", "1", ":", "sig_style", "=", "n_sig", "*...
Plot signal channels
[ "Plot", "signal", "channels" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L157-L177
221,330
MIT-LCP/wfdb-python
wfdb/plot/plot.py
plot_annotation
def plot_annotation(ann_samp, n_annot, ann_sym, signal, n_sig, fs, time_units, ann_style, axes): "Plot annotations, possibly overlaid on signals" # Extend annotation style if necesary if len(ann_style) == 1: ann_style = n_annot * ann_style # Figure out downsample factor for ...
python
def plot_annotation(ann_samp, n_annot, ann_sym, signal, n_sig, fs, time_units, ann_style, axes): "Plot annotations, possibly overlaid on signals" # Extend annotation style if necesary if len(ann_style) == 1: ann_style = n_annot * ann_style # Figure out downsample factor for ...
[ "def", "plot_annotation", "(", "ann_samp", ",", "n_annot", ",", "ann_sym", ",", "signal", ",", "n_sig", ",", "fs", ",", "time_units", ",", "ann_style", ",", "axes", ")", ":", "# Extend annotation style if necesary", "if", "len", "(", "ann_style", ")", "==", ...
Plot annotations, possibly overlaid on signals
[ "Plot", "annotations", "possibly", "overlaid", "on", "signals" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L180-L214
221,331
MIT-LCP/wfdb-python
wfdb/plot/plot.py
plot_ecg_grids
def plot_ecg_grids(ecg_grids, fs, units, time_units, axes): "Add ecg grids to the axes" if ecg_grids == 'all': ecg_grids = range(0, len(axes)) for ch in ecg_grids: # Get the initial plot limits auto_xlims = axes[ch].get_xlim() auto_ylims= axes[ch].get_ylim() (major...
python
def plot_ecg_grids(ecg_grids, fs, units, time_units, axes): "Add ecg grids to the axes" if ecg_grids == 'all': ecg_grids = range(0, len(axes)) for ch in ecg_grids: # Get the initial plot limits auto_xlims = axes[ch].get_xlim() auto_ylims= axes[ch].get_ylim() (major...
[ "def", "plot_ecg_grids", "(", "ecg_grids", ",", "fs", ",", "units", ",", "time_units", ",", "axes", ")", ":", "if", "ecg_grids", "==", "'all'", ":", "ecg_grids", "=", "range", "(", "0", ",", "len", "(", "axes", ")", ")", "for", "ch", "in", "ecg_grids...
Add ecg grids to the axes
[ "Add", "ecg", "grids", "to", "the", "axes" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L217-L251
221,332
MIT-LCP/wfdb-python
wfdb/plot/plot.py
calc_ecg_grids
def calc_ecg_grids(minsig, maxsig, sig_units, fs, maxt, time_units): """ Calculate tick intervals for ecg grids - 5mm 0.2s major grids, 0.04s minor grids - 0.5mV major grids, 0.125 minor grids 10 mm is equal to 1mV in voltage. """ # Get the grid interval of the x axis if time_units == ...
python
def calc_ecg_grids(minsig, maxsig, sig_units, fs, maxt, time_units): """ Calculate tick intervals for ecg grids - 5mm 0.2s major grids, 0.04s minor grids - 0.5mV major grids, 0.125 minor grids 10 mm is equal to 1mV in voltage. """ # Get the grid interval of the x axis if time_units == ...
[ "def", "calc_ecg_grids", "(", "minsig", ",", "maxsig", ",", "sig_units", ",", "fs", ",", "maxt", ",", "time_units", ")", ":", "# Get the grid interval of the x axis", "if", "time_units", "==", "'samples'", ":", "majorx", "=", "0.2", "*", "fs", "minorx", "=", ...
Calculate tick intervals for ecg grids - 5mm 0.2s major grids, 0.04s minor grids - 0.5mV major grids, 0.125 minor grids 10 mm is equal to 1mV in voltage.
[ "Calculate", "tick", "intervals", "for", "ecg", "grids" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L253-L297
221,333
MIT-LCP/wfdb-python
wfdb/plot/plot.py
label_figure
def label_figure(axes, n_subplots, time_units, sig_name, sig_units, ylabel, title): "Add title, and axes labels" if title: axes[0].set_title(title) # Determine y label # Explicit labels take precedence if present. Otherwise, construct labels # using signal names and units ...
python
def label_figure(axes, n_subplots, time_units, sig_name, sig_units, ylabel, title): "Add title, and axes labels" if title: axes[0].set_title(title) # Determine y label # Explicit labels take precedence if present. Otherwise, construct labels # using signal names and units ...
[ "def", "label_figure", "(", "axes", ",", "n_subplots", ",", "time_units", ",", "sig_name", ",", "sig_units", ",", "ylabel", ",", "title", ")", ":", "if", "title", ":", "axes", "[", "0", "]", ".", "set_title", "(", "title", ")", "# Determine y label", "# ...
Add title, and axes labels
[ "Add", "title", "and", "axes", "labels" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L300-L329
221,334
MIT-LCP/wfdb-python
wfdb/plot/plot.py
get_wfdb_plot_items
def get_wfdb_plot_items(record, annotation, plot_sym): """ Get items to plot from wfdb objects """ # Get record attributes if record: if record.p_signal is not None: signal = record.p_signal elif record.d_signal is not None: signal = record.d_signal el...
python
def get_wfdb_plot_items(record, annotation, plot_sym): """ Get items to plot from wfdb objects """ # Get record attributes if record: if record.p_signal is not None: signal = record.p_signal elif record.d_signal is not None: signal = record.d_signal el...
[ "def", "get_wfdb_plot_items", "(", "record", ",", "annotation", ",", "plot_sym", ")", ":", "# Get record attributes", "if", "record", ":", "if", "record", ".", "p_signal", "is", "not", "None", ":", "signal", "=", "record", ".", "p_signal", "elif", "record", ...
Get items to plot from wfdb objects
[ "Get", "items", "to", "plot", "from", "wfdb", "objects" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/plot/plot.py#L417-L510
221,335
MIT-LCP/wfdb-python
wfdb/io/download.py
_remote_file_size
def _remote_file_size(url=None, file_name=None, pb_dir=None): """ Get the remote file size in bytes Parameters ---------- url : str, optional The full url of the file. Use this option to explicitly state the full url. file_name : str, optional The base file name. Use thi...
python
def _remote_file_size(url=None, file_name=None, pb_dir=None): """ Get the remote file size in bytes Parameters ---------- url : str, optional The full url of the file. Use this option to explicitly state the full url. file_name : str, optional The base file name. Use thi...
[ "def", "_remote_file_size", "(", "url", "=", "None", ",", "file_name", "=", "None", ",", "pb_dir", "=", "None", ")", ":", "# Option to construct the url", "if", "file_name", "and", "pb_dir", ":", "url", "=", "posixpath", ".", "join", "(", "config", ".", "d...
Get the remote file size in bytes Parameters ---------- url : str, optional The full url of the file. Use this option to explicitly state the full url. file_name : str, optional The base file name. Use this argument along with pb_dir if you want the full url to be constr...
[ "Get", "the", "remote", "file", "size", "in", "bytes" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L35-L69
221,336
MIT-LCP/wfdb-python
wfdb/io/download.py
_stream_header
def _stream_header(file_name, pb_dir): """ Stream the lines of a remote header file. Parameters ---------- file_name : str pb_dir : str The Physiobank database directory from which to find the required header file. eg. For file '100.hea' in 'http://physionet.org/physiob...
python
def _stream_header(file_name, pb_dir): """ Stream the lines of a remote header file. Parameters ---------- file_name : str pb_dir : str The Physiobank database directory from which to find the required header file. eg. For file '100.hea' in 'http://physionet.org/physiob...
[ "def", "_stream_header", "(", "file_name", ",", "pb_dir", ")", ":", "# Full url of header location", "url", "=", "posixpath", ".", "join", "(", "config", ".", "db_index_url", ",", "pb_dir", ",", "file_name", ")", "response", "=", "requests", ".", "get", "(", ...
Stream the lines of a remote header file. Parameters ---------- file_name : str pb_dir : str The Physiobank database directory from which to find the required header file. eg. For file '100.hea' in 'http://physionet.org/physiobank/database/mitdb', pb_dir='mitdb'.
[ "Stream", "the", "lines", "of", "a", "remote", "header", "file", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L71-L115
221,337
MIT-LCP/wfdb-python
wfdb/io/download.py
_stream_dat
def _stream_dat(file_name, pb_dir, byte_count, start_byte, dtype): """ Stream data from a remote dat file, into a 1d numpy array. Parameters ---------- file_name : str The name of the dat file to be read. pb_dir : str The physiobank directory where the dat file is located. b...
python
def _stream_dat(file_name, pb_dir, byte_count, start_byte, dtype): """ Stream data from a remote dat file, into a 1d numpy array. Parameters ---------- file_name : str The name of the dat file to be read. pb_dir : str The physiobank directory where the dat file is located. b...
[ "def", "_stream_dat", "(", "file_name", ",", "pb_dir", ",", "byte_count", ",", "start_byte", ",", "dtype", ")", ":", "# Full url of dat file", "url", "=", "posixpath", ".", "join", "(", "config", ".", "db_index_url", ",", "pb_dir", ",", "file_name", ")", "# ...
Stream data from a remote dat file, into a 1d numpy array. Parameters ---------- file_name : str The name of the dat file to be read. pb_dir : str The physiobank directory where the dat file is located. byte_count : int The number of bytes to be read. start_byte : int ...
[ "Stream", "data", "from", "a", "remote", "dat", "file", "into", "a", "1d", "numpy", "array", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L118-L159
221,338
MIT-LCP/wfdb-python
wfdb/io/download.py
_stream_annotation
def _stream_annotation(file_name, pb_dir): """ Stream an entire remote annotation file from physiobank Parameters ---------- file_name : str The name of the annotation file to be read. pb_dir : str The physiobank directory where the annotation file is located. """ # Ful...
python
def _stream_annotation(file_name, pb_dir): """ Stream an entire remote annotation file from physiobank Parameters ---------- file_name : str The name of the annotation file to be read. pb_dir : str The physiobank directory where the annotation file is located. """ # Ful...
[ "def", "_stream_annotation", "(", "file_name", ",", "pb_dir", ")", ":", "# Full url of annotation file", "url", "=", "posixpath", ".", "join", "(", "config", ".", "db_index_url", ",", "pb_dir", ",", "file_name", ")", "# Get the content", "response", "=", "requests...
Stream an entire remote annotation file from physiobank Parameters ---------- file_name : str The name of the annotation file to be read. pb_dir : str The physiobank directory where the annotation file is located.
[ "Stream", "an", "entire", "remote", "annotation", "file", "from", "physiobank" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L162-L185
221,339
MIT-LCP/wfdb-python
wfdb/io/download.py
get_dbs
def get_dbs(): """ Get a list of all the Physiobank databases available. Examples -------- >>> dbs = get_dbs() """ url = posixpath.join(config.db_index_url, 'DBS') response = requests.get(url) dbs = response.content.decode('ascii').splitlines() dbs = [re.sub('\t{2,}', '\t', li...
python
def get_dbs(): """ Get a list of all the Physiobank databases available. Examples -------- >>> dbs = get_dbs() """ url = posixpath.join(config.db_index_url, 'DBS') response = requests.get(url) dbs = response.content.decode('ascii').splitlines() dbs = [re.sub('\t{2,}', '\t', li...
[ "def", "get_dbs", "(", ")", ":", "url", "=", "posixpath", ".", "join", "(", "config", ".", "db_index_url", ",", "'DBS'", ")", "response", "=", "requests", ".", "get", "(", "url", ")", "dbs", "=", "response", ".", "content", ".", "decode", "(", "'asci...
Get a list of all the Physiobank databases available. Examples -------- >>> dbs = get_dbs()
[ "Get", "a", "list", "of", "all", "the", "Physiobank", "databases", "available", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L188-L203
221,340
MIT-LCP/wfdb-python
wfdb/io/download.py
get_record_list
def get_record_list(db_dir, records='all'): """ Get a list of records belonging to a database. Parameters ---------- db_dir : str The database directory, usually the same as the database slug. The location to look for a RECORDS file. records : list, optional A Option use...
python
def get_record_list(db_dir, records='all'): """ Get a list of records belonging to a database. Parameters ---------- db_dir : str The database directory, usually the same as the database slug. The location to look for a RECORDS file. records : list, optional A Option use...
[ "def", "get_record_list", "(", "db_dir", ",", "records", "=", "'all'", ")", ":", "# Full url physiobank database", "db_url", "=", "posixpath", ".", "join", "(", "config", ".", "db_index_url", ",", "db_dir", ")", "# Check for a RECORDS file", "if", "records", "==",...
Get a list of records belonging to a database. Parameters ---------- db_dir : str The database directory, usually the same as the database slug. The location to look for a RECORDS file. records : list, optional A Option used when this function acts as a helper function. ...
[ "Get", "a", "list", "of", "records", "belonging", "to", "a", "database", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L208-L241
221,341
MIT-LCP/wfdb-python
wfdb/io/download.py
make_local_dirs
def make_local_dirs(dl_dir, dl_inputs, keep_subdirs): """ Make any required local directories to prepare for downloading """ # Make the local download dir if it doesn't exist if not os.path.isdir(dl_dir): os.makedirs(dl_dir) print('Created local base download directory: %s' % dl_dir...
python
def make_local_dirs(dl_dir, dl_inputs, keep_subdirs): """ Make any required local directories to prepare for downloading """ # Make the local download dir if it doesn't exist if not os.path.isdir(dl_dir): os.makedirs(dl_dir) print('Created local base download directory: %s' % dl_dir...
[ "def", "make_local_dirs", "(", "dl_dir", ",", "dl_inputs", ",", "keep_subdirs", ")", ":", "# Make the local download dir if it doesn't exist", "if", "not", "os", ".", "path", ".", "isdir", "(", "dl_dir", ")", ":", "os", ".", "makedirs", "(", "dl_dir", ")", "pr...
Make any required local directories to prepare for downloading
[ "Make", "any", "required", "local", "directories", "to", "prepare", "for", "downloading" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L277-L294
221,342
MIT-LCP/wfdb-python
wfdb/io/download.py
dl_pb_file
def dl_pb_file(inputs): """ Download a file from physiobank. The input args are to be unpacked for the use of multiprocessing map, because python2 doesn't have starmap... """ basefile, subdir, db, dl_dir, keep_subdirs, overwrite = inputs # Full url of file url = posixpath.join(config...
python
def dl_pb_file(inputs): """ Download a file from physiobank. The input args are to be unpacked for the use of multiprocessing map, because python2 doesn't have starmap... """ basefile, subdir, db, dl_dir, keep_subdirs, overwrite = inputs # Full url of file url = posixpath.join(config...
[ "def", "dl_pb_file", "(", "inputs", ")", ":", "basefile", ",", "subdir", ",", "db", ",", "dl_dir", ",", "keep_subdirs", ",", "overwrite", "=", "inputs", "# Full url of file", "url", "=", "posixpath", ".", "join", "(", "config", ".", "db_index_url", ",", "d...
Download a file from physiobank. The input args are to be unpacked for the use of multiprocessing map, because python2 doesn't have starmap...
[ "Download", "a", "file", "from", "physiobank", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L297-L349
221,343
MIT-LCP/wfdb-python
wfdb/io/download.py
dl_full_file
def dl_full_file(url, save_file_name): """ Download a file. No checks are performed. Parameters ---------- url : str The url of the file to download save_file_name : str The name to save the file as """ response = requests.get(url) with open(save_file_name, 'wb') as...
python
def dl_full_file(url, save_file_name): """ Download a file. No checks are performed. Parameters ---------- url : str The url of the file to download save_file_name : str The name to save the file as """ response = requests.get(url) with open(save_file_name, 'wb') as...
[ "def", "dl_full_file", "(", "url", ",", "save_file_name", ")", ":", "response", "=", "requests", ".", "get", "(", "url", ")", "with", "open", "(", "save_file_name", ",", "'wb'", ")", "as", "writefile", ":", "writefile", ".", "write", "(", "response", "."...
Download a file. No checks are performed. Parameters ---------- url : str The url of the file to download save_file_name : str The name to save the file as
[ "Download", "a", "file", ".", "No", "checks", "are", "performed", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L352-L368
221,344
MIT-LCP/wfdb-python
wfdb/io/download.py
dl_files
def dl_files(db, dl_dir, files, keep_subdirs=True, overwrite=False): """ Download specified files from a Physiobank database. Parameters ---------- db : str The Physiobank database directory to download. eg. For database: 'http://physionet.org/physiobank/database/mitdb', db='mitdb'....
python
def dl_files(db, dl_dir, files, keep_subdirs=True, overwrite=False): """ Download specified files from a Physiobank database. Parameters ---------- db : str The Physiobank database directory to download. eg. For database: 'http://physionet.org/physiobank/database/mitdb', db='mitdb'....
[ "def", "dl_files", "(", "db", ",", "dl_dir", ",", "files", ",", "keep_subdirs", "=", "True", ",", "overwrite", "=", "False", ")", ":", "# Full url physiobank database", "db_url", "=", "posixpath", ".", "join", "(", "config", ".", "db_index_url", ",", "db", ...
Download specified files from a Physiobank database. Parameters ---------- db : str The Physiobank database directory to download. eg. For database: 'http://physionet.org/physiobank/database/mitdb', db='mitdb'. dl_dir : str The full local directory path in which to download the ...
[ "Download", "specified", "files", "from", "a", "Physiobank", "database", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/download.py#L371-L425
221,345
MIT-LCP/wfdb-python
wfdb/io/annotation.py
label_triplets_to_df
def label_triplets_to_df(triplets): """ Get a pd dataframe from a tuple triplets used to define annotation labels. The triplets should come in the form: (label_store, symbol, description) """ label_df = pd.DataFrame({'label_store':np.array([t[0] for t in triplets], ...
python
def label_triplets_to_df(triplets): """ Get a pd dataframe from a tuple triplets used to define annotation labels. The triplets should come in the form: (label_store, symbol, description) """ label_df = pd.DataFrame({'label_store':np.array([t[0] for t in triplets], ...
[ "def", "label_triplets_to_df", "(", "triplets", ")", ":", "label_df", "=", "pd", ".", "DataFrame", "(", "{", "'label_store'", ":", "np", ".", "array", "(", "[", "t", "[", "0", "]", "for", "t", "in", "triplets", "]", ",", "dtype", "=", "'int'", ")", ...
Get a pd dataframe from a tuple triplets used to define annotation labels. The triplets should come in the form: (label_store, symbol, description)
[ "Get", "a", "pd", "dataframe", "from", "a", "tuple", "triplets", "used", "to", "define", "annotation", "labels", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L925-L942
221,346
MIT-LCP/wfdb-python
wfdb/io/annotation.py
wrann
def wrann(record_name, extension, sample, symbol=None, subtype=None, chan=None, num=None, aux_note=None, label_store=None, fs=None, custom_labels=None, write_dir=''): """ Write a WFDB annotation file. Specify at least the following: - The record name of the WFDB record (record_name...
python
def wrann(record_name, extension, sample, symbol=None, subtype=None, chan=None, num=None, aux_note=None, label_store=None, fs=None, custom_labels=None, write_dir=''): """ Write a WFDB annotation file. Specify at least the following: - The record name of the WFDB record (record_name...
[ "def", "wrann", "(", "record_name", ",", "extension", ",", "sample", ",", "symbol", "=", "None", ",", "subtype", "=", "None", ",", "chan", "=", "None", ",", "num", "=", "None", ",", "aux_note", "=", "None", ",", "label_store", "=", "None", ",", "fs",...
Write a WFDB annotation file. Specify at least the following: - The record name of the WFDB record (record_name) - The annotation file extension (extension) - The annotation locations in samples relative to the beginning of the record (sample) - Either the numerical values used to store the ...
[ "Write", "a", "WFDB", "annotation", "file", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L1057-L1168
221,347
MIT-LCP/wfdb-python
wfdb/io/annotation.py
rdann
def rdann(record_name, extension, sampfrom=0, sampto=None, shift_samps=False, pb_dir=None, return_label_elements=['symbol'], summarize_labels=False): """ Read a WFDB annotation file record_name.extension and return an Annotation object. Parameters ---------- record_name : st...
python
def rdann(record_name, extension, sampfrom=0, sampto=None, shift_samps=False, pb_dir=None, return_label_elements=['symbol'], summarize_labels=False): """ Read a WFDB annotation file record_name.extension and return an Annotation object. Parameters ---------- record_name : st...
[ "def", "rdann", "(", "record_name", ",", "extension", ",", "sampfrom", "=", "0", ",", "sampto", "=", "None", ",", "shift_samps", "=", "False", ",", "pb_dir", "=", "None", ",", "return_label_elements", "=", "[", "'symbol'", "]", ",", "summarize_labels", "="...
Read a WFDB annotation file record_name.extension and return an Annotation object. Parameters ---------- record_name : str The record name of the WFDB annotation file. ie. for file '100.atr', record_name='100'. extension : str The annotatator extension of the annotation file...
[ "Read", "a", "WFDB", "annotation", "file", "record_name", ".", "extension", "and", "return", "an", "Annotation", "object", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L1196-L1315
221,348
MIT-LCP/wfdb-python
wfdb/io/annotation.py
update_extra_fields
def update_extra_fields(subtype, chan, num, aux_note, update): """ Update the field if the current annotation did not provide a value. - aux_note and sub are set to default values if missing. - chan and num copy over previous value if missing. """ if update['subtype']: subtype.appe...
python
def update_extra_fields(subtype, chan, num, aux_note, update): """ Update the field if the current annotation did not provide a value. - aux_note and sub are set to default values if missing. - chan and num copy over previous value if missing. """ if update['subtype']: subtype.appe...
[ "def", "update_extra_fields", "(", "subtype", ",", "chan", ",", "num", ",", "aux_note", ",", "update", ")", ":", "if", "update", "[", "'subtype'", "]", ":", "subtype", ".", "append", "(", "0", ")", "if", "update", "[", "'chan'", "]", ":", "if", "chan...
Update the field if the current annotation did not provide a value. - aux_note and sub are set to default values if missing. - chan and num copy over previous value if missing.
[ "Update", "the", "field", "if", "the", "current", "annotation", "did", "not", "provide", "a", "value", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L1471-L1497
221,349
MIT-LCP/wfdb-python
wfdb/io/annotation.py
get_special_inds
def get_special_inds(sample, label_store, aux_note): """ Get the indices of annotations that hold definition information about the entire annotation file, and other empty annotations to be removed. Note: There is no need to deal with SKIP annotations (label_store=59) which were already dealt ...
python
def get_special_inds(sample, label_store, aux_note): """ Get the indices of annotations that hold definition information about the entire annotation file, and other empty annotations to be removed. Note: There is no need to deal with SKIP annotations (label_store=59) which were already dealt ...
[ "def", "get_special_inds", "(", "sample", ",", "label_store", ",", "aux_note", ")", ":", "s0_inds", "=", "np", ".", "where", "(", "sample", "==", "np", ".", "int64", "(", "0", ")", ")", "[", "0", "]", "note_inds", "=", "np", ".", "where", "(", "lab...
Get the indices of annotations that hold definition information about the entire annotation file, and other empty annotations to be removed. Note: There is no need to deal with SKIP annotations (label_store=59) which were already dealt with in proc_core_fields and hence not included here.
[ "Get", "the", "indices", "of", "annotations", "that", "hold", "definition", "information", "about", "the", "entire", "annotation", "file", "and", "other", "empty", "annotations", "to", "be", "removed", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L1504-L1526
221,350
MIT-LCP/wfdb-python
wfdb/io/annotation.py
rm_empty_indices
def rm_empty_indices(*args): """ Remove unwanted list indices. First argument is the list of indices to remove. Other elements are the lists to trim. """ rm_inds = args[0] if not rm_inds: return args[1:] keep_inds = [i for i in range(len(args[1])) if i not in rm_inds] retu...
python
def rm_empty_indices(*args): """ Remove unwanted list indices. First argument is the list of indices to remove. Other elements are the lists to trim. """ rm_inds = args[0] if not rm_inds: return args[1:] keep_inds = [i for i in range(len(args[1])) if i not in rm_inds] retu...
[ "def", "rm_empty_indices", "(", "*", "args", ")", ":", "rm_inds", "=", "args", "[", "0", "]", "if", "not", "rm_inds", ":", "return", "args", "[", "1", ":", "]", "keep_inds", "=", "[", "i", "for", "i", "in", "range", "(", "len", "(", "args", "[", ...
Remove unwanted list indices. First argument is the list of indices to remove. Other elements are the lists to trim.
[ "Remove", "unwanted", "list", "indices", ".", "First", "argument", "is", "the", "list", "of", "indices", "to", "remove", ".", "Other", "elements", "are", "the", "lists", "to", "trim", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L1567-L1580
221,351
MIT-LCP/wfdb-python
wfdb/io/annotation.py
Annotation.apply_range
def apply_range(self, sampfrom=0, sampto=None): """ Filter the annotation attributes to keep only items between the desired sample values """ sampto = sampto or self.sample[-1] kept_inds = np.intersect1d(np.where(self.sample>=sampfrom), ...
python
def apply_range(self, sampfrom=0, sampto=None): """ Filter the annotation attributes to keep only items between the desired sample values """ sampto = sampto or self.sample[-1] kept_inds = np.intersect1d(np.where(self.sample>=sampfrom), ...
[ "def", "apply_range", "(", "self", ",", "sampfrom", "=", "0", ",", "sampto", "=", "None", ")", ":", "sampto", "=", "sampto", "or", "self", ".", "sample", "[", "-", "1", "]", "kept_inds", "=", "np", ".", "intersect1d", "(", "np", ".", "where", "(", ...
Filter the annotation attributes to keep only items between the desired sample values
[ "Filter", "the", "annotation", "attributes", "to", "keep", "only", "items", "between", "the", "desired", "sample", "values" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L134-L151
221,352
MIT-LCP/wfdb-python
wfdb/io/annotation.py
Annotation.wrann
def wrann(self, write_fs=False, write_dir=''): """ Write a WFDB annotation file from this object. Parameters ---------- write_fs : bool, optional Whether to write the `fs` attribute to the file. """ for field in ['record_name', 'extension']: ...
python
def wrann(self, write_fs=False, write_dir=''): """ Write a WFDB annotation file from this object. Parameters ---------- write_fs : bool, optional Whether to write the `fs` attribute to the file. """ for field in ['record_name', 'extension']: ...
[ "def", "wrann", "(", "self", ",", "write_fs", "=", "False", ",", "write_dir", "=", "''", ")", ":", "for", "field", "in", "[", "'record_name'", ",", "'extension'", "]", ":", "if", "getattr", "(", "self", ",", "field", ")", "is", "None", ":", "raise", ...
Write a WFDB annotation file from this object. Parameters ---------- write_fs : bool, optional Whether to write the `fs` attribute to the file.
[ "Write", "a", "WFDB", "annotation", "file", "from", "this", "object", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L153-L191
221,353
MIT-LCP/wfdb-python
wfdb/io/annotation.py
Annotation.get_label_fields
def get_label_fields(self): """ Get the present label fields in the object """ present_label_fields = [] for field in ann_label_fields: if getattr(self, field) is not None: present_label_fields.append(field) return present_label_fields
python
def get_label_fields(self): """ Get the present label fields in the object """ present_label_fields = [] for field in ann_label_fields: if getattr(self, field) is not None: present_label_fields.append(field) return present_label_fields
[ "def", "get_label_fields", "(", "self", ")", ":", "present_label_fields", "=", "[", "]", "for", "field", "in", "ann_label_fields", ":", "if", "getattr", "(", "self", ",", "field", ")", "is", "not", "None", ":", "present_label_fields", ".", "append", "(", "...
Get the present label fields in the object
[ "Get", "the", "present", "label", "fields", "in", "the", "object" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L193-L202
221,354
MIT-LCP/wfdb-python
wfdb/io/annotation.py
Annotation.check_field_cohesion
def check_field_cohesion(self, present_label_fields): """ Check that the content and structure of different fields are consistent with one another. """ # Ensure all written annotation fields have the same length nannots = len(self.sample) for field in ['sample', ...
python
def check_field_cohesion(self, present_label_fields): """ Check that the content and structure of different fields are consistent with one another. """ # Ensure all written annotation fields have the same length nannots = len(self.sample) for field in ['sample', ...
[ "def", "check_field_cohesion", "(", "self", ",", "present_label_fields", ")", ":", "# Ensure all written annotation fields have the same length", "nannots", "=", "len", "(", "self", ".", "sample", ")", "for", "field", "in", "[", "'sample'", ",", "'num'", ",", "'subt...
Check that the content and structure of different fields are consistent with one another.
[ "Check", "that", "the", "content", "and", "structure", "of", "different", "fields", "are", "consistent", "with", "one", "another", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L361-L386
221,355
MIT-LCP/wfdb-python
wfdb/io/annotation.py
Annotation.get_available_label_stores
def get_available_label_stores(self, usefield='tryall'): """ Get the label store values that may be used for writing this annotation. Available store values include: - the undefined values in the standard wfdb labels - the store values not used in the current a...
python
def get_available_label_stores(self, usefield='tryall'): """ Get the label store values that may be used for writing this annotation. Available store values include: - the undefined values in the standard wfdb labels - the store values not used in the current a...
[ "def", "get_available_label_stores", "(", "self", ",", "usefield", "=", "'tryall'", ")", ":", "# Figure out which field to use to get available labels stores.", "if", "usefield", "==", "'tryall'", ":", "if", "self", ".", "label_store", "is", "not", "None", ":", "usefi...
Get the label store values that may be used for writing this annotation. Available store values include: - the undefined values in the standard wfdb labels - the store values not used in the current annotation object. - the store values whose standard wfdb symbols/desc...
[ "Get", "the", "label", "store", "values", "that", "may", "be", "used", "for", "writing", "this", "annotation", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L463-L527
221,356
MIT-LCP/wfdb-python
wfdb/io/annotation.py
Annotation.get_custom_label_attribute
def get_custom_label_attribute(self, attribute): """ Get a list of the custom_labels attribute. ie. label_store, symbol, or description. The custom_labels variable could be in a number of formats """ if attribute not in ann_label_fields: raise ValueE...
python
def get_custom_label_attribute(self, attribute): """ Get a list of the custom_labels attribute. ie. label_store, symbol, or description. The custom_labels variable could be in a number of formats """ if attribute not in ann_label_fields: raise ValueE...
[ "def", "get_custom_label_attribute", "(", "self", ",", "attribute", ")", ":", "if", "attribute", "not", "in", "ann_label_fields", ":", "raise", "ValueError", "(", "'Invalid attribute specified'", ")", "if", "isinstance", "(", "self", ".", "custom_labels", ",", "pd...
Get a list of the custom_labels attribute. ie. label_store, symbol, or description. The custom_labels variable could be in a number of formats
[ "Get", "a", "list", "of", "the", "custom_labels", "attribute", ".", "ie", ".", "label_store", "symbol", "or", "description", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L530-L562
221,357
MIT-LCP/wfdb-python
wfdb/io/annotation.py
Annotation.create_label_map
def create_label_map(self, inplace=True): """ Creates mapping df based on ann_label_table and self.custom_labels. Table composed of entire WFDB standard annotation table, overwritten/appended with custom_labels if any. Sets __label_map__ attribute, or returns value. """ ...
python
def create_label_map(self, inplace=True): """ Creates mapping df based on ann_label_table and self.custom_labels. Table composed of entire WFDB standard annotation table, overwritten/appended with custom_labels if any. Sets __label_map__ attribute, or returns value. """ ...
[ "def", "create_label_map", "(", "self", ",", "inplace", "=", "True", ")", ":", "label_map", "=", "ann_label_table", ".", "copy", "(", ")", "if", "self", ".", "custom_labels", "is", "not", "None", ":", "self", ".", "standardize_custom_labels", "(", ")", "fo...
Creates mapping df based on ann_label_table and self.custom_labels. Table composed of entire WFDB standard annotation table, overwritten/appended with custom_labels if any. Sets __label_map__ attribute, or returns value.
[ "Creates", "mapping", "df", "based", "on", "ann_label_table", "and", "self", ".", "custom_labels", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L565-L583
221,358
MIT-LCP/wfdb-python
wfdb/io/annotation.py
Annotation.wr_ann_file
def wr_ann_file(self, write_fs, write_dir=''): """ Calculate the bytes used to encode an annotation set and write them to an annotation file """ # Calculate the fs bytes to write if present and desired to write if write_fs: fs_bytes = self.calc_fs_bytes() ...
python
def wr_ann_file(self, write_fs, write_dir=''): """ Calculate the bytes used to encode an annotation set and write them to an annotation file """ # Calculate the fs bytes to write if present and desired to write if write_fs: fs_bytes = self.calc_fs_bytes() ...
[ "def", "wr_ann_file", "(", "self", ",", "write_fs", ",", "write_dir", "=", "''", ")", ":", "# Calculate the fs bytes to write if present and desired to write", "if", "write_fs", ":", "fs_bytes", "=", "self", ".", "calc_fs_bytes", "(", ")", "else", ":", "fs_bytes", ...
Calculate the bytes used to encode an annotation set and write them to an annotation file
[ "Calculate", "the", "bytes", "used", "to", "encode", "an", "annotation", "set", "and", "write", "them", "to", "an", "annotation", "file" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L586-L615
221,359
MIT-LCP/wfdb-python
wfdb/io/annotation.py
Annotation.calc_core_bytes
def calc_core_bytes(self): """ Convert all used annotation fields into bytes to write """ # The difference sample to write if len(self.sample) == 1: sampdiff = np.array([self.sample[0]]) else: sampdiff = np.concatenate(([self.sample[0]], np.diff(se...
python
def calc_core_bytes(self): """ Convert all used annotation fields into bytes to write """ # The difference sample to write if len(self.sample) == 1: sampdiff = np.array([self.sample[0]]) else: sampdiff = np.concatenate(([self.sample[0]], np.diff(se...
[ "def", "calc_core_bytes", "(", "self", ")", ":", "# The difference sample to write", "if", "len", "(", "self", ".", "sample", ")", "==", "1", ":", "sampdiff", "=", "np", ".", "array", "(", "[", "self", ".", "sample", "[", "0", "]", "]", ")", "else", ...
Convert all used annotation fields into bytes to write
[ "Convert", "all", "used", "annotation", "fields", "into", "bytes", "to", "write" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L676-L716
221,360
MIT-LCP/wfdb-python
wfdb/io/annotation.py
Annotation.get_contained_labels
def get_contained_labels(self, inplace=True): """ Get the set of unique labels contained in this annotation. Returns a pandas dataframe or sets the contained_labels attribute of the object. Requires the label_store field to be set. Function will try to use attributes c...
python
def get_contained_labels(self, inplace=True): """ Get the set of unique labels contained in this annotation. Returns a pandas dataframe or sets the contained_labels attribute of the object. Requires the label_store field to be set. Function will try to use attributes c...
[ "def", "get_contained_labels", "(", "self", ",", "inplace", "=", "True", ")", ":", "if", "self", ".", "custom_labels", "is", "not", "None", ":", "self", ".", "check_field", "(", "'custom_labels'", ")", "# Create the label map", "label_map", "=", "ann_label_table...
Get the set of unique labels contained in this annotation. Returns a pandas dataframe or sets the contained_labels attribute of the object. Requires the label_store field to be set. Function will try to use attributes contained in the order: 1. label_store 2. symbol ...
[ "Get", "the", "set", "of", "unique", "labels", "contained", "in", "this", "annotation", ".", "Returns", "a", "pandas", "dataframe", "or", "sets", "the", "contained_labels", "attribute", "of", "the", "object", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L781-L859
221,361
MIT-LCP/wfdb-python
wfdb/io/annotation.py
Annotation.set_label_elements
def set_label_elements(self, wanted_label_elements): """ Set one or more label elements based on at least one of the others """ if isinstance(wanted_label_elements, str): wanted_label_elements = [wanted_label_elements] # Figure out which desired label element...
python
def set_label_elements(self, wanted_label_elements): """ Set one or more label elements based on at least one of the others """ if isinstance(wanted_label_elements, str): wanted_label_elements = [wanted_label_elements] # Figure out which desired label element...
[ "def", "set_label_elements", "(", "self", ",", "wanted_label_elements", ")", ":", "if", "isinstance", "(", "wanted_label_elements", ",", "str", ")", ":", "wanted_label_elements", "=", "[", "wanted_label_elements", "]", "# Figure out which desired label elements are missing"...
Set one or more label elements based on at least one of the others
[ "Set", "one", "or", "more", "label", "elements", "based", "on", "at", "least", "one", "of", "the", "others" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L861-L885
221,362
MIT-LCP/wfdb-python
wfdb/io/_signal.py
_dat_read_params
def _dat_read_params(fmt, sig_len, byte_offset, skew, tsamps_per_frame, sampfrom, sampto): """ Calculate the parameters used to read and process a dat file, given its layout, and the desired sample range. Parameters ---------- fmt : str The format of the dat file ...
python
def _dat_read_params(fmt, sig_len, byte_offset, skew, tsamps_per_frame, sampfrom, sampto): """ Calculate the parameters used to read and process a dat file, given its layout, and the desired sample range. Parameters ---------- fmt : str The format of the dat file ...
[ "def", "_dat_read_params", "(", "fmt", ",", "sig_len", ",", "byte_offset", ",", "skew", ",", "tsamps_per_frame", ",", "sampfrom", ",", "sampto", ")", ":", "# First flat sample number to read (if all channels were flattened)", "start_flat_sample", "=", "sampfrom", "*", "...
Calculate the parameters used to read and process a dat file, given its layout, and the desired sample range. Parameters ---------- fmt : str The format of the dat file sig_len : int The signal length (per channel) of the dat file byte_offset : int The byte offset of the...
[ "Calculate", "the", "parameters", "used", "to", "read", "and", "process", "a", "dat", "file", "given", "its", "layout", "and", "the", "desired", "sample", "range", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L1035-L1123
221,363
MIT-LCP/wfdb-python
wfdb/io/_signal.py
_required_byte_num
def _required_byte_num(mode, fmt, n_samp): """ Determine how many signal bytes are needed to read or write a number of desired samples from a dat file. Parameters ---------- mode : str Whether the file is to be read or written: 'read' or 'write'. fmt : str The wfdb dat forma...
python
def _required_byte_num(mode, fmt, n_samp): """ Determine how many signal bytes are needed to read or write a number of desired samples from a dat file. Parameters ---------- mode : str Whether the file is to be read or written: 'read' or 'write'. fmt : str The wfdb dat forma...
[ "def", "_required_byte_num", "(", "mode", ",", "fmt", ",", "n_samp", ")", ":", "if", "fmt", "==", "'212'", ":", "n_bytes", "=", "math", ".", "ceil", "(", "n_samp", "*", "1.5", ")", "elif", "fmt", "in", "[", "'310'", ",", "'311'", "]", ":", "n_extra...
Determine how many signal bytes are needed to read or write a number of desired samples from a dat file. Parameters ---------- mode : str Whether the file is to be read or written: 'read' or 'write'. fmt : str The wfdb dat format. n_samp : int The number of samples wante...
[ "Determine", "how", "many", "signal", "bytes", "are", "needed", "to", "read", "or", "write", "a", "number", "of", "desired", "samples", "from", "a", "dat", "file", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L1126-L1173
221,364
MIT-LCP/wfdb-python
wfdb/io/_signal.py
_rd_dat_file
def _rd_dat_file(file_name, dir_name, pb_dir, fmt, start_byte, n_samp): """ Read data from a dat file, either local or remote, into a 1d numpy array. This is the lowest level dat reading function (along with `_stream_dat` which this function may call), and is called by `_rd_dat_signals`. P...
python
def _rd_dat_file(file_name, dir_name, pb_dir, fmt, start_byte, n_samp): """ Read data from a dat file, either local or remote, into a 1d numpy array. This is the lowest level dat reading function (along with `_stream_dat` which this function may call), and is called by `_rd_dat_signals`. P...
[ "def", "_rd_dat_file", "(", "file_name", ",", "dir_name", ",", "pb_dir", ",", "fmt", ",", "start_byte", ",", "n_samp", ")", ":", "# element_count is the number of elements to read using np.fromfile", "# for local files", "# byte_count is the number of bytes to read for streaming ...
Read data from a dat file, either local or remote, into a 1d numpy array. This is the lowest level dat reading function (along with `_stream_dat` which this function may call), and is called by `_rd_dat_signals`. Parameters ---------- start_byte : int The starting byte number to re...
[ "Read", "data", "from", "a", "dat", "file", "either", "local", "or", "remote", "into", "a", "1d", "numpy", "array", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L1176-L1234
221,365
MIT-LCP/wfdb-python
wfdb/io/_signal.py
_skew_sig
def _skew_sig(sig, skew, n_sig, read_len, fmt, nan_replace, samps_per_frame=None): """ Skew the signal, insert nans and shave off end of array if needed. Parameters ---------- sig : numpy array The original signal skew : list List of samples to skew for each signal n_sig : i...
python
def _skew_sig(sig, skew, n_sig, read_len, fmt, nan_replace, samps_per_frame=None): """ Skew the signal, insert nans and shave off end of array if needed. Parameters ---------- sig : numpy array The original signal skew : list List of samples to skew for each signal n_sig : i...
[ "def", "_skew_sig", "(", "sig", ",", "skew", ",", "n_sig", ",", "read_len", ",", "fmt", ",", "nan_replace", ",", "samps_per_frame", "=", "None", ")", ":", "if", "max", "(", "skew", ")", ">", "0", ":", "# Expanded frame samples. List of arrays.", "if", "isi...
Skew the signal, insert nans and shave off end of array if needed. Parameters ---------- sig : numpy array The original signal skew : list List of samples to skew for each signal n_sig : int The number of signals Notes ----- `fmt` is just for the correct nan va...
[ "Skew", "the", "signal", "insert", "nans", "and", "shave", "off", "end", "of", "array", "if", "needed", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L1343-L1394
221,366
MIT-LCP/wfdb-python
wfdb/io/_signal.py
_check_sig_dims
def _check_sig_dims(sig, read_len, n_sig, samps_per_frame): """ Integrity check of a signal's shape after reading. """ if isinstance(sig, np.ndarray): if sig.shape != (read_len, n_sig): raise ValueError('Samples were not loaded correctly') else: if len(sig) != n_sig: ...
python
def _check_sig_dims(sig, read_len, n_sig, samps_per_frame): """ Integrity check of a signal's shape after reading. """ if isinstance(sig, np.ndarray): if sig.shape != (read_len, n_sig): raise ValueError('Samples were not loaded correctly') else: if len(sig) != n_sig: ...
[ "def", "_check_sig_dims", "(", "sig", ",", "read_len", ",", "n_sig", ",", "samps_per_frame", ")", ":", "if", "isinstance", "(", "sig", ",", "np", ".", "ndarray", ")", ":", "if", "sig", ".", "shape", "!=", "(", "read_len", ",", "n_sig", ")", ":", "rai...
Integrity check of a signal's shape after reading.
[ "Integrity", "check", "of", "a", "signal", "s", "shape", "after", "reading", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L1397-L1410
221,367
MIT-LCP/wfdb-python
wfdb/io/_signal.py
_digi_bounds
def _digi_bounds(fmt): """ Return min and max digital values for each format type. Accepts lists. Parmeters --------- fmt : str, or list The wfdb dat format, or a list of them. """ if isinstance(fmt, list): return [_digi_bounds(f) for f in fmt] if fmt == '80': ...
python
def _digi_bounds(fmt): """ Return min and max digital values for each format type. Accepts lists. Parmeters --------- fmt : str, or list The wfdb dat format, or a list of them. """ if isinstance(fmt, list): return [_digi_bounds(f) for f in fmt] if fmt == '80': ...
[ "def", "_digi_bounds", "(", "fmt", ")", ":", "if", "isinstance", "(", "fmt", ",", "list", ")", ":", "return", "[", "_digi_bounds", "(", "f", ")", "for", "f", "in", "fmt", "]", "if", "fmt", "==", "'80'", ":", "return", "(", "-", "128", ",", "127",...
Return min and max digital values for each format type. Accepts lists. Parmeters --------- fmt : str, or list The wfdb dat format, or a list of them.
[ "Return", "min", "and", "max", "digital", "values", "for", "each", "format", "type", ".", "Accepts", "lists", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L1416-L1439
221,368
MIT-LCP/wfdb-python
wfdb/io/_signal.py
_digi_nan
def _digi_nan(fmt): """ Return the wfdb digital value used to store nan for the format type. Parmeters --------- fmt : str, or list The wfdb dat format, or a list of them. """ if isinstance(fmt, list): return [_digi_nan(f) for f in fmt] if fmt == '80': return -...
python
def _digi_nan(fmt): """ Return the wfdb digital value used to store nan for the format type. Parmeters --------- fmt : str, or list The wfdb dat format, or a list of them. """ if isinstance(fmt, list): return [_digi_nan(f) for f in fmt] if fmt == '80': return -...
[ "def", "_digi_nan", "(", "fmt", ")", ":", "if", "isinstance", "(", "fmt", ",", "list", ")", ":", "return", "[", "_digi_nan", "(", "f", ")", "for", "f", "in", "fmt", "]", "if", "fmt", "==", "'80'", ":", "return", "-", "128", "if", "fmt", "==", "...
Return the wfdb digital value used to store nan for the format type. Parmeters --------- fmt : str, or list The wfdb dat format, or a list of them.
[ "Return", "the", "wfdb", "digital", "value", "used", "to", "store", "nan", "for", "the", "format", "type", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L1442-L1472
221,369
MIT-LCP/wfdb-python
wfdb/io/_signal.py
est_res
def est_res(signals): """ Estimate the resolution of each signal in a multi-channel signal in bits. Maximum of 32 bits. Parameters ---------- signals : numpy array, or list A 2d numpy array representing a uniform multichannel signal, or a list of 1d numpy arrays representing mul...
python
def est_res(signals): """ Estimate the resolution of each signal in a multi-channel signal in bits. Maximum of 32 bits. Parameters ---------- signals : numpy array, or list A 2d numpy array representing a uniform multichannel signal, or a list of 1d numpy arrays representing mul...
[ "def", "est_res", "(", "signals", ")", ":", "res_levels", "=", "np", ".", "power", "(", "2", ",", "np", ".", "arange", "(", "0", ",", "33", ")", ")", "# Expanded sample signals. List of numpy arrays", "if", "isinstance", "(", "signals", ",", "list", ")", ...
Estimate the resolution of each signal in a multi-channel signal in bits. Maximum of 32 bits. Parameters ---------- signals : numpy array, or list A 2d numpy array representing a uniform multichannel signal, or a list of 1d numpy arrays representing multiple channels of signals ...
[ "Estimate", "the", "resolution", "of", "each", "signal", "in", "a", "multi", "-", "channel", "signal", "in", "bits", ".", "Maximum", "of", "32", "bits", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L1475-L1528
221,370
MIT-LCP/wfdb-python
wfdb/io/_signal.py
_np_dtype
def _np_dtype(bit_res, discrete): """ Given the bit resolution of a signal, return the minimum numpy dtype used to store it. Parameters ---------- bit_res : int The bit resolution. discrete : bool Whether the dtype is to be int or float. Returns ------- dtype : ...
python
def _np_dtype(bit_res, discrete): """ Given the bit resolution of a signal, return the minimum numpy dtype used to store it. Parameters ---------- bit_res : int The bit resolution. discrete : bool Whether the dtype is to be int or float. Returns ------- dtype : ...
[ "def", "_np_dtype", "(", "bit_res", ",", "discrete", ")", ":", "bit_res", "=", "min", "(", "bit_res", ",", "64", ")", "for", "np_res", "in", "[", "8", ",", "16", ",", "32", ",", "64", "]", ":", "if", "bit_res", "<=", "np_res", ":", "break", "if",...
Given the bit resolution of a signal, return the minimum numpy dtype used to store it. Parameters ---------- bit_res : int The bit resolution. discrete : bool Whether the dtype is to be int or float. Returns ------- dtype : str String numpy dtype used to store t...
[ "Given", "the", "bit", "resolution", "of", "a", "signal", "return", "the", "minimum", "numpy", "dtype", "used", "to", "store", "it", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L1599-L1628
221,371
MIT-LCP/wfdb-python
wfdb/io/_signal.py
_infer_sig_len
def _infer_sig_len(file_name, fmt, n_sig, dir_name, pb_dir=None): """ Infer the length of a signal from a dat file. Parameters ---------- file_name : str Name of the dat file fmt : str WFDB fmt of the dat file n_sig : int Number of signals contained in the dat file ...
python
def _infer_sig_len(file_name, fmt, n_sig, dir_name, pb_dir=None): """ Infer the length of a signal from a dat file. Parameters ---------- file_name : str Name of the dat file fmt : str WFDB fmt of the dat file n_sig : int Number of signals contained in the dat file ...
[ "def", "_infer_sig_len", "(", "file_name", ",", "fmt", ",", "n_sig", ",", "dir_name", ",", "pb_dir", "=", "None", ")", ":", "if", "pb_dir", "is", "None", ":", "file_size", "=", "os", ".", "path", ".", "getsize", "(", "os", ".", "path", ".", "join", ...
Infer the length of a signal from a dat file. Parameters ---------- file_name : str Name of the dat file fmt : str WFDB fmt of the dat file n_sig : int Number of signals contained in the dat file Notes ----- sig_len * n_sig * bytes_per_sample == file_size
[ "Infer", "the", "length", "of", "a", "signal", "from", "a", "dat", "file", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L1798-L1824
221,372
MIT-LCP/wfdb-python
wfdb/io/_signal.py
SignalMixin.adc
def adc(self, expanded=False, inplace=False): """ Performs analogue to digital conversion of the physical signal stored in p_signal if expanded is False, or e_p_signal if expanded is True. The p_signal/e_p_signal, fmt, gain, and baseline fields must all be valid. If inp...
python
def adc(self, expanded=False, inplace=False): """ Performs analogue to digital conversion of the physical signal stored in p_signal if expanded is False, or e_p_signal if expanded is True. The p_signal/e_p_signal, fmt, gain, and baseline fields must all be valid. If inp...
[ "def", "adc", "(", "self", ",", "expanded", "=", "False", ",", "inplace", "=", "False", ")", ":", "# The digital nan values for each channel", "d_nans", "=", "_digi_nan", "(", "self", ".", "fmt", ")", "# To do: choose the minimum return res needed", "intdtype", "=",...
Performs analogue to digital conversion of the physical signal stored in p_signal if expanded is False, or e_p_signal if expanded is True. The p_signal/e_p_signal, fmt, gain, and baseline fields must all be valid. If inplace is True, the adc will be performed inplace on the variable, ...
[ "Performs", "analogue", "to", "digital", "conversion", "of", "the", "physical", "signal", "stored", "in", "p_signal", "if", "expanded", "is", "False", "or", "e_p_signal", "if", "expanded", "is", "True", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L320-L416
221,373
MIT-LCP/wfdb-python
wfdb/io/_signal.py
SignalMixin.dac
def dac(self, expanded=False, return_res=64, inplace=False): """ Performs the digital to analogue conversion of the signal stored in `d_signal` if expanded is False, or `e_d_signal` if expanded is True. The d_signal/e_d_signal, fmt, gain, and baseline fields must all be ...
python
def dac(self, expanded=False, return_res=64, inplace=False): """ Performs the digital to analogue conversion of the signal stored in `d_signal` if expanded is False, or `e_d_signal` if expanded is True. The d_signal/e_d_signal, fmt, gain, and baseline fields must all be ...
[ "def", "dac", "(", "self", ",", "expanded", "=", "False", ",", "return_res", "=", "64", ",", "inplace", "=", "False", ")", ":", "# The digital nan values for each channel", "d_nans", "=", "_digi_nan", "(", "self", ".", "fmt", ")", "# Get the appropriate float dt...
Performs the digital to analogue conversion of the signal stored in `d_signal` if expanded is False, or `e_d_signal` if expanded is True. The d_signal/e_d_signal, fmt, gain, and baseline fields must all be valid. If inplace is True, the dac will be performed inplace on the ...
[ "Performs", "the", "digital", "to", "analogue", "conversion", "of", "the", "signal", "stored", "in", "d_signal", "if", "expanded", "is", "False", "or", "e_d_signal", "if", "expanded", "is", "True", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L419-L513
221,374
MIT-LCP/wfdb-python
wfdb/io/_signal.py
SignalMixin.calc_adc_params
def calc_adc_params(self): """ Compute appropriate adc_gain and baseline parameters for adc conversion, given the physical signal and the fmts. Returns ------- adc_gains : list List of calculated `adc_gain` values for each channel. baselines : list ...
python
def calc_adc_params(self): """ Compute appropriate adc_gain and baseline parameters for adc conversion, given the physical signal and the fmts. Returns ------- adc_gains : list List of calculated `adc_gain` values for each channel. baselines : list ...
[ "def", "calc_adc_params", "(", "self", ")", ":", "adc_gains", "=", "[", "]", "baselines", "=", "[", "]", "if", "np", ".", "where", "(", "np", ".", "isinf", "(", "self", ".", "p_signal", ")", ")", "[", "0", "]", ".", "size", ":", "raise", "ValueEr...
Compute appropriate adc_gain and baseline parameters for adc conversion, given the physical signal and the fmts. Returns ------- adc_gains : list List of calculated `adc_gain` values for each channel. baselines : list List of calculated `baseline` values ...
[ "Compute", "appropriate", "adc_gain", "and", "baseline", "parameters", "for", "adc", "conversion", "given", "the", "physical", "signal", "and", "the", "fmts", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L516-L622
221,375
MIT-LCP/wfdb-python
wfdb/io/_signal.py
SignalMixin.wr_dat_files
def wr_dat_files(self, expanded=False, write_dir=''): """ Write each of the specified dat files """ # Get the set of dat files to be written, and # the channels to be written to each file. file_names, dat_channels = describe_list_indices(self.file_name) # Get th...
python
def wr_dat_files(self, expanded=False, write_dir=''): """ Write each of the specified dat files """ # Get the set of dat files to be written, and # the channels to be written to each file. file_names, dat_channels = describe_list_indices(self.file_name) # Get th...
[ "def", "wr_dat_files", "(", "self", ",", "expanded", "=", "False", ",", "write_dir", "=", "''", ")", ":", "# Get the set of dat files to be written, and", "# the channels to be written to each file.", "file_names", ",", "dat_channels", "=", "describe_list_indices", "(", "...
Write each of the specified dat files
[ "Write", "each", "of", "the", "specified", "dat", "files" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_signal.py#L667-L700
221,376
MIT-LCP/wfdb-python
wfdb/io/_header.py
wfdb_strptime
def wfdb_strptime(time_string): """ Given a time string in an acceptable wfdb format, return a datetime.time object. Valid formats: SS, MM:SS, HH:MM:SS, all with and without microsec. """ n_colons = time_string.count(':') if n_colons == 0: time_fmt = '%S' elif n_colons == 1: ...
python
def wfdb_strptime(time_string): """ Given a time string in an acceptable wfdb format, return a datetime.time object. Valid formats: SS, MM:SS, HH:MM:SS, all with and without microsec. """ n_colons = time_string.count(':') if n_colons == 0: time_fmt = '%S' elif n_colons == 1: ...
[ "def", "wfdb_strptime", "(", "time_string", ")", ":", "n_colons", "=", "time_string", ".", "count", "(", "':'", ")", "if", "n_colons", "==", "0", ":", "time_fmt", "=", "'%S'", "elif", "n_colons", "==", "1", ":", "time_fmt", "=", "'%M:%S'", "elif", "n_col...
Given a time string in an acceptable wfdb format, return a datetime.time object. Valid formats: SS, MM:SS, HH:MM:SS, all with and without microsec.
[ "Given", "a", "time", "string", "in", "an", "acceptable", "wfdb", "format", "return", "a", "datetime", ".", "time", "object", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_header.py#L653-L672
221,377
MIT-LCP/wfdb-python
wfdb/io/_header.py
_read_header_lines
def _read_header_lines(base_record_name, dir_name, pb_dir): """ Read the lines in a local or remote header file. Parameters ---------- base_record_name : str The base name of the WFDB record to be read, without any file extensions. dir_name : str The local directory loca...
python
def _read_header_lines(base_record_name, dir_name, pb_dir): """ Read the lines in a local or remote header file. Parameters ---------- base_record_name : str The base name of the WFDB record to be read, without any file extensions. dir_name : str The local directory loca...
[ "def", "_read_header_lines", "(", "base_record_name", ",", "dir_name", ",", "pb_dir", ")", ":", "file_name", "=", "base_record_name", "+", "'.hea'", "# Read local file", "if", "pb_dir", "is", "None", ":", "with", "open", "(", "os", ".", "path", ".", "join", ...
Read the lines in a local or remote header file. Parameters ---------- base_record_name : str The base name of the WFDB record to be read, without any file extensions. dir_name : str The local directory location of the header file. This parameter is ignored if `pb_dir` i...
[ "Read", "the", "lines", "in", "a", "local", "or", "remote", "header", "file", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_header.py#L675-L730
221,378
MIT-LCP/wfdb-python
wfdb/io/_header.py
_parse_record_line
def _parse_record_line(record_line): """ Extract fields from a record line string into a dictionary """ # Dictionary for record fields record_fields = {} # Read string fields from record line (record_fields['record_name'], record_fields['n_seg'], record_fields['n_sig'], record_fields[...
python
def _parse_record_line(record_line): """ Extract fields from a record line string into a dictionary """ # Dictionary for record fields record_fields = {} # Read string fields from record line (record_fields['record_name'], record_fields['n_seg'], record_fields['n_sig'], record_fields[...
[ "def", "_parse_record_line", "(", "record_line", ")", ":", "# Dictionary for record fields", "record_fields", "=", "{", "}", "# Read string fields from record line", "(", "record_fields", "[", "'record_name'", "]", ",", "record_fields", "[", "'n_seg'", "]", ",", "record...
Extract fields from a record line string into a dictionary
[ "Extract", "fields", "from", "a", "record", "line", "string", "into", "a", "dictionary" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_header.py#L733-L777
221,379
MIT-LCP/wfdb-python
wfdb/io/_header.py
_parse_signal_lines
def _parse_signal_lines(signal_lines): """ Extract fields from a list of signal line strings into a dictionary. """ n_sig = len(signal_lines) # Dictionary for signal fields signal_fields = {} # Each dictionary field is a list for field in SIGNAL_SPECS.index: signal_fields[field...
python
def _parse_signal_lines(signal_lines): """ Extract fields from a list of signal line strings into a dictionary. """ n_sig = len(signal_lines) # Dictionary for signal fields signal_fields = {} # Each dictionary field is a list for field in SIGNAL_SPECS.index: signal_fields[field...
[ "def", "_parse_signal_lines", "(", "signal_lines", ")", ":", "n_sig", "=", "len", "(", "signal_lines", ")", "# Dictionary for signal fields", "signal_fields", "=", "{", "}", "# Each dictionary field is a list", "for", "field", "in", "SIGNAL_SPECS", ".", "index", ":", ...
Extract fields from a list of signal line strings into a dictionary.
[ "Extract", "fields", "from", "a", "list", "of", "signal", "line", "strings", "into", "a", "dictionary", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_header.py#L780-L824
221,380
MIT-LCP/wfdb-python
wfdb/io/_header.py
_read_segment_lines
def _read_segment_lines(segment_lines): """ Extract fields from segment line strings into a dictionary """ # Dictionary for segment fields segment_fields = {} # Each dictionary field is a list for field in SEGMENT_SPECS.index: segment_fields[field] = [None] * len(segment_lines) ...
python
def _read_segment_lines(segment_lines): """ Extract fields from segment line strings into a dictionary """ # Dictionary for segment fields segment_fields = {} # Each dictionary field is a list for field in SEGMENT_SPECS.index: segment_fields[field] = [None] * len(segment_lines) ...
[ "def", "_read_segment_lines", "(", "segment_lines", ")", ":", "# Dictionary for segment fields", "segment_fields", "=", "{", "}", "# Each dictionary field is a list", "for", "field", "in", "SEGMENT_SPECS", ".", "index", ":", "segment_fields", "[", "field", "]", "=", "...
Extract fields from segment line strings into a dictionary
[ "Extract", "fields", "from", "segment", "line", "strings", "into", "a", "dictionary" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_header.py#L827-L847
221,381
MIT-LCP/wfdb-python
wfdb/io/_header.py
BaseHeaderMixin.get_write_subset
def get_write_subset(self, spec_type): """ Get a set of fields used to write the header; either 'record' or 'signal' specification fields. Helper function for `get_write_fields`. Gets the default required fields, the user defined fields, and their dependencies. Parameter...
python
def get_write_subset(self, spec_type): """ Get a set of fields used to write the header; either 'record' or 'signal' specification fields. Helper function for `get_write_fields`. Gets the default required fields, the user defined fields, and their dependencies. Parameter...
[ "def", "get_write_subset", "(", "self", ",", "spec_type", ")", ":", "if", "spec_type", "==", "'record'", ":", "write_fields", "=", "[", "]", "record_specs", "=", "RECORD_SPECS", ".", "copy", "(", ")", "# Remove the n_seg requirement for single segment items", "if", ...
Get a set of fields used to write the header; either 'record' or 'signal' specification fields. Helper function for `get_write_fields`. Gets the default required fields, the user defined fields, and their dependencies. Parameters ---------- spec_type : str Th...
[ "Get", "a", "set", "of", "fields", "used", "to", "write", "the", "header", ";", "either", "record", "or", "signal", "specification", "fields", ".", "Helper", "function", "for", "get_write_fields", ".", "Gets", "the", "default", "required", "fields", "the", "...
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_header.py#L147-L233
221,382
MIT-LCP/wfdb-python
wfdb/io/_header.py
HeaderMixin.set_defaults
def set_defaults(self): """ Set defaults for fields needed to write the header if they have defaults. Notes ----- - This is NOT called by `rdheader`. It is only automatically called by the gateway `wrsamp` for convenience. - This is also not called by `...
python
def set_defaults(self): """ Set defaults for fields needed to write the header if they have defaults. Notes ----- - This is NOT called by `rdheader`. It is only automatically called by the gateway `wrsamp` for convenience. - This is also not called by `...
[ "def", "set_defaults", "(", "self", ")", ":", "rfields", ",", "sfields", "=", "self", ".", "get_write_fields", "(", ")", "for", "f", "in", "rfields", ":", "self", ".", "set_default", "(", "f", ")", "for", "f", "in", "sfields", ":", "self", ".", "set_...
Set defaults for fields needed to write the header if they have defaults. Notes ----- - This is NOT called by `rdheader`. It is only automatically called by the gateway `wrsamp` for convenience. - This is also not called by `wrheader` since it is supposed to ...
[ "Set", "defaults", "for", "fields", "needed", "to", "write", "the", "header", "if", "they", "have", "defaults", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_header.py#L241-L262
221,383
MIT-LCP/wfdb-python
wfdb/io/_header.py
HeaderMixin.get_write_fields
def get_write_fields(self): """ Get the list of fields used to write the header, separating record and signal specification fields. Returns the default required fields, the user defined fields, and their dependencies. Does NOT include `d_signal` or `e_d_signal`. ...
python
def get_write_fields(self): """ Get the list of fields used to write the header, separating record and signal specification fields. Returns the default required fields, the user defined fields, and their dependencies. Does NOT include `d_signal` or `e_d_signal`. ...
[ "def", "get_write_fields", "(", "self", ")", ":", "# Record specification fields", "rec_write_fields", "=", "self", ".", "get_write_subset", "(", "'record'", ")", "# Add comments if any", "if", "self", ".", "comments", "!=", "None", ":", "rec_write_fields", ".", "ap...
Get the list of fields used to write the header, separating record and signal specification fields. Returns the default required fields, the user defined fields, and their dependencies. Does NOT include `d_signal` or `e_d_signal`. Returns ------- rec_write_field...
[ "Get", "the", "list", "of", "fields", "used", "to", "write", "the", "header", "separating", "record", "and", "signal", "specification", "fields", ".", "Returns", "the", "default", "required", "fields", "the", "user", "defined", "fields", "and", "their", "depen...
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_header.py#L306-L342
221,384
MIT-LCP/wfdb-python
wfdb/io/_header.py
HeaderMixin.set_default
def set_default(self, field): """ Set the object's attribute to its default value if it is missing and there is a default. Not responsible for initializing the attribute. That is done by the constructor. """ # Record specification fields if field in RECO...
python
def set_default(self, field): """ Set the object's attribute to its default value if it is missing and there is a default. Not responsible for initializing the attribute. That is done by the constructor. """ # Record specification fields if field in RECO...
[ "def", "set_default", "(", "self", ",", "field", ")", ":", "# Record specification fields", "if", "field", "in", "RECORD_SPECS", ".", "index", ":", "# Return if no default to set, or if the field is already", "# present.", "if", "RECORD_SPECS", ".", "loc", "[", "field",...
Set the object's attribute to its default value if it is missing and there is a default. Not responsible for initializing the attribute. That is done by the constructor.
[ "Set", "the", "object", "s", "attribute", "to", "its", "default", "value", "if", "it", "is", "missing", "and", "there", "is", "a", "default", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_header.py#L345-L384
221,385
MIT-LCP/wfdb-python
wfdb/io/_header.py
HeaderMixin.check_field_cohesion
def check_field_cohesion(self, rec_write_fields, sig_write_fields): """ Check the cohesion of fields used to write the header """ # If there are no signal specification fields, there is nothing to check. if self.n_sig>0: # The length of all signal specification fiel...
python
def check_field_cohesion(self, rec_write_fields, sig_write_fields): """ Check the cohesion of fields used to write the header """ # If there are no signal specification fields, there is nothing to check. if self.n_sig>0: # The length of all signal specification fiel...
[ "def", "check_field_cohesion", "(", "self", ",", "rec_write_fields", ",", "sig_write_fields", ")", ":", "# If there are no signal specification fields, there is nothing to check.", "if", "self", ".", "n_sig", ">", "0", ":", "# The length of all signal specification fields must ma...
Check the cohesion of fields used to write the header
[ "Check", "the", "cohesion", "of", "fields", "used", "to", "write", "the", "header" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_header.py#L387-L420
221,386
MIT-LCP/wfdb-python
wfdb/io/_header.py
HeaderMixin.wr_header_file
def wr_header_file(self, rec_write_fields, sig_write_fields, write_dir): """ Write a header file using the specified fields. Converts Record attributes into appropriate wfdb format strings. Parameters ---------- rec_write_fields : list List of record specifi...
python
def wr_header_file(self, rec_write_fields, sig_write_fields, write_dir): """ Write a header file using the specified fields. Converts Record attributes into appropriate wfdb format strings. Parameters ---------- rec_write_fields : list List of record specifi...
[ "def", "wr_header_file", "(", "self", ",", "rec_write_fields", ",", "sig_write_fields", ",", "write_dir", ")", ":", "# Create record specification line", "record_line", "=", "''", "# Traverse the ordered dictionary", "for", "field", "in", "RECORD_SPECS", ".", "index", "...
Write a header file using the specified fields. Converts Record attributes into appropriate wfdb format strings. Parameters ---------- rec_write_fields : list List of record specification fields to write sig_write_fields : dict Dictionary of signal speci...
[ "Write", "a", "header", "file", "using", "the", "specified", "fields", ".", "Converts", "Record", "attributes", "into", "appropriate", "wfdb", "format", "strings", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_header.py#L423-L489
221,387
MIT-LCP/wfdb-python
wfdb/io/_header.py
MultiHeaderMixin.get_write_fields
def get_write_fields(self): """ Get the list of fields used to write the multi-segment header. Returns the default required fields, the user defined fields, and their dependencies. """ # Record specification fields write_fields = self.get_write_subset('record') ...
python
def get_write_fields(self): """ Get the list of fields used to write the multi-segment header. Returns the default required fields, the user defined fields, and their dependencies. """ # Record specification fields write_fields = self.get_write_subset('record') ...
[ "def", "get_write_fields", "(", "self", ")", ":", "# Record specification fields", "write_fields", "=", "self", ".", "get_write_subset", "(", "'record'", ")", "# Segment specification fields are all mandatory", "write_fields", "=", "write_fields", "+", "[", "'seg_name'", ...
Get the list of fields used to write the multi-segment header. Returns the default required fields, the user defined fields, and their dependencies.
[ "Get", "the", "list", "of", "fields", "used", "to", "write", "the", "multi", "-", "segment", "header", ".", "Returns", "the", "default", "required", "fields", "the", "user", "defined", "fields", "and", "their", "dependencies", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_header.py#L533-L550
221,388
MIT-LCP/wfdb-python
wfdb/io/_header.py
MultiHeaderMixin.wr_header_file
def wr_header_file(self, write_fields, write_dir): """ Write a header file using the specified fields """ # Create record specification line record_line = '' # Traverse the ordered dictionary for field in RECORD_SPECS.index: # If the field is being us...
python
def wr_header_file(self, write_fields, write_dir): """ Write a header file using the specified fields """ # Create record specification line record_line = '' # Traverse the ordered dictionary for field in RECORD_SPECS.index: # If the field is being us...
[ "def", "wr_header_file", "(", "self", ",", "write_fields", ",", "write_dir", ")", ":", "# Create record specification line", "record_line", "=", "''", "# Traverse the ordered dictionary", "for", "field", "in", "RECORD_SPECS", ".", "index", ":", "# If the field is being us...
Write a header file using the specified fields
[ "Write", "a", "header", "file", "using", "the", "specified", "fields" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/_header.py#L578-L608
221,389
MIT-LCP/wfdb-python
wfdb/processing/basic.py
resample_ann
def resample_ann(resampled_t, ann_sample): """ Compute the new annotation indices Parameters ---------- resampled_t : numpy array Array of signal locations as returned by scipy.signal.resample ann_sample : numpy array Array of annotation locations Returns ------- re...
python
def resample_ann(resampled_t, ann_sample): """ Compute the new annotation indices Parameters ---------- resampled_t : numpy array Array of signal locations as returned by scipy.signal.resample ann_sample : numpy array Array of annotation locations Returns ------- re...
[ "def", "resample_ann", "(", "resampled_t", ",", "ann_sample", ")", ":", "tmp", "=", "np", ".", "zeros", "(", "len", "(", "resampled_t", ")", ",", "dtype", "=", "'int16'", ")", "j", "=", "0", "tprec", "=", "resampled_t", "[", "j", "]", "for", "i", "...
Compute the new annotation indices Parameters ---------- resampled_t : numpy array Array of signal locations as returned by scipy.signal.resample ann_sample : numpy array Array of annotation locations Returns ------- resampled_ann_sample : numpy array Array of resam...
[ "Compute", "the", "new", "annotation", "indices" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/basic.py#L7-L57
221,390
MIT-LCP/wfdb-python
wfdb/processing/basic.py
resample_sig
def resample_sig(x, fs, fs_target): """ Resample a signal to a different frequency. Parameters ---------- x : numpy array Array containing the signal fs : int, or float The original sampling frequency fs_target : int, or float The target frequency Returns --...
python
def resample_sig(x, fs, fs_target): """ Resample a signal to a different frequency. Parameters ---------- x : numpy array Array containing the signal fs : int, or float The original sampling frequency fs_target : int, or float The target frequency Returns --...
[ "def", "resample_sig", "(", "x", ",", "fs", ",", "fs_target", ")", ":", "t", "=", "np", ".", "arange", "(", "x", ".", "shape", "[", "0", "]", ")", ".", "astype", "(", "'float64'", ")", "if", "fs", "==", "fs_target", ":", "return", "x", ",", "t"...
Resample a signal to a different frequency. Parameters ---------- x : numpy array Array containing the signal fs : int, or float The original sampling frequency fs_target : int, or float The target frequency Returns ------- resampled_x : numpy array Arra...
[ "Resample", "a", "signal", "to", "a", "different", "frequency", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/basic.py#L60-L92
221,391
MIT-LCP/wfdb-python
wfdb/processing/basic.py
resample_singlechan
def resample_singlechan(x, ann, fs, fs_target): """ Resample a single-channel signal with its annotations Parameters ---------- x: numpy array The signal array ann : wfdb Annotation The wfdb annotation object fs : int, or float The original frequency fs_target : ...
python
def resample_singlechan(x, ann, fs, fs_target): """ Resample a single-channel signal with its annotations Parameters ---------- x: numpy array The signal array ann : wfdb Annotation The wfdb annotation object fs : int, or float The original frequency fs_target : ...
[ "def", "resample_singlechan", "(", "x", ",", "ann", ",", "fs", ",", "fs_target", ")", ":", "resampled_x", ",", "resampled_t", "=", "resample_sig", "(", "x", ",", "fs", ",", "fs_target", ")", "new_sample", "=", "resample_ann", "(", "resampled_t", ",", "ann"...
Resample a single-channel signal with its annotations Parameters ---------- x: numpy array The signal array ann : wfdb Annotation The wfdb annotation object fs : int, or float The original frequency fs_target : int, or float The target frequency Returns ...
[ "Resample", "a", "single", "-", "channel", "signal", "with", "its", "annotations" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/basic.py#L95-L134
221,392
MIT-LCP/wfdb-python
wfdb/processing/basic.py
resample_multichan
def resample_multichan(xs, ann, fs, fs_target, resamp_ann_chan=0): """ Resample multiple channels with their annotations Parameters ---------- xs: numpy array The signal array ann : wfdb Annotation The wfdb annotation object fs : int, or float The original frequency ...
python
def resample_multichan(xs, ann, fs, fs_target, resamp_ann_chan=0): """ Resample multiple channels with their annotations Parameters ---------- xs: numpy array The signal array ann : wfdb Annotation The wfdb annotation object fs : int, or float The original frequency ...
[ "def", "resample_multichan", "(", "xs", ",", "ann", ",", "fs", ",", "fs_target", ",", "resamp_ann_chan", "=", "0", ")", ":", "assert", "resamp_ann_chan", "<", "xs", ".", "shape", "[", "1", "]", "lx", "=", "[", "]", "lt", "=", "None", "for", "chan", ...
Resample multiple channels with their annotations Parameters ---------- xs: numpy array The signal array ann : wfdb Annotation The wfdb annotation object fs : int, or float The original frequency fs_target : int, or float The target frequency resample_ann_cha...
[ "Resample", "multiple", "channels", "with", "their", "annotations" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/basic.py#L137-L185
221,393
MIT-LCP/wfdb-python
wfdb/processing/basic.py
normalize_bound
def normalize_bound(sig, lb=0, ub=1): """ Normalize a signal between the lower and upper bound Parameters ---------- sig : numpy array Original signal to be normalized lb : int, or float Lower bound ub : int, or float Upper bound Returns ------- x_normal...
python
def normalize_bound(sig, lb=0, ub=1): """ Normalize a signal between the lower and upper bound Parameters ---------- sig : numpy array Original signal to be normalized lb : int, or float Lower bound ub : int, or float Upper bound Returns ------- x_normal...
[ "def", "normalize_bound", "(", "sig", ",", "lb", "=", "0", ",", "ub", "=", "1", ")", ":", "mid", "=", "ub", "-", "(", "ub", "-", "lb", ")", "/", "2", "min_v", "=", "np", ".", "min", "(", "sig", ")", "max_v", "=", "np", ".", "max", "(", "s...
Normalize a signal between the lower and upper bound Parameters ---------- sig : numpy array Original signal to be normalized lb : int, or float Lower bound ub : int, or float Upper bound Returns ------- x_normalized : numpy array Normalized signal
[ "Normalize", "a", "signal", "between", "the", "lower", "and", "upper", "bound" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/basic.py#L188-L213
221,394
MIT-LCP/wfdb-python
wfdb/processing/basic.py
smooth
def smooth(sig, window_size): """ Apply a uniform moving average filter to a signal Parameters ---------- sig : numpy array The signal to smooth. window_size : int The width of the moving average filter. """ box = np.ones(window_size)/window_size return np.convolve(...
python
def smooth(sig, window_size): """ Apply a uniform moving average filter to a signal Parameters ---------- sig : numpy array The signal to smooth. window_size : int The width of the moving average filter. """ box = np.ones(window_size)/window_size return np.convolve(...
[ "def", "smooth", "(", "sig", ",", "window_size", ")", ":", "box", "=", "np", ".", "ones", "(", "window_size", ")", "/", "window_size", "return", "np", ".", "convolve", "(", "sig", ",", "box", ",", "mode", "=", "'same'", ")" ]
Apply a uniform moving average filter to a signal Parameters ---------- sig : numpy array The signal to smooth. window_size : int The width of the moving average filter.
[ "Apply", "a", "uniform", "moving", "average", "filter", "to", "a", "signal" ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/basic.py#L216-L229
221,395
MIT-LCP/wfdb-python
wfdb/processing/basic.py
get_filter_gain
def get_filter_gain(b, a, f_gain, fs): """ Given filter coefficients, return the gain at a particular frequency. Parameters ---------- b : list List of linear filter b coefficients a : list List of linear filter a coefficients f_gain : int or float, optional The ...
python
def get_filter_gain(b, a, f_gain, fs): """ Given filter coefficients, return the gain at a particular frequency. Parameters ---------- b : list List of linear filter b coefficients a : list List of linear filter a coefficients f_gain : int or float, optional The ...
[ "def", "get_filter_gain", "(", "b", ",", "a", ",", "f_gain", ",", "fs", ")", ":", "# Save the passband gain", "w", ",", "h", "=", "signal", ".", "freqz", "(", "b", ",", "a", ")", "w_gain", "=", "f_gain", "*", "2", "*", "np", ".", "pi", "/", "fs",...
Given filter coefficients, return the gain at a particular frequency. Parameters ---------- b : list List of linear filter b coefficients a : list List of linear filter a coefficients f_gain : int or float, optional The frequency at which to calculate the gain fs : i...
[ "Given", "filter", "coefficients", "return", "the", "gain", "at", "a", "particular", "frequency", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/basic.py#L232-L256
221,396
MIT-LCP/wfdb-python
wfdb/io/record.py
_check_item_type
def _check_item_type(item, field_name, allowed_types, expect_list=False, required_channels='all'): """ Check the item's type against a set of allowed types. Vary the print message regarding whether the item can be None. Helper to `BaseRecord.check_field`. Parameters --------...
python
def _check_item_type(item, field_name, allowed_types, expect_list=False, required_channels='all'): """ Check the item's type against a set of allowed types. Vary the print message regarding whether the item can be None. Helper to `BaseRecord.check_field`. Parameters --------...
[ "def", "_check_item_type", "(", "item", ",", "field_name", ",", "allowed_types", ",", "expect_list", "=", "False", ",", "required_channels", "=", "'all'", ")", ":", "if", "expect_list", ":", "if", "not", "isinstance", "(", "item", ",", "list", ")", ":", "r...
Check the item's type against a set of allowed types. Vary the print message regarding whether the item can be None. Helper to `BaseRecord.check_field`. Parameters ---------- item : any The item to check. field_name : str The field name. allowed_types : iterable Iter...
[ "Check", "the", "item", "s", "type", "against", "a", "set", "of", "allowed", "types", ".", "Vary", "the", "print", "message", "regarding", "whether", "the", "item", "can", "be", "None", ".", "Helper", "to", "BaseRecord", ".", "check_field", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L858-L909
221,397
MIT-LCP/wfdb-python
wfdb/io/record.py
check_np_array
def check_np_array(item, field_name, ndim, parent_class, channel_num=None): """ Check a numpy array's shape and dtype against required specifications. Parameters ---------- item : numpy array The numpy array to check field_name : str The name of the field to check ndim :...
python
def check_np_array(item, field_name, ndim, parent_class, channel_num=None): """ Check a numpy array's shape and dtype against required specifications. Parameters ---------- item : numpy array The numpy array to check field_name : str The name of the field to check ndim :...
[ "def", "check_np_array", "(", "item", ",", "field_name", ",", "ndim", ",", "parent_class", ",", "channel_num", "=", "None", ")", ":", "# Check shape", "if", "item", ".", "ndim", "!=", "ndim", ":", "error_msg", "=", "'Field `%s` must have ndim == %d'", "%", "("...
Check a numpy array's shape and dtype against required specifications. Parameters ---------- item : numpy array The numpy array to check field_name : str The name of the field to check ndim : int The required number of dimensions parent_class : type The paren...
[ "Check", "a", "numpy", "array", "s", "shape", "and", "dtype", "against", "required", "specifications", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L912-L944
221,398
MIT-LCP/wfdb-python
wfdb/io/record.py
rdheader
def rdheader(record_name, pb_dir=None, rd_segments=False): """ Read a WFDB header file and return a `Record` or `MultiRecord` object with the record descriptors as attributes. Parameters ---------- record_name : str The name of the WFDB record to be read, without any file extens...
python
def rdheader(record_name, pb_dir=None, rd_segments=False): """ Read a WFDB header file and return a `Record` or `MultiRecord` object with the record descriptors as attributes. Parameters ---------- record_name : str The name of the WFDB record to be read, without any file extens...
[ "def", "rdheader", "(", "record_name", ",", "pb_dir", "=", "None", ",", "rd_segments", "=", "False", ")", ":", "dir_name", ",", "base_record_name", "=", "os", ".", "path", ".", "split", "(", "record_name", ")", "dir_name", "=", "os", ".", "path", ".", ...
Read a WFDB header file and return a `Record` or `MultiRecord` object with the record descriptors as attributes. Parameters ---------- record_name : str The name of the WFDB record to be read, without any file extensions. If the argument contains any path delimiter characters, t...
[ "Read", "a", "WFDB", "header", "file", "and", "return", "a", "Record", "or", "MultiRecord", "object", "with", "the", "record", "descriptors", "as", "attributes", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L950-L1051
221,399
MIT-LCP/wfdb-python
wfdb/io/record.py
rdsamp
def rdsamp(record_name, sampfrom=0, sampto=None, channels=None, pb_dir=None, channel_names=None, warn_empty=False): """ Read a WFDB record, and return the physical signals and a few important descriptor fields. Parameters ---------- record_name : str The name of the WFDB reco...
python
def rdsamp(record_name, sampfrom=0, sampto=None, channels=None, pb_dir=None, channel_names=None, warn_empty=False): """ Read a WFDB record, and return the physical signals and a few important descriptor fields. Parameters ---------- record_name : str The name of the WFDB reco...
[ "def", "rdsamp", "(", "record_name", ",", "sampfrom", "=", "0", ",", "sampto", "=", "None", ",", "channels", "=", "None", ",", "pb_dir", "=", "None", ",", "channel_names", "=", "None", ",", "warn_empty", "=", "False", ")", ":", "record", "=", "rdrecord...
Read a WFDB record, and return the physical signals and a few important descriptor fields. Parameters ---------- record_name : str The name of the WFDB record to be read (without any file extensions). If the argument contains any path delimiter characters, the argument will be i...
[ "Read", "a", "WFDB", "record", "and", "return", "the", "physical", "signals", "and", "a", "few", "important", "descriptor", "fields", "." ]
cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L1323-L1402