Input-output
- pyPCG.io.read_signal_file(path: str, format: str) tuple[ndarray[tuple[int, ...], dtype[int64]], int][source]
Read in fetal heartsound containing file
Supported file formats:
wav: wav file
mat: MATLAB file (containing two variables: fs-samplerate, sig-signal data)
raw: raw binary (headerless)
FETA: every second byte is PCG data (headerless)
1k: 1 kB chunks (CURRENTLY UNTESTED)
- Parameters:
path (str) – Path to input file
format (str) – File format identification
- Returns:
Unprocessed heartsound signal read in from file, and sample rate in Hz. If the input file was headerless, then the value is 0
- Return type:
tuple[np.ndarray,int]
Example
Read in a 1 min wav file with 333 Hz samplerate
>>> import pyPCG.io as pcg_io >>> data, fs = pcg_io.read_signal_file("example.wav","wav") >>> print(len(data),fs) 19980 333
Raw binary file reading: >>> import pyPCG.io as pcg_io >>> data, fs = pcg_io.read_signal_file(“example.dat”,”raw”) >>> print(len(data),fs) 19980 0
- pyPCG.io.read_hsannot_file(fpath: str) tuple[list[float], list[float]][source]
Reads manually labeled heartsounds from annotation csv file
The csv format has to be the following:
Location: heartsound location in seconds
Value: heartsound type of “S1” or “S2”
- Parameters:
fpath (str) – path to annotation file
- Returns:
S1 and S2 annotation locations
- Return type:
tuple[list[float],list[float]]