ltbio.biosignals.modalities#

Overview#

Submodules#

Classes#

ACC

-

ECG

-

EDA

A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable.

EEG

A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable.

EMG

-

HR

-

PPG

A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable.

RESP

A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable.

TEMP

A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable.

Contents#

class ltbio.biosignals.modalities.ACC(timeseries, source=None, patient=None, acquisition_location=None, name=None)#

Bases: ltbio.biosignals.modalities.Biosignal.Biosignal

digraph inheritanceb77bafae05 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "ACC" [URL="ACC/index.html#ltbio.biosignals.modalities.ACC.ACC",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "Biosignal" -> "ACC" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Biosignal" [URL="Biosignal/index.html#ltbio.biosignals.modalities.Biosignal.Biosignal",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable."]; "ABC" -> "Biosignal" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
DEFAULT_UNIT#
plot_summary(show: bool = True, save_to: str = None)#
class ltbio.biosignals.modalities.ECG(timeseries, source=None, patient=None, acquisition_location=None, name=None)#

Bases: ltbio.biosignals.modalities.Biosignal.Biosignal

digraph inheritance10f4dc8352 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "Biosignal" [URL="Biosignal/index.html#ltbio.biosignals.modalities.Biosignal.Biosignal",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable."]; "ABC" -> "Biosignal" [arrowsize=0.5,style="setlinewidth(0.5)"]; "ECG" [URL="ECG/index.html#ltbio.biosignals.modalities.ECG.ECG",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "Biosignal" -> "ECG" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
DEFAULT_UNIT#
basSQI(by_segment: bool = False)#

Computes the ration between [0, 1] Hz and [0, 40] Hz frequency power bands. If by_segment is True, a list of values is returned for each contiguous uninterrupted segment, otherwise the weighted average is returned. Weighted by duration of each segment.

Adequate to evaluate the presence of baseline drift. Values between [0.95, 1] mean ECG shows optimal quality.

Returns:

A dictionary of the computed ratio for each channel.

bsSQI(by_segment: bool = False)#

Checks baseline wander in time domain. If by_segment is True, a list of values is returned for each contiguous uninterrupted segment, otherwise the weighted average is returned. Weighted by duration of each segment.

Meant to evaluate the presence of baseline wander. Ref: https://www.sciencedirect.com/science/article/pii/S0169260714003241?via%3Dihub#bib0040

Returns:

A dictionary of the computed ratio for each channel.

flatline_percentage(by_segment: bool = False)#

Computes the % of flatline of each channel. If by_segment is True, a list of values is returned for each contiguous uninterrupted segment, otherwise the weighted average is returned. Weighted by duration of each segment.

Returns:

A dictionary of % of flatline value(s) for each channel.

heartbeats(before=0.2, after=0.4)#

Segment the signal by heartbeats. Works like a Segmenter, except output Timeseries is not necessarily equally segmented.

beforefloat, optional

Window size to include before the R peak (seconds).

afterint, optional

Window size to include after the R peak (seconds).

heartbeatsECG

Biosignal segmented where each Segment is a heartbeat.

If filtered, the raw samples are not recoverable by ‘undo_filters’.

hr(smooth_length: float = None)#

Transform ECG signal to instantaneous heart rate.

smooth_lengthfloat, optional

Length of smoothing window. If not given, no smoothing is performed on the instantaneous heart rate.

hrHR

Pseudo-Biosignal where samples are the instantaneous heart rate at each timepoint.

invert_if_necessary()#

Investigates which ECG channels need to be inverted, and, the ones that do, get inverted just like method ‘invert’. Based on the median of the R-peaks amplitudes. Works preferably with leads I and II.

None

None

kurtosis(by_segment: bool = False)#

Computes the kurtosis of each channel. If by_segment is True, a list of kurtosis values is returned for each contiguous uninterrupted segment, otherwise the weighted average is returned. Weighted by duration of each segment.

If kurtosis <= 5, it means there’s a great amount of noise present.

Returns:

A dictionary of kurtosis value(s) for each channel.

nni()#

Transform ECG signal to an evenly-sampled R-R peak interval (RRI/NNI) signal. Interpolation is used. It is assumed the ECG only has one channel.

nniECG

Pseudo-Biosignal where each sample is the interval of the R peak ‘occured there’ and the previous R peak.

pSQI(by_segment: bool = False)#

Computes the ration between [5, 15] Hz and [5, 40] Hz frequency power bands. If by_segment is True, a list of values is returned for each contiguous uninterrupted segment, otherwise the weighted average is returned. Weighted by duration of each segment.

Values between [0.5, 0.8] mean QRS complexes show high quality.

Returns:

A dictionary of the computed ratio for each channel.

plot_rpeaks(show: bool = True, save_to: str = None)#
plot_summary(show: bool = True, save_to: str = None)#
qSQI(by_segment: bool = False)#

Evaluates agreement between two R detectors. If by_segment is True, a list of values is returned for each contiguous uninterrupted segment, otherwise the weighted average is returned. Weighted by duration of each segment.

Values > 90% mean optimal R-peak consensus.

Returns:

A dictionary of the computed qSQI for each channel.

r_timepoints(algorithm='hamilton', _by_segment=False) tuple#

Finds the timepoints of the R peaks.

@param algoritm (optional): The algorithm used to compute the R peaks. Default: Hamilton segmenter. @param _by_segment (optional): Return timepoints grouped by uninterrptuned segments.

@returns: The ordered sequence of timepoints of the R peaks. @rtype: np.array

Note: Index one channel first.

skewness(by_segment: bool = False) dict[str:float | list[float]]#

Computes the skweness of each channel. If by_segment is True, a list of skweness values is returned for each contiguous uninterrupted segment, otherwise the weighted average is returned. Weighted by duration of each segment. :return: A dictionary of skewness value(s) for each channel.

zhaoSQI(by_segment: bool = False)#
class ltbio.biosignals.modalities.EDA(timeseries, source=None, patient=None, acquisition_location=None, name=None)#

Bases: ltbio.biosignals.modalities.Biosignal.Biosignal

digraph inheritancec44801c31f { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "Biosignal" [URL="Biosignal/index.html#ltbio.biosignals.modalities.Biosignal.Biosignal",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable."]; "ABC" -> "Biosignal" [arrowsize=0.5,style="setlinewidth(0.5)"]; "EDA" [URL="EDA/index.html#ltbio.biosignals.modalities.EDA.EDA",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "Biosignal" -> "EDA" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable. It may be associated with a source, a patient, and a body location. It can also have a name. It has an initial and final datetime. Its length is its number of channels. It can be resampled, filtered, and concatenated to other Biosignals. Amplitude and spectrum plots can be displayed and saved.

DEFAULT_UNIT#
plot_summary(show: bool = True, save_to: str = None)#

Plots a summary of relevant aspects of common analysis of the Biosignal.

class ltbio.biosignals.modalities.EEG(timeseries, source=None, patient=None, acquisition_location=None, name=None)#

Bases: ltbio.biosignals.modalities.Biosignal.Biosignal

digraph inheritance0be53a4365 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "Biosignal" [URL="Biosignal/index.html#ltbio.biosignals.modalities.Biosignal.Biosignal",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable."]; "ABC" -> "Biosignal" [arrowsize=0.5,style="setlinewidth(0.5)"]; "EEG" [URL="EEG/index.html#ltbio.biosignals.modalities.EEG.EEG",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "Biosignal" -> "EEG" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable. It may be associated with a source, a patient, and a body location. It can also have a name. It has an initial and final datetime. Its length is its number of channels. It can be resampled, filtered, and concatenated to other Biosignals. Amplitude and spectrum plots can be displayed and saved.

DEFAULT_UNIT#
plot_summary(show: bool = True, save_to: str = None)#

Plots a summary of relevant aspects of common analysis of the Biosignal.

class ltbio.biosignals.modalities.EMG(timeseries, source=None, patient=None, acquisition_location=None, name=None)#

Bases: ltbio.biosignals.modalities.Biosignal.Biosignal

digraph inheritance5219908b9f { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "Biosignal" [URL="Biosignal/index.html#ltbio.biosignals.modalities.Biosignal.Biosignal",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable."]; "ABC" -> "Biosignal" [arrowsize=0.5,style="setlinewidth(0.5)"]; "EMG" [URL="EMG/index.html#ltbio.biosignals.modalities.EMG.EMG",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "Biosignal" -> "EMG" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
DEFAULT_UNIT#
plot_summary(show: bool = True, save_to: str = None)#
class ltbio.biosignals.modalities.HR(timeseries, source=None, patient=None, acquisition_location=None, name=None, original_signal: ECG | PPG = None)#

Bases: ltbio.biosignals.modalities.Biosignal.Biosignal

digraph inheritance72c1380760 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "Biosignal" [URL="Biosignal/index.html#ltbio.biosignals.modalities.Biosignal.Biosignal",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable."]; "ABC" -> "Biosignal" [arrowsize=0.5,style="setlinewidth(0.5)"]; "HR" [URL="HR/index.html#ltbio.biosignals.modalities.HR.HR",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "Biosignal" -> "HR" [arrowsize=0.5,style="setlinewidth(0.5)"]; }
plot_summary(show: bool = True, save_to: str = None)#
class ltbio.biosignals.modalities.PPG(timeseries, source=None, patient=None, acquisition_location=None, name=None, **options)#

Bases: ltbio.biosignals.modalities.Biosignal.Biosignal

digraph inheritance881f7d0c36 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "Biosignal" [URL="Biosignal/index.html#ltbio.biosignals.modalities.Biosignal.Biosignal",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable."]; "ABC" -> "Biosignal" [arrowsize=0.5,style="setlinewidth(0.5)"]; "PPG" [URL="PPG/index.html#ltbio.biosignals.modalities.PPG.PPG",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "Biosignal" -> "PPG" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable. It may be associated with a source, a patient, and a body location. It can also have a name. It has an initial and final datetime. Its length is its number of channels. It can be resampled, filtered, and concatenated to other Biosignals. Amplitude and spectrum plots can be displayed and saved.

DEFAULT_UNIT#
plot_summary(show: bool = True, save_to: str = None)#

Plots a summary of relevant aspects of common analysis of the Biosignal.

class ltbio.biosignals.modalities.RESP(timeseries, source=None, patient=None, acquisition_location=None, name=None)#

Bases: ltbio.biosignals.modalities.Biosignal.Biosignal

digraph inheritance6dd1892b73 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "Biosignal" [URL="Biosignal/index.html#ltbio.biosignals.modalities.Biosignal.Biosignal",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable."]; "ABC" -> "Biosignal" [arrowsize=0.5,style="setlinewidth(0.5)"]; "RESP" [URL="RESP/index.html#ltbio.biosignals.modalities.RESP.RESP",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "Biosignal" -> "RESP" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable. It may be associated with a source, a patient, and a body location. It can also have a name. It has an initial and final datetime. Its length is its number of channels. It can be resampled, filtered, and concatenated to other Biosignals. Amplitude and spectrum plots can be displayed and saved.

DEFAULT_UNIT#
plot_summary(show: bool = True, save_to: str = None)#

Plots a summary of relevant aspects of common analysis of the Biosignal.

class ltbio.biosignals.modalities.TEMP(timeseries, source=None, patient=None, acquisition_location=None, name=None)#

Bases: ltbio.biosignals.modalities.Biosignal.Biosignal

digraph inheritance5173a4622c { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "Biosignal" [URL="Biosignal/index.html#ltbio.biosignals.modalities.Biosignal.Biosignal",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable."]; "ABC" -> "Biosignal" [arrowsize=0.5,style="setlinewidth(0.5)"]; "TEMP" [URL="TEMP/index.html#ltbio.biosignals.modalities.TEMP.TEMP",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "Biosignal" -> "TEMP" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

A Biosignal is a set of channels (Timeseries), each of which with samples measuring a biological variable. It may be associated with a source, a patient, and a body location. It can also have a name. It has an initial and final datetime. Its length is its number of channels. It can be resampled, filtered, and concatenated to other Biosignals. Amplitude and spectrum plots can be displayed and saved.

DEFAULT_UNIT#
plot_summary(show: bool = True, save_to: str = None)#

Plots a summary of relevant aspects of common analysis of the Biosignal.