pyPSG other modules
This section covers additional pyPSG modules, including example function and utility tools for signal processing
pyPSG.pypsg_example
- pyPSG.pypsg_example.pypsg_example(edf_path=None, matlab_path=None, channels={'ecg': '', 'ppg': '', 'spo2': ''})
Demonstrates the usage of the pyPSG toolbox to read an EDF file, visualize raw signals, compute heart rate variability (HRV) and beat rate variability (BRV), and extract biomarkers for PPG, ECG, and SpO₂ signals.
- Parameters:
edf_path (str) – Path to the EDF file containing the physiological signals.
matlab_path (str) – Path to the MATLAB executable (required for ECG fiducial point detection and HRV computation).
channels (dict) – Dictionary mapping signal types to EDF channel names. Keys can include “ppg”, “ecg”, and “spo2”. Values are the corresponding channel names in the EDF file. Empty string values indicate that a channel should be ignored.
- Returns:
None. The function generates plots of the raw data and HRV/BRV, extracts biomarkers for the available channels, and saves them into a .mat file in the directory temp_dir/biomarkers.
- Return type:
None
pyPSG.utils
- class pyPSG.utils.HiddenPrints
Bases:
objectContext manager to temporarily suppress console output.
- pyPSG.utils.plot_leads(signals, fs, leads=range(0, 12), labels=[''], peaks=None, figsize=(8, 4))
Plots multiple ECG leads from one or more signals with optional peak markers.
- Parameters:
signals (list of np.ndarray) – List of 2D numpy arrays, each representing an ECG signal (samples x leads).
fs (float) – Sampling frequency of the signals in Hz.
leads (iterable of int, optional) – Indices of leads to plot. Defaults to all 12 leads.
labels (list of str, optional) – List of labels for each signal, used in the legend.
peaks (dict, optional) – Dictionary of peak positions to overlay on the plots, keys are labels and values are 2D arrays (samples x leads).
figsize (tuple, optional) – Figure size in inches (width, height).
- Returns:
None
- pyPSG.utils.select_file(title='Select file', filetypes=[('EDF files', '*.edf')])
Open a file dialog and return the selected file path.
- Parameters:
title (str) – Dialog window title.
filetypes (list of tuple) – List of (label, pattern) tuples defining selectable file types.
- Returns:
Selected file path, or empty string if cancelled.
- Return type:
str