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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
MIT-LCP/wfdb-python | wfdb/io/record.py | _get_wanted_channels | def _get_wanted_channels(wanted_sig_names, record_sig_names, pad=False):
"""
Given some wanted signal names, and the signal names contained in a
record, return the indices of the record channels that intersect.
Parameters
----------
wanted_sig_names : list
List of desired signal name st... | python | def _get_wanted_channels(wanted_sig_names, record_sig_names, pad=False):
"""
Given some wanted signal names, and the signal names contained in a
record, return the indices of the record channels that intersect.
Parameters
----------
wanted_sig_names : list
List of desired signal name st... | [
"def",
"_get_wanted_channels",
"(",
"wanted_sig_names",
",",
"record_sig_names",
",",
"pad",
"=",
"False",
")",
":",
"if",
"pad",
":",
"return",
"[",
"record_sig_names",
".",
"index",
"(",
"s",
")",
"if",
"s",
"in",
"record_sig_names",
"else",
"None",
"for",... | Given some wanted signal names, and the signal names contained in a
record, return the indices of the record channels that intersect.
Parameters
----------
wanted_sig_names : list
List of desired signal name strings
record_sig_names : list
List of signal names for a single record
... | [
"Given",
"some",
"wanted",
"signal",
"names",
"and",
"the",
"signal",
"names",
"contained",
"in",
"a",
"record",
"return",
"the",
"indices",
"of",
"the",
"record",
"channels",
"that",
"intersect",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L1405-L1429 | train |
MIT-LCP/wfdb-python | wfdb/io/record.py | wrsamp | def wrsamp(record_name, fs, units, sig_name, p_signal=None, d_signal=None,
fmt=None, adc_gain=None, baseline=None, comments=None,
base_time=None, base_date=None, write_dir=''):
"""
Write a single segment WFDB record, creating a WFDB header file and any
associated dat files.
Parame... | python | def wrsamp(record_name, fs, units, sig_name, p_signal=None, d_signal=None,
fmt=None, adc_gain=None, baseline=None, comments=None,
base_time=None, base_date=None, write_dir=''):
"""
Write a single segment WFDB record, creating a WFDB header file and any
associated dat files.
Parame... | [
"def",
"wrsamp",
"(",
"record_name",
",",
"fs",
",",
"units",
",",
"sig_name",
",",
"p_signal",
"=",
"None",
",",
"d_signal",
"=",
"None",
",",
"fmt",
"=",
"None",
",",
"adc_gain",
"=",
"None",
",",
"baseline",
"=",
"None",
",",
"comments",
"=",
"Non... | Write a single segment WFDB record, creating a WFDB header file and any
associated dat files.
Parameters
----------
record_name : str
The string name of the WFDB record to be written (without any file
extensions).
fs : int, or float
The sampling frequency of the record.
... | [
"Write",
"a",
"single",
"segment",
"WFDB",
"record",
"creating",
"a",
"WFDB",
"header",
"file",
"and",
"any",
"associated",
"dat",
"files",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L1435-L1539 | train |
MIT-LCP/wfdb-python | wfdb/io/record.py | is_monotonic | def is_monotonic(full_list):
"""
Determine whether elements in a list are monotonic. ie. unique
elements are clustered together.
ie. [5,5,3,4] is, [5,3,5] is not.
"""
prev_elements = set({full_list[0]})
prev_item = full_list[0]
for item in full_list:
if item != prev_item:
... | python | def is_monotonic(full_list):
"""
Determine whether elements in a list are monotonic. ie. unique
elements are clustered together.
ie. [5,5,3,4] is, [5,3,5] is not.
"""
prev_elements = set({full_list[0]})
prev_item = full_list[0]
for item in full_list:
if item != prev_item:
... | [
"def",
"is_monotonic",
"(",
"full_list",
")",
":",
"prev_elements",
"=",
"set",
"(",
"{",
"full_list",
"[",
"0",
"]",
"}",
")",
"prev_item",
"=",
"full_list",
"[",
"0",
"]",
"for",
"item",
"in",
"full_list",
":",
"if",
"item",
"!=",
"prev_item",
":",
... | Determine whether elements in a list are monotonic. ie. unique
elements are clustered together.
ie. [5,5,3,4] is, [5,3,5] is not. | [
"Determine",
"whether",
"elements",
"in",
"a",
"list",
"are",
"monotonic",
".",
"ie",
".",
"unique",
"elements",
"are",
"clustered",
"together",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L1542-L1559 | train |
MIT-LCP/wfdb-python | wfdb/io/record.py | BaseRecord._adjust_datetime | def _adjust_datetime(self, sampfrom):
"""
Adjust date and time fields to reflect user input if possible.
Helper function for the `_arrange_fields` of both Record and
MultiRecord objects.
"""
if sampfrom:
dt_seconds = sampfrom / self.fs
if self.bas... | python | def _adjust_datetime(self, sampfrom):
"""
Adjust date and time fields to reflect user input if possible.
Helper function for the `_arrange_fields` of both Record and
MultiRecord objects.
"""
if sampfrom:
dt_seconds = sampfrom / self.fs
if self.bas... | [
"def",
"_adjust_datetime",
"(",
"self",
",",
"sampfrom",
")",
":",
"if",
"sampfrom",
":",
"dt_seconds",
"=",
"sampfrom",
"/",
"self",
".",
"fs",
"if",
"self",
".",
"base_date",
"and",
"self",
".",
"base_time",
":",
"self",
".",
"base_datetime",
"=",
"dat... | Adjust date and time fields to reflect user input if possible.
Helper function for the `_arrange_fields` of both Record and
MultiRecord objects. | [
"Adjust",
"date",
"and",
"time",
"fields",
"to",
"reflect",
"user",
"input",
"if",
"possible",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L235-L255 | train |
MIT-LCP/wfdb-python | wfdb/io/record.py | Record.wrsamp | def wrsamp(self, expanded=False, write_dir=''):
"""
Write a wfdb header file and any associated dat files from this
object.
Parameters
----------
expanded : bool, optional
Whether to write the expanded signal (e_d_signal) instead
of the uniform si... | python | def wrsamp(self, expanded=False, write_dir=''):
"""
Write a wfdb header file and any associated dat files from this
object.
Parameters
----------
expanded : bool, optional
Whether to write the expanded signal (e_d_signal) instead
of the uniform si... | [
"def",
"wrsamp",
"(",
"self",
",",
"expanded",
"=",
"False",
",",
"write_dir",
"=",
"''",
")",
":",
"# Perform field validity and cohesion checks, and write the",
"# header file.",
"self",
".",
"wrheader",
"(",
"write_dir",
"=",
"write_dir",
")",
"if",
"self",
"."... | Write a wfdb header file and any associated dat files from this
object.
Parameters
----------
expanded : bool, optional
Whether to write the expanded signal (e_d_signal) instead
of the uniform signal (d_signal).
write_dir : str, optional
The d... | [
"Write",
"a",
"wfdb",
"header",
"file",
"and",
"any",
"associated",
"dat",
"files",
"from",
"this",
"object",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L350-L370 | train |
MIT-LCP/wfdb-python | wfdb/io/record.py | MultiRecord.wrsamp | def wrsamp(self, write_dir=''):
"""
Write a multi-segment header, along with headers and dat files
for all segments, from this object.
"""
# Perform field validity and cohesion checks, and write the
# header file.
self.wrheader(write_dir=write_dir)
# Perfo... | python | def wrsamp(self, write_dir=''):
"""
Write a multi-segment header, along with headers and dat files
for all segments, from this object.
"""
# Perform field validity and cohesion checks, and write the
# header file.
self.wrheader(write_dir=write_dir)
# Perfo... | [
"def",
"wrsamp",
"(",
"self",
",",
"write_dir",
"=",
"''",
")",
":",
"# Perform field validity and cohesion checks, and write the",
"# header file.",
"self",
".",
"wrheader",
"(",
"write_dir",
"=",
"write_dir",
")",
"# Perform record validity and cohesion checks, and write th... | Write a multi-segment header, along with headers and dat files
for all segments, from this object. | [
"Write",
"a",
"multi",
"-",
"segment",
"header",
"along",
"with",
"headers",
"and",
"dat",
"files",
"for",
"all",
"segments",
"from",
"this",
"object",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L479-L490 | train |
MIT-LCP/wfdb-python | wfdb/io/record.py | MultiRecord._check_segment_cohesion | def _check_segment_cohesion(self):
"""
Check the cohesion of the segments field with other fields used
to write the record
"""
if self.n_seg != len(self.segments):
raise ValueError("Length of segments must match the 'n_seg' field")
for i in range(n_seg):
... | python | def _check_segment_cohesion(self):
"""
Check the cohesion of the segments field with other fields used
to write the record
"""
if self.n_seg != len(self.segments):
raise ValueError("Length of segments must match the 'n_seg' field")
for i in range(n_seg):
... | [
"def",
"_check_segment_cohesion",
"(",
"self",
")",
":",
"if",
"self",
".",
"n_seg",
"!=",
"len",
"(",
"self",
".",
"segments",
")",
":",
"raise",
"ValueError",
"(",
"\"Length of segments must match the 'n_seg' field\"",
")",
"for",
"i",
"in",
"range",
"(",
"n... | Check the cohesion of the segments field with other fields used
to write the record | [
"Check",
"the",
"cohesion",
"of",
"the",
"segments",
"field",
"with",
"other",
"fields",
"used",
"to",
"write",
"the",
"record"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L492-L518 | train |
MIT-LCP/wfdb-python | wfdb/io/record.py | MultiRecord._required_segments | def _required_segments(self, sampfrom, sampto):
"""
Determine the segments and the samples within each segment in a
multi-segment record, that lie within a sample range.
Parameters
----------
sampfrom : int
The starting sample number to read for each channel.... | python | def _required_segments(self, sampfrom, sampto):
"""
Determine the segments and the samples within each segment in a
multi-segment record, that lie within a sample range.
Parameters
----------
sampfrom : int
The starting sample number to read for each channel.... | [
"def",
"_required_segments",
"(",
"self",
",",
"sampfrom",
",",
"sampto",
")",
":",
"# The starting segment with actual samples",
"if",
"self",
".",
"layout",
"==",
"'fixed'",
":",
"startseg",
"=",
"0",
"else",
":",
"startseg",
"=",
"1",
"# Cumulative sum of segme... | Determine the segments and the samples within each segment in a
multi-segment record, that lie within a sample range.
Parameters
----------
sampfrom : int
The starting sample number to read for each channel.
sampto : int
The sample number at which to stop... | [
"Determine",
"the",
"segments",
"and",
"the",
"samples",
"within",
"each",
"segment",
"in",
"a",
"multi",
"-",
"segment",
"record",
"that",
"lie",
"within",
"a",
"sample",
"range",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L525-L577 | train |
MIT-LCP/wfdb-python | wfdb/io/record.py | MultiRecord._required_channels | def _required_channels(self, seg_numbers, channels, dir_name, pb_dir):
"""
Get the channel numbers to be read from each specified segment,
given the channel numbers specified for the entire record.
Parameters
----------
seg_numbers : list
List of segment numb... | python | def _required_channels(self, seg_numbers, channels, dir_name, pb_dir):
"""
Get the channel numbers to be read from each specified segment,
given the channel numbers specified for the entire record.
Parameters
----------
seg_numbers : list
List of segment numb... | [
"def",
"_required_channels",
"(",
"self",
",",
"seg_numbers",
",",
"channels",
",",
"dir_name",
",",
"pb_dir",
")",
":",
"# Fixed layout. All channels are the same.",
"if",
"self",
".",
"layout",
"==",
"'fixed'",
":",
"required_channels",
"=",
"[",
"channels",
"]"... | Get the channel numbers to be read from each specified segment,
given the channel numbers specified for the entire record.
Parameters
----------
seg_numbers : list
List of segment numbers to read.
channels : list
The channel indices to read for the whole ... | [
"Get",
"the",
"channel",
"numbers",
"to",
"be",
"read",
"from",
"each",
"specified",
"segment",
"given",
"the",
"channel",
"numbers",
"specified",
"for",
"the",
"entire",
"record",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/record.py#L580-L625 | train |
MIT-LCP/wfdb-python | wfdb/io/tff.py | rdtff | def rdtff(file_name, cut_end=False):
"""
Read values from a tff file
Parameters
----------
file_name : str
Name of the .tff file to read
cut_end : bool, optional
If True, cuts out the last sample for all channels. This is for
reading files which appear to terminate with ... | python | def rdtff(file_name, cut_end=False):
"""
Read values from a tff file
Parameters
----------
file_name : str
Name of the .tff file to read
cut_end : bool, optional
If True, cuts out the last sample for all channels. This is for
reading files which appear to terminate with ... | [
"def",
"rdtff",
"(",
"file_name",
",",
"cut_end",
"=",
"False",
")",
":",
"file_size",
"=",
"os",
".",
"path",
".",
"getsize",
"(",
"file_name",
")",
"with",
"open",
"(",
"file_name",
",",
"'rb'",
")",
"as",
"fp",
":",
"fields",
",",
"file_fields",
"... | Read values from a tff file
Parameters
----------
file_name : str
Name of the .tff file to read
cut_end : bool, optional
If True, cuts out the last sample for all channels. This is for
reading files which appear to terminate with the incorrect
number of samples (ie. samp... | [
"Read",
"values",
"from",
"a",
"tff",
"file"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/tff.py#L14-L57 | train |
MIT-LCP/wfdb-python | wfdb/io/tff.py | _rdheader | def _rdheader(fp):
"""
Read header info of the windaq file
"""
tag = None
# The '2' tag indicates the end of tags.
while tag != 2:
# For each header element, there is a tag indicating data type,
# followed by the data size, followed by the data itself. 0's
# pad the conte... | python | def _rdheader(fp):
"""
Read header info of the windaq file
"""
tag = None
# The '2' tag indicates the end of tags.
while tag != 2:
# For each header element, there is a tag indicating data type,
# followed by the data size, followed by the data itself. 0's
# pad the conte... | [
"def",
"_rdheader",
"(",
"fp",
")",
":",
"tag",
"=",
"None",
"# The '2' tag indicates the end of tags.",
"while",
"tag",
"!=",
"2",
":",
"# For each header element, there is a tag indicating data type,",
"# followed by the data size, followed by the data itself. 0's",
"# pad the co... | Read header info of the windaq file | [
"Read",
"header",
"info",
"of",
"the",
"windaq",
"file"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/tff.py#L60-L139 | train |
MIT-LCP/wfdb-python | wfdb/io/tff.py | _rdsignal | def _rdsignal(fp, file_size, header_size, n_sig, bit_width, is_signed, cut_end):
"""
Read the signal
Parameters
----------
cut_end : bool, optional
If True, enables reading the end of files which appear to terminate
with the incorrect number of samples (ie. sample not present for al... | python | def _rdsignal(fp, file_size, header_size, n_sig, bit_width, is_signed, cut_end):
"""
Read the signal
Parameters
----------
cut_end : bool, optional
If True, enables reading the end of files which appear to terminate
with the incorrect number of samples (ie. sample not present for al... | [
"def",
"_rdsignal",
"(",
"fp",
",",
"file_size",
",",
"header_size",
",",
"n_sig",
",",
"bit_width",
",",
"is_signed",
",",
"cut_end",
")",
":",
"# Cannot initially figure out signal length because there",
"# are escape sequences.",
"fp",
".",
"seek",
"(",
"header_siz... | Read the signal
Parameters
----------
cut_end : bool, optional
If True, enables reading the end of files which appear to terminate
with the incorrect number of samples (ie. sample not present for all channels),
by checking and skipping the reading the end of such files.
Chec... | [
"Read",
"the",
"signal"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/tff.py#L142-L196 | train |
MIT-LCP/wfdb-python | wfdb/processing/qrs.py | xqrs_detect | def xqrs_detect(sig, fs, sampfrom=0, sampto='end', conf=None,
learn=True, verbose=True):
"""
Run the 'xqrs' qrs detection algorithm on a signal. See the
docstring of the XQRS class for algorithm details.
Parameters
----------
sig : numpy array
The input ecg signal to app... | python | def xqrs_detect(sig, fs, sampfrom=0, sampto='end', conf=None,
learn=True, verbose=True):
"""
Run the 'xqrs' qrs detection algorithm on a signal. See the
docstring of the XQRS class for algorithm details.
Parameters
----------
sig : numpy array
The input ecg signal to app... | [
"def",
"xqrs_detect",
"(",
"sig",
",",
"fs",
",",
"sampfrom",
"=",
"0",
",",
"sampto",
"=",
"'end'",
",",
"conf",
"=",
"None",
",",
"learn",
"=",
"True",
",",
"verbose",
"=",
"True",
")",
":",
"xqrs",
"=",
"XQRS",
"(",
"sig",
"=",
"sig",
",",
"... | Run the 'xqrs' qrs detection algorithm on a signal. See the
docstring of the XQRS class for algorithm details.
Parameters
----------
sig : numpy array
The input ecg signal to apply the qrs detection on.
fs : int or float
The sampling frequency of the input signal.
sampfrom : int... | [
"Run",
"the",
"xqrs",
"qrs",
"detection",
"algorithm",
"on",
"a",
"signal",
".",
"See",
"the",
"docstring",
"of",
"the",
"XQRS",
"class",
"for",
"algorithm",
"details",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/qrs.py#L603-L648 | train |
MIT-LCP/wfdb-python | wfdb/processing/qrs.py | gqrs_detect | def gqrs_detect(sig=None, fs=None, d_sig=None, adc_gain=None, adc_zero=None,
threshold=1.0, hr=75, RRdelta=0.2, RRmin=0.28, RRmax=2.4,
QS=0.07, QT=0.35, RTmin=0.25, RTmax=0.33,
QRSa=750, QRSamin=130):
"""
Detect qrs locations in a single channel ecg. Functionally,... | python | def gqrs_detect(sig=None, fs=None, d_sig=None, adc_gain=None, adc_zero=None,
threshold=1.0, hr=75, RRdelta=0.2, RRmin=0.28, RRmax=2.4,
QS=0.07, QT=0.35, RTmin=0.25, RTmax=0.33,
QRSa=750, QRSamin=130):
"""
Detect qrs locations in a single channel ecg. Functionally,... | [
"def",
"gqrs_detect",
"(",
"sig",
"=",
"None",
",",
"fs",
"=",
"None",
",",
"d_sig",
"=",
"None",
",",
"adc_gain",
"=",
"None",
",",
"adc_zero",
"=",
"None",
",",
"threshold",
"=",
"1.0",
",",
"hr",
"=",
"75",
",",
"RRdelta",
"=",
"0.2",
",",
"RR... | Detect qrs locations in a single channel ecg. Functionally, a direct port
of the gqrs algorithm from the original wfdb package. Accepts either a
physical signal, or a digital signal with known adc_gain and adc_zero.
See the notes below for a summary of the program. This algorithm is not
being developed... | [
"Detect",
"qrs",
"locations",
"in",
"a",
"single",
"channel",
"ecg",
".",
"Functionally",
"a",
"direct",
"port",
"of",
"the",
"gqrs",
"algorithm",
"from",
"the",
"original",
"wfdb",
"package",
".",
"Accepts",
"either",
"a",
"physical",
"signal",
"or",
"a",
... | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/qrs.py#L1123-L1278 | train |
MIT-LCP/wfdb-python | wfdb/processing/qrs.py | XQRS._set_conf | def _set_conf(self):
"""
Set configuration parameters from the Conf object into the detector
object.
Time values are converted to samples, and amplitude values are in mV.
"""
self.rr_init = 60 * self.fs / self.conf.hr_init
self.rr_max = 60 * self.fs / self.conf.h... | python | def _set_conf(self):
"""
Set configuration parameters from the Conf object into the detector
object.
Time values are converted to samples, and amplitude values are in mV.
"""
self.rr_init = 60 * self.fs / self.conf.hr_init
self.rr_max = 60 * self.fs / self.conf.h... | [
"def",
"_set_conf",
"(",
"self",
")",
":",
"self",
".",
"rr_init",
"=",
"60",
"*",
"self",
".",
"fs",
"/",
"self",
".",
"conf",
".",
"hr_init",
"self",
".",
"rr_max",
"=",
"60",
"*",
"self",
".",
"fs",
"/",
"self",
".",
"conf",
".",
"hr_min",
"... | Set configuration parameters from the Conf object into the detector
object.
Time values are converted to samples, and amplitude values are in mV. | [
"Set",
"configuration",
"parameters",
"from",
"the",
"Conf",
"object",
"into",
"the",
"detector",
"object",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/qrs.py#L126-L145 | train |
MIT-LCP/wfdb-python | wfdb/processing/qrs.py | XQRS._bandpass | def _bandpass(self, fc_low=5, fc_high=20):
"""
Apply a bandpass filter onto the signal, and save the filtered
signal.
"""
self.fc_low = fc_low
self.fc_high = fc_high
b, a = signal.butter(2, [float(fc_low) * 2 / self.fs,
float(fc_h... | python | def _bandpass(self, fc_low=5, fc_high=20):
"""
Apply a bandpass filter onto the signal, and save the filtered
signal.
"""
self.fc_low = fc_low
self.fc_high = fc_high
b, a = signal.butter(2, [float(fc_low) * 2 / self.fs,
float(fc_h... | [
"def",
"_bandpass",
"(",
"self",
",",
"fc_low",
"=",
"5",
",",
"fc_high",
"=",
"20",
")",
":",
"self",
".",
"fc_low",
"=",
"fc_low",
"self",
".",
"fc_high",
"=",
"fc_high",
"b",
",",
"a",
"=",
"signal",
".",
"butter",
"(",
"2",
",",
"[",
"float",... | Apply a bandpass filter onto the signal, and save the filtered
signal. | [
"Apply",
"a",
"bandpass",
"filter",
"onto",
"the",
"signal",
"and",
"save",
"the",
"filtered",
"signal",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/qrs.py#L148-L162 | train |
MIT-LCP/wfdb-python | wfdb/processing/qrs.py | XQRS._set_init_params | def _set_init_params(self, qrs_amp_recent, noise_amp_recent, rr_recent,
last_qrs_ind):
"""
Set initial online parameters
"""
self.qrs_amp_recent = qrs_amp_recent
self.noise_amp_recent = noise_amp_recent
# What happens if qrs_thr is calculated to b... | python | def _set_init_params(self, qrs_amp_recent, noise_amp_recent, rr_recent,
last_qrs_ind):
"""
Set initial online parameters
"""
self.qrs_amp_recent = qrs_amp_recent
self.noise_amp_recent = noise_amp_recent
# What happens if qrs_thr is calculated to b... | [
"def",
"_set_init_params",
"(",
"self",
",",
"qrs_amp_recent",
",",
"noise_amp_recent",
",",
"rr_recent",
",",
"last_qrs_ind",
")",
":",
"self",
".",
"qrs_amp_recent",
"=",
"qrs_amp_recent",
"self",
".",
"noise_amp_recent",
"=",
"noise_amp_recent",
"# What happens if ... | Set initial online parameters | [
"Set",
"initial",
"online",
"parameters"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/qrs.py#L314-L330 | train |
MIT-LCP/wfdb-python | wfdb/processing/qrs.py | XQRS._set_default_init_params | def _set_default_init_params(self):
"""
Set initial running parameters using default values.
The steady state equation is:
`qrs_thr = 0.25*qrs_amp + 0.75*noise_amp`
Estimate that qrs amp is 10x noise amp, giving:
`qrs_thr = 0.325 * qrs_amp or 13/40 * qrs_amp`
... | python | def _set_default_init_params(self):
"""
Set initial running parameters using default values.
The steady state equation is:
`qrs_thr = 0.25*qrs_amp + 0.75*noise_amp`
Estimate that qrs amp is 10x noise amp, giving:
`qrs_thr = 0.325 * qrs_amp or 13/40 * qrs_amp`
... | [
"def",
"_set_default_init_params",
"(",
"self",
")",
":",
"if",
"self",
".",
"verbose",
":",
"print",
"(",
"'Initializing using default parameters'",
")",
"# Multiply the specified ecg thresholds by the filter and mwi gain",
"# factors",
"qrs_thr_init",
"=",
"self",
".",
"q... | Set initial running parameters using default values.
The steady state equation is:
`qrs_thr = 0.25*qrs_amp + 0.75*noise_amp`
Estimate that qrs amp is 10x noise amp, giving:
`qrs_thr = 0.325 * qrs_amp or 13/40 * qrs_amp` | [
"Set",
"initial",
"running",
"parameters",
"using",
"default",
"values",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/qrs.py#L333-L361 | train |
MIT-LCP/wfdb-python | wfdb/processing/qrs.py | XQRS._update_qrs | def _update_qrs(self, peak_num, backsearch=False):
"""
Update live qrs parameters. Adjust the recent rr-intervals and
qrs amplitudes, and the qrs threshold.
Parameters
----------
peak_num : int
The peak number of the mwi signal where the qrs is detected
... | python | def _update_qrs(self, peak_num, backsearch=False):
"""
Update live qrs parameters. Adjust the recent rr-intervals and
qrs amplitudes, and the qrs threshold.
Parameters
----------
peak_num : int
The peak number of the mwi signal where the qrs is detected
... | [
"def",
"_update_qrs",
"(",
"self",
",",
"peak_num",
",",
"backsearch",
"=",
"False",
")",
":",
"i",
"=",
"self",
".",
"peak_inds_i",
"[",
"peak_num",
"]",
"# Update recent rr if the beat is consecutive (do this before",
"# updating self.last_qrs_ind)",
"rr_new",
"=",
... | Update live qrs parameters. Adjust the recent rr-intervals and
qrs amplitudes, and the qrs threshold.
Parameters
----------
peak_num : int
The peak number of the mwi signal where the qrs is detected
backsearch: bool, optional
Whether the qrs was found via... | [
"Update",
"live",
"qrs",
"parameters",
".",
"Adjust",
"the",
"recent",
"rr",
"-",
"intervals",
"and",
"qrs",
"amplitudes",
"and",
"the",
"qrs",
"threshold",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/qrs.py#L396-L435 | train |
MIT-LCP/wfdb-python | wfdb/processing/qrs.py | XQRS._is_twave | def _is_twave(self, peak_num):
"""
Check whether a segment is a t-wave. Compare the maximum gradient of
the filtered signal segment with that of the previous qrs segment.
Parameters
----------
peak_num : int
The peak number of the mwi signal where the qrs is ... | python | def _is_twave(self, peak_num):
"""
Check whether a segment is a t-wave. Compare the maximum gradient of
the filtered signal segment with that of the previous qrs segment.
Parameters
----------
peak_num : int
The peak number of the mwi signal where the qrs is ... | [
"def",
"_is_twave",
"(",
"self",
",",
"peak_num",
")",
":",
"i",
"=",
"self",
".",
"peak_inds_i",
"[",
"peak_num",
"]",
"# Due to initialization parameters, last_qrs_ind may be negative.",
"# No way to check in this instance.",
"if",
"self",
".",
"last_qrs_ind",
"-",
"s... | Check whether a segment is a t-wave. Compare the maximum gradient of
the filtered signal segment with that of the previous qrs segment.
Parameters
----------
peak_num : int
The peak number of the mwi signal where the qrs is detected | [
"Check",
"whether",
"a",
"segment",
"is",
"a",
"t",
"-",
"wave",
".",
"Compare",
"the",
"maximum",
"gradient",
"of",
"the",
"filtered",
"signal",
"segment",
"with",
"that",
"of",
"the",
"previous",
"qrs",
"segment",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/qrs.py#L438-L470 | train |
MIT-LCP/wfdb-python | wfdb/processing/qrs.py | XQRS._update_noise | def _update_noise(self, peak_num):
"""
Update live noise parameters
"""
i = self.peak_inds_i[peak_num]
self.noise_amp_recent = (0.875*self.noise_amp_recent
+ 0.125*self.sig_i[i])
return | python | def _update_noise(self, peak_num):
"""
Update live noise parameters
"""
i = self.peak_inds_i[peak_num]
self.noise_amp_recent = (0.875*self.noise_amp_recent
+ 0.125*self.sig_i[i])
return | [
"def",
"_update_noise",
"(",
"self",
",",
"peak_num",
")",
":",
"i",
"=",
"self",
".",
"peak_inds_i",
"[",
"peak_num",
"]",
"self",
".",
"noise_amp_recent",
"=",
"(",
"0.875",
"*",
"self",
".",
"noise_amp_recent",
"+",
"0.125",
"*",
"self",
".",
"sig_i",... | Update live noise parameters | [
"Update",
"live",
"noise",
"parameters"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/qrs.py#L472-L479 | train |
MIT-LCP/wfdb-python | wfdb/processing/qrs.py | XQRS._require_backsearch | def _require_backsearch(self):
"""
Determine whether a backsearch should be performed on prior peaks
"""
if self.peak_num == self.n_peaks_i-1:
# If we just return false, we may miss a chance to backsearch.
# Update this?
return False
next_peak... | python | def _require_backsearch(self):
"""
Determine whether a backsearch should be performed on prior peaks
"""
if self.peak_num == self.n_peaks_i-1:
# If we just return false, we may miss a chance to backsearch.
# Update this?
return False
next_peak... | [
"def",
"_require_backsearch",
"(",
"self",
")",
":",
"if",
"self",
".",
"peak_num",
"==",
"self",
".",
"n_peaks_i",
"-",
"1",
":",
"# If we just return false, we may miss a chance to backsearch.",
"# Update this?",
"return",
"False",
"next_peak_ind",
"=",
"self",
".",... | Determine whether a backsearch should be performed on prior peaks | [
"Determine",
"whether",
"a",
"backsearch",
"should",
"be",
"performed",
"on",
"prior",
"peaks"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/qrs.py#L481-L495 | train |
MIT-LCP/wfdb-python | wfdb/processing/qrs.py | XQRS._run_detection | def _run_detection(self):
"""
Run the qrs detection after all signals and parameters have been
configured and set.
"""
if self.verbose:
print('Running QRS detection...')
# Detected qrs indices
self.qrs_inds = []
# qrs indices found via backse... | python | def _run_detection(self):
"""
Run the qrs detection after all signals and parameters have been
configured and set.
"""
if self.verbose:
print('Running QRS detection...')
# Detected qrs indices
self.qrs_inds = []
# qrs indices found via backse... | [
"def",
"_run_detection",
"(",
"self",
")",
":",
"if",
"self",
".",
"verbose",
":",
"print",
"(",
"'Running QRS detection...'",
")",
"# Detected qrs indices",
"self",
".",
"qrs_inds",
"=",
"[",
"]",
"# qrs indices found via backsearch",
"self",
".",
"backsearch_qrs_i... | Run the qrs detection after all signals and parameters have been
configured and set. | [
"Run",
"the",
"qrs",
"detection",
"after",
"all",
"signals",
"and",
"parameters",
"have",
"been",
"configured",
"and",
"set",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/qrs.py#L510-L543 | train |
MIT-LCP/wfdb-python | wfdb/processing/qrs.py | XQRS.detect | def detect(self, sampfrom=0, sampto='end', learn=True, verbose=True):
"""
Detect qrs locations between two samples.
Parameters
----------
sampfrom : int, optional
The starting sample number to run the detection on.
sampto : int, optional
The final... | python | def detect(self, sampfrom=0, sampto='end', learn=True, verbose=True):
"""
Detect qrs locations between two samples.
Parameters
----------
sampfrom : int, optional
The starting sample number to run the detection on.
sampto : int, optional
The final... | [
"def",
"detect",
"(",
"self",
",",
"sampfrom",
"=",
"0",
",",
"sampto",
"=",
"'end'",
",",
"learn",
"=",
"True",
",",
"verbose",
"=",
"True",
")",
":",
"if",
"sampfrom",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"'sampfrom' cannot be negative\"",
")",... | Detect qrs locations between two samples.
Parameters
----------
sampfrom : int, optional
The starting sample number to run the detection on.
sampto : int, optional
The final sample number to run the detection on. Set as
'end' to run on the entire sign... | [
"Detect",
"qrs",
"locations",
"between",
"two",
"samples",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/qrs.py#L546-L600 | train |
MIT-LCP/wfdb-python | wfdb/processing/qrs.py | GQRS.detect | def detect(self, x, conf, adc_zero):
"""
Run detection. x is digital signal
"""
self.c = conf
self.annotations = []
self.sample_valid = False
if len(x) < 1:
return []
self.x = x
self.adc_zero = adc_zero
self.qfv = np.zeros((s... | python | def detect(self, x, conf, adc_zero):
"""
Run detection. x is digital signal
"""
self.c = conf
self.annotations = []
self.sample_valid = False
if len(x) < 1:
return []
self.x = x
self.adc_zero = adc_zero
self.qfv = np.zeros((s... | [
"def",
"detect",
"(",
"self",
",",
"x",
",",
"conf",
",",
"adc_zero",
")",
":",
"self",
".",
"c",
"=",
"conf",
"self",
".",
"annotations",
"=",
"[",
"]",
"self",
".",
"sample_valid",
"=",
"False",
"if",
"len",
"(",
"x",
")",
"<",
"1",
":",
"ret... | Run detection. x is digital signal | [
"Run",
"detection",
".",
"x",
"is",
"digital",
"signal"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/qrs.py#L750-L806 | train |
MIT-LCP/wfdb-python | wfdb/processing/hr.py | compute_hr | def compute_hr(sig_len, qrs_inds, fs):
"""
Compute instantaneous heart rate from peak indices.
Parameters
----------
sig_len : int
The length of the corresponding signal
qrs_inds : numpy array
The qrs index locations
fs : int, or float
The corresponding signal's samp... | python | def compute_hr(sig_len, qrs_inds, fs):
"""
Compute instantaneous heart rate from peak indices.
Parameters
----------
sig_len : int
The length of the corresponding signal
qrs_inds : numpy array
The qrs index locations
fs : int, or float
The corresponding signal's samp... | [
"def",
"compute_hr",
"(",
"sig_len",
",",
"qrs_inds",
",",
"fs",
")",
":",
"heart_rate",
"=",
"np",
".",
"full",
"(",
"sig_len",
",",
"np",
".",
"nan",
",",
"dtype",
"=",
"'float32'",
")",
"if",
"len",
"(",
"qrs_inds",
")",
"<",
"2",
":",
"return",... | Compute instantaneous heart rate from peak indices.
Parameters
----------
sig_len : int
The length of the corresponding signal
qrs_inds : numpy array
The qrs index locations
fs : int, or float
The corresponding signal's sampling frequency.
Returns
-------
heart_... | [
"Compute",
"instantaneous",
"heart",
"rate",
"from",
"peak",
"indices",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/hr.py#L4-L40 | train |
MIT-LCP/wfdb-python | wfdb/processing/hr.py | calc_rr | def calc_rr(qrs_locs, fs=None, min_rr=None, max_rr=None, qrs_units='samples',
rr_units='samples'):
"""
Compute rr intervals from qrs indices by extracting the time
differences.
Parameters
----------
qrs_locs : numpy array
1d array of qrs locations.
fs : float, optional
... | python | def calc_rr(qrs_locs, fs=None, min_rr=None, max_rr=None, qrs_units='samples',
rr_units='samples'):
"""
Compute rr intervals from qrs indices by extracting the time
differences.
Parameters
----------
qrs_locs : numpy array
1d array of qrs locations.
fs : float, optional
... | [
"def",
"calc_rr",
"(",
"qrs_locs",
",",
"fs",
"=",
"None",
",",
"min_rr",
"=",
"None",
",",
"max_rr",
"=",
"None",
",",
"qrs_units",
"=",
"'samples'",
",",
"rr_units",
"=",
"'samples'",
")",
":",
"rr",
"=",
"np",
".",
"diff",
"(",
"qrs_locs",
")",
... | Compute rr intervals from qrs indices by extracting the time
differences.
Parameters
----------
qrs_locs : numpy array
1d array of qrs locations.
fs : float, optional
Sampling frequency of the original signal. Needed if
`qrs_units` does not match `rr_units`.
min_rr : flo... | [
"Compute",
"rr",
"intervals",
"from",
"qrs",
"indices",
"by",
"extracting",
"the",
"time",
"differences",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/hr.py#L43-L94 | train |
MIT-LCP/wfdb-python | wfdb/processing/hr.py | calc_mean_hr | def calc_mean_hr(rr, fs=None, min_rr=None, max_rr=None, rr_units='samples'):
"""
Compute mean heart rate in beats per minute, from a set of rr
intervals. Returns 0 if rr is empty.
Parameters
----------
rr : numpy array
Array of rr intervals.
fs : int, or float
The correspond... | python | def calc_mean_hr(rr, fs=None, min_rr=None, max_rr=None, rr_units='samples'):
"""
Compute mean heart rate in beats per minute, from a set of rr
intervals. Returns 0 if rr is empty.
Parameters
----------
rr : numpy array
Array of rr intervals.
fs : int, or float
The correspond... | [
"def",
"calc_mean_hr",
"(",
"rr",
",",
"fs",
"=",
"None",
",",
"min_rr",
"=",
"None",
",",
"max_rr",
"=",
"None",
",",
"rr_units",
"=",
"'samples'",
")",
":",
"if",
"not",
"len",
"(",
"rr",
")",
":",
"return",
"0",
"if",
"min_rr",
"is",
"not",
"N... | Compute mean heart rate in beats per minute, from a set of rr
intervals. Returns 0 if rr is empty.
Parameters
----------
rr : numpy array
Array of rr intervals.
fs : int, or float
The corresponding signal's sampling frequency. Required if
'input_time_units' == 'samples'.
... | [
"Compute",
"mean",
"heart",
"rate",
"in",
"beats",
"per",
"minute",
"from",
"a",
"set",
"of",
"rr",
"intervals",
".",
"Returns",
"0",
"if",
"rr",
"is",
"empty",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/hr.py#L97-L142 | train |
MIT-LCP/wfdb-python | wfdb/processing/evaluate.py | compare_annotations | def compare_annotations(ref_sample, test_sample, window_width, signal=None):
"""
Compare a set of reference annotation locations against a set of
test annotation locations.
See the Comparitor class docstring for more information.
Parameters
----------
ref_sample : 1d numpy array
A... | python | def compare_annotations(ref_sample, test_sample, window_width, signal=None):
"""
Compare a set of reference annotation locations against a set of
test annotation locations.
See the Comparitor class docstring for more information.
Parameters
----------
ref_sample : 1d numpy array
A... | [
"def",
"compare_annotations",
"(",
"ref_sample",
",",
"test_sample",
",",
"window_width",
",",
"signal",
"=",
"None",
")",
":",
"comparitor",
"=",
"Comparitor",
"(",
"ref_sample",
"=",
"ref_sample",
",",
"test_sample",
"=",
"test_sample",
",",
"window_width",
"=... | Compare a set of reference annotation locations against a set of
test annotation locations.
See the Comparitor class docstring for more information.
Parameters
----------
ref_sample : 1d numpy array
Array of reference sample locations
test_sample : 1d numpy array
Array of test... | [
"Compare",
"a",
"set",
"of",
"reference",
"annotation",
"locations",
"against",
"a",
"set",
"of",
"test",
"annotation",
"locations",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/evaluate.py#L334-L381 | train |
MIT-LCP/wfdb-python | wfdb/processing/evaluate.py | benchmark_mitdb | def benchmark_mitdb(detector, verbose=False, print_results=False):
"""
Benchmark a qrs detector against mitdb's records.
Parameters
----------
detector : function
The detector function.
verbose : bool, optional
The verbose option of the detector function.
print_results : boo... | python | def benchmark_mitdb(detector, verbose=False, print_results=False):
"""
Benchmark a qrs detector against mitdb's records.
Parameters
----------
detector : function
The detector function.
verbose : bool, optional
The verbose option of the detector function.
print_results : boo... | [
"def",
"benchmark_mitdb",
"(",
"detector",
",",
"verbose",
"=",
"False",
",",
"print_results",
"=",
"False",
")",
":",
"record_list",
"=",
"get_record_list",
"(",
"'mitdb'",
")",
"n_records",
"=",
"len",
"(",
"record_list",
")",
"# Function arguments for starmap",... | Benchmark a qrs detector against mitdb's records.
Parameters
----------
detector : function
The detector function.
verbose : bool, optional
The verbose option of the detector function.
print_results : bool, optional
Whether to print the overall performance, and the results f... | [
"Benchmark",
"a",
"qrs",
"detector",
"against",
"mitdb",
"s",
"records",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/evaluate.py#L384-L454 | train |
MIT-LCP/wfdb-python | wfdb/processing/evaluate.py | benchmark_mitdb_record | def benchmark_mitdb_record(rec, detector, verbose):
"""
Benchmark a single mitdb record
"""
sig, fields = rdsamp(rec, pb_dir='mitdb', channels=[0])
ann_ref = rdann(rec, pb_dir='mitdb', extension='atr')
qrs_inds = detector(sig=sig[:,0], fs=fields['fs'], verbose=verbose)
comparitor = compare... | python | def benchmark_mitdb_record(rec, detector, verbose):
"""
Benchmark a single mitdb record
"""
sig, fields = rdsamp(rec, pb_dir='mitdb', channels=[0])
ann_ref = rdann(rec, pb_dir='mitdb', extension='atr')
qrs_inds = detector(sig=sig[:,0], fs=fields['fs'], verbose=verbose)
comparitor = compare... | [
"def",
"benchmark_mitdb_record",
"(",
"rec",
",",
"detector",
",",
"verbose",
")",
":",
"sig",
",",
"fields",
"=",
"rdsamp",
"(",
"rec",
",",
"pb_dir",
"=",
"'mitdb'",
",",
"channels",
"=",
"[",
"0",
"]",
")",
"ann_ref",
"=",
"rdann",
"(",
"rec",
","... | Benchmark a single mitdb record | [
"Benchmark",
"a",
"single",
"mitdb",
"record"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/evaluate.py#L457-L471 | train |
MIT-LCP/wfdb-python | wfdb/processing/evaluate.py | Comparitor._calc_stats | def _calc_stats(self):
"""
Calculate performance statistics after the two sets of annotations
are compared.
Example:
-------------------
ref=500 test=480
{ 30 { 470 } 10 }
-------------------
tp = 470
fp = 10
fn = 30
... | python | def _calc_stats(self):
"""
Calculate performance statistics after the two sets of annotations
are compared.
Example:
-------------------
ref=500 test=480
{ 30 { 470 } 10 }
-------------------
tp = 470
fp = 10
fn = 30
... | [
"def",
"_calc_stats",
"(",
"self",
")",
":",
"# Reference annotation indices that were detected",
"self",
".",
"matched_ref_inds",
"=",
"np",
".",
"where",
"(",
"self",
".",
"matching_sample_nums",
"!=",
"-",
"1",
")",
"[",
"0",
"]",
"# Reference annotation indices ... | Calculate performance statistics after the two sets of annotations
are compared.
Example:
-------------------
ref=500 test=480
{ 30 { 470 } 10 }
-------------------
tp = 470
fp = 10
fn = 30
specificity = 470 / 500
positive_pr... | [
"Calculate",
"performance",
"statistics",
"after",
"the",
"two",
"sets",
"of",
"annotations",
"are",
"compared",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/evaluate.py#L69-L116 | train |
MIT-LCP/wfdb-python | wfdb/processing/evaluate.py | Comparitor.compare | def compare(self):
"""
Main comparison function
"""
"""
Note: Make sure to be able to handle these ref/test scenarios:
A:
o----o---o---o
x-------x----x
B:
o----o-----o---o
x--------x--x--x
C:
o------o-----o---o
... | python | def compare(self):
"""
Main comparison function
"""
"""
Note: Make sure to be able to handle these ref/test scenarios:
A:
o----o---o---o
x-------x----x
B:
o----o-----o---o
x--------x--x--x
C:
o------o-----o---o
... | [
"def",
"compare",
"(",
"self",
")",
":",
"\"\"\"\n Note: Make sure to be able to handle these ref/test scenarios:\n\n A:\n o----o---o---o\n x-------x----x\n\n B:\n o----o-----o---o\n x--------x--x--x\n\n C:\n o------o-----o---o\n x-x-... | Main comparison function | [
"Main",
"comparison",
"function"
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/evaluate.py#L118-L197 | train |
MIT-LCP/wfdb-python | wfdb/processing/evaluate.py | Comparitor._get_closest_samp_num | def _get_closest_samp_num(self, ref_samp_num, start_test_samp_num):
"""
Return the closest testing sample number for the given reference
sample number. Limit the search from start_test_samp_num.
"""
if start_test_samp_num >= self.n_test:
raise ValueError('Invalid sta... | python | def _get_closest_samp_num(self, ref_samp_num, start_test_samp_num):
"""
Return the closest testing sample number for the given reference
sample number. Limit the search from start_test_samp_num.
"""
if start_test_samp_num >= self.n_test:
raise ValueError('Invalid sta... | [
"def",
"_get_closest_samp_num",
"(",
"self",
",",
"ref_samp_num",
",",
"start_test_samp_num",
")",
":",
"if",
"start_test_samp_num",
">=",
"self",
".",
"n_test",
":",
"raise",
"ValueError",
"(",
"'Invalid starting test sample number.'",
")",
"ref_samp",
"=",
"self",
... | Return the closest testing sample number for the given reference
sample number. Limit the search from start_test_samp_num. | [
"Return",
"the",
"closest",
"testing",
"sample",
"number",
"for",
"the",
"given",
"reference",
"sample",
"number",
".",
"Limit",
"the",
"search",
"from",
"start_test_samp_num",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/evaluate.py#L200-L232 | train |
MIT-LCP/wfdb-python | wfdb/processing/evaluate.py | Comparitor.print_summary | def print_summary(self):
"""
Print summary metrics of the annotation comparisons.
"""
# True positives = matched reference samples
self.tp = len(self.matched_ref_inds)
# False positives = extra test samples not matched
self.fp = self.n_test - self.tp
# Fal... | python | def print_summary(self):
"""
Print summary metrics of the annotation comparisons.
"""
# True positives = matched reference samples
self.tp = len(self.matched_ref_inds)
# False positives = extra test samples not matched
self.fp = self.n_test - self.tp
# Fal... | [
"def",
"print_summary",
"(",
"self",
")",
":",
"# True positives = matched reference samples",
"self",
".",
"tp",
"=",
"len",
"(",
"self",
".",
"matched_ref_inds",
")",
"# False positives = extra test samples not matched",
"self",
".",
"fp",
"=",
"self",
".",
"n_test"... | Print summary metrics of the annotation comparisons. | [
"Print",
"summary",
"metrics",
"of",
"the",
"annotation",
"comparisons",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/evaluate.py#L234-L261 | train |
MIT-LCP/wfdb-python | wfdb/processing/evaluate.py | Comparitor.plot | def plot(self, sig_style='', title=None, figsize=None,
return_fig=False):
"""
Plot the comparison of two sets of annotations, possibly
overlaid on their original signal.
Parameters
----------
sig_style : str, optional
The matplotlib style of the ... | python | def plot(self, sig_style='', title=None, figsize=None,
return_fig=False):
"""
Plot the comparison of two sets of annotations, possibly
overlaid on their original signal.
Parameters
----------
sig_style : str, optional
The matplotlib style of the ... | [
"def",
"plot",
"(",
"self",
",",
"sig_style",
"=",
"''",
",",
"title",
"=",
"None",
",",
"figsize",
"=",
"None",
",",
"return_fig",
"=",
"False",
")",
":",
"fig",
"=",
"plt",
".",
"figure",
"(",
"figsize",
"=",
"figsize",
")",
"ax",
"=",
"fig",
"... | Plot the comparison of two sets of annotations, possibly
overlaid on their original signal.
Parameters
----------
sig_style : str, optional
The matplotlib style of the signal
title : str, optional
The title of the plot
figsize: tuple, optional
... | [
"Plot",
"the",
"comparison",
"of",
"two",
"sets",
"of",
"annotations",
"possibly",
"overlaid",
"on",
"their",
"original",
"signal",
"."
] | cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c | https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/processing/evaluate.py#L264-L331 | train |
numba/llvmlite | llvmlite/binding/executionengine.py | ExecutionEngine.add_module | def add_module(self, module):
"""
Ownership of module is transferred to the execution engine
"""
if module in self._modules:
raise KeyError("module already added to this engine")
ffi.lib.LLVMPY_AddModule(self, module)
module._owned = True
self._modules... | python | def add_module(self, module):
"""
Ownership of module is transferred to the execution engine
"""
if module in self._modules:
raise KeyError("module already added to this engine")
ffi.lib.LLVMPY_AddModule(self, module)
module._owned = True
self._modules... | [
"def",
"add_module",
"(",
"self",
",",
"module",
")",
":",
"if",
"module",
"in",
"self",
".",
"_modules",
":",
"raise",
"KeyError",
"(",
"\"module already added to this engine\"",
")",
"ffi",
".",
"lib",
".",
"LLVMPY_AddModule",
"(",
"self",
",",
"module",
"... | Ownership of module is transferred to the execution engine | [
"Ownership",
"of",
"module",
"is",
"transferred",
"to",
"the",
"execution",
"engine"
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/executionengine.py#L80-L88 | train |
numba/llvmlite | llvmlite/binding/executionengine.py | ExecutionEngine.remove_module | def remove_module(self, module):
"""
Ownership of module is returned
"""
with ffi.OutputString() as outerr:
if ffi.lib.LLVMPY_RemoveModule(self, module, outerr):
raise RuntimeError(str(outerr))
self._modules.remove(module)
module._owned = False | python | def remove_module(self, module):
"""
Ownership of module is returned
"""
with ffi.OutputString() as outerr:
if ffi.lib.LLVMPY_RemoveModule(self, module, outerr):
raise RuntimeError(str(outerr))
self._modules.remove(module)
module._owned = False | [
"def",
"remove_module",
"(",
"self",
",",
"module",
")",
":",
"with",
"ffi",
".",
"OutputString",
"(",
")",
"as",
"outerr",
":",
"if",
"ffi",
".",
"lib",
".",
"LLVMPY_RemoveModule",
"(",
"self",
",",
"module",
",",
"outerr",
")",
":",
"raise",
"Runtime... | Ownership of module is returned | [
"Ownership",
"of",
"module",
"is",
"returned"
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/executionengine.py#L105-L113 | train |
numba/llvmlite | llvmlite/binding/executionengine.py | ExecutionEngine.target_data | def target_data(self):
"""
The TargetData for this execution engine.
"""
if self._td is not None:
return self._td
ptr = ffi.lib.LLVMPY_GetExecutionEngineTargetData(self)
self._td = targets.TargetData(ptr)
self._td._owned = True
return self._td | python | def target_data(self):
"""
The TargetData for this execution engine.
"""
if self._td is not None:
return self._td
ptr = ffi.lib.LLVMPY_GetExecutionEngineTargetData(self)
self._td = targets.TargetData(ptr)
self._td._owned = True
return self._td | [
"def",
"target_data",
"(",
"self",
")",
":",
"if",
"self",
".",
"_td",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_td",
"ptr",
"=",
"ffi",
".",
"lib",
".",
"LLVMPY_GetExecutionEngineTargetData",
"(",
"self",
")",
"self",
".",
"_td",
"=",
"target... | The TargetData for this execution engine. | [
"The",
"TargetData",
"for",
"this",
"execution",
"engine",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/executionengine.py#L116-L125 | train |
numba/llvmlite | llvmlite/binding/executionengine.py | ExecutionEngine._find_module_ptr | def _find_module_ptr(self, module_ptr):
"""
Find the ModuleRef corresponding to the given pointer.
"""
ptr = cast(module_ptr, c_void_p).value
for module in self._modules:
if cast(module._ptr, c_void_p).value == ptr:
return module
return None | python | def _find_module_ptr(self, module_ptr):
"""
Find the ModuleRef corresponding to the given pointer.
"""
ptr = cast(module_ptr, c_void_p).value
for module in self._modules:
if cast(module._ptr, c_void_p).value == ptr:
return module
return None | [
"def",
"_find_module_ptr",
"(",
"self",
",",
"module_ptr",
")",
":",
"ptr",
"=",
"cast",
"(",
"module_ptr",
",",
"c_void_p",
")",
".",
"value",
"for",
"module",
"in",
"self",
".",
"_modules",
":",
"if",
"cast",
"(",
"module",
".",
"_ptr",
",",
"c_void_... | Find the ModuleRef corresponding to the given pointer. | [
"Find",
"the",
"ModuleRef",
"corresponding",
"to",
"the",
"given",
"pointer",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/executionengine.py#L136-L144 | train |
numba/llvmlite | llvmlite/binding/executionengine.py | ExecutionEngine.set_object_cache | def set_object_cache(self, notify_func=None, getbuffer_func=None):
"""
Set the object cache "notifyObjectCompiled" and "getBuffer"
callbacks to the given Python functions.
"""
self._object_cache_notify = notify_func
self._object_cache_getbuffer = getbuffer_func
# ... | python | def set_object_cache(self, notify_func=None, getbuffer_func=None):
"""
Set the object cache "notifyObjectCompiled" and "getBuffer"
callbacks to the given Python functions.
"""
self._object_cache_notify = notify_func
self._object_cache_getbuffer = getbuffer_func
# ... | [
"def",
"set_object_cache",
"(",
"self",
",",
"notify_func",
"=",
"None",
",",
"getbuffer_func",
"=",
"None",
")",
":",
"self",
".",
"_object_cache_notify",
"=",
"notify_func",
"self",
".",
"_object_cache_getbuffer",
"=",
"getbuffer_func",
"# Lifetime of the object cac... | Set the object cache "notifyObjectCompiled" and "getBuffer"
callbacks to the given Python functions. | [
"Set",
"the",
"object",
"cache",
"notifyObjectCompiled",
"and",
"getBuffer",
"callbacks",
"to",
"the",
"given",
"Python",
"functions",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/executionengine.py#L157-L168 | train |
numba/llvmlite | llvmlite/binding/executionengine.py | ExecutionEngine._raw_object_cache_notify | def _raw_object_cache_notify(self, data):
"""
Low-level notify hook.
"""
if self._object_cache_notify is None:
return
module_ptr = data.contents.module_ptr
buf_ptr = data.contents.buf_ptr
buf_len = data.contents.buf_len
buf = string_at(buf_ptr,... | python | def _raw_object_cache_notify(self, data):
"""
Low-level notify hook.
"""
if self._object_cache_notify is None:
return
module_ptr = data.contents.module_ptr
buf_ptr = data.contents.buf_ptr
buf_len = data.contents.buf_len
buf = string_at(buf_ptr,... | [
"def",
"_raw_object_cache_notify",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"_object_cache_notify",
"is",
"None",
":",
"return",
"module_ptr",
"=",
"data",
".",
"contents",
".",
"module_ptr",
"buf_ptr",
"=",
"data",
".",
"contents",
".",
"buf_p... | Low-level notify hook. | [
"Low",
"-",
"level",
"notify",
"hook",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/executionengine.py#L170-L186 | train |
numba/llvmlite | llvmlite/binding/executionengine.py | ExecutionEngine._raw_object_cache_getbuffer | def _raw_object_cache_getbuffer(self, data):
"""
Low-level getbuffer hook.
"""
if self._object_cache_getbuffer is None:
return
module_ptr = data.contents.module_ptr
module = self._find_module_ptr(module_ptr)
if module is None:
# The LLVM EE... | python | def _raw_object_cache_getbuffer(self, data):
"""
Low-level getbuffer hook.
"""
if self._object_cache_getbuffer is None:
return
module_ptr = data.contents.module_ptr
module = self._find_module_ptr(module_ptr)
if module is None:
# The LLVM EE... | [
"def",
"_raw_object_cache_getbuffer",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"_object_cache_getbuffer",
"is",
"None",
":",
"return",
"module_ptr",
"=",
"data",
".",
"contents",
".",
"module_ptr",
"module",
"=",
"self",
".",
"_find_module_ptr",
... | Low-level getbuffer hook. | [
"Low",
"-",
"level",
"getbuffer",
"hook",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/binding/executionengine.py#L188-L206 | train |
numba/llvmlite | llvmlite/ir/builder.py | IRBuilder.position_before | def position_before(self, instr):
"""
Position immediately before the given instruction. The current block
is also changed to the instruction's basic block.
"""
self._block = instr.parent
self._anchor = self._block.instructions.index(instr) | python | def position_before(self, instr):
"""
Position immediately before the given instruction. The current block
is also changed to the instruction's basic block.
"""
self._block = instr.parent
self._anchor = self._block.instructions.index(instr) | [
"def",
"position_before",
"(",
"self",
",",
"instr",
")",
":",
"self",
".",
"_block",
"=",
"instr",
".",
"parent",
"self",
".",
"_anchor",
"=",
"self",
".",
"_block",
".",
"instructions",
".",
"index",
"(",
"instr",
")"
] | Position immediately before the given instruction. The current block
is also changed to the instruction's basic block. | [
"Position",
"immediately",
"before",
"the",
"given",
"instruction",
".",
"The",
"current",
"block",
"is",
"also",
"changed",
"to",
"the",
"instruction",
"s",
"basic",
"block",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/builder.py#L182-L188 | train |
numba/llvmlite | llvmlite/ir/builder.py | IRBuilder.position_after | def position_after(self, instr):
"""
Position immediately after the given instruction. The current block
is also changed to the instruction's basic block.
"""
self._block = instr.parent
self._anchor = self._block.instructions.index(instr) + 1 | python | def position_after(self, instr):
"""
Position immediately after the given instruction. The current block
is also changed to the instruction's basic block.
"""
self._block = instr.parent
self._anchor = self._block.instructions.index(instr) + 1 | [
"def",
"position_after",
"(",
"self",
",",
"instr",
")",
":",
"self",
".",
"_block",
"=",
"instr",
".",
"parent",
"self",
".",
"_anchor",
"=",
"self",
".",
"_block",
".",
"instructions",
".",
"index",
"(",
"instr",
")",
"+",
"1"
] | Position immediately after the given instruction. The current block
is also changed to the instruction's basic block. | [
"Position",
"immediately",
"after",
"the",
"given",
"instruction",
".",
"The",
"current",
"block",
"is",
"also",
"changed",
"to",
"the",
"instruction",
"s",
"basic",
"block",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/builder.py#L190-L196 | train |
numba/llvmlite | llvmlite/ir/builder.py | IRBuilder.resume | def resume(self, landingpad):
"""
Resume an in-flight exception.
"""
br = instructions.Branch(self.block, "resume", [landingpad])
self._set_terminator(br)
return br | python | def resume(self, landingpad):
"""
Resume an in-flight exception.
"""
br = instructions.Branch(self.block, "resume", [landingpad])
self._set_terminator(br)
return br | [
"def",
"resume",
"(",
"self",
",",
"landingpad",
")",
":",
"br",
"=",
"instructions",
".",
"Branch",
"(",
"self",
".",
"block",
",",
"\"resume\"",
",",
"[",
"landingpad",
"]",
")",
"self",
".",
"_set_terminator",
"(",
"br",
")",
"return",
"br"
] | Resume an in-flight exception. | [
"Resume",
"an",
"in",
"-",
"flight",
"exception",
"."
] | fcadf8af11947f3fd041c5d6526c5bf231564883 | https://github.com/numba/llvmlite/blob/fcadf8af11947f3fd041c5d6526c5bf231564883/llvmlite/ir/builder.py#L809-L815 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.