benchmark-tools


FECGSYN_benchMorph_plot


Call: function FECGSYN_exp3results

this script generates the plots for Experiment 3 as in Andreotti et al
TODO
See also:

FECGSYN_exp3results


Call: function FECGSYN_exp3results

this script extracts morphological features of NI-FECG signals and makes
TODO
See also:

FECGSYN_benchFQRS_plot


Call: function FECGSYN_benchFQRS_plot(stats,fls_orig)

stats Structure containing statistic results for FQRS
fls_orig Files containing original data (prior to extraction).
FECGSYN_benchFQRS

FECGSYN_benchMorph


Call: function FECGSYN_benchFQRS(path,debug)

this script generates statistics as in Experiment 3 by Andreotti et al 2016,
hardcoded in the function, make sure to alter it in case you include your
path Root directory where original data is saved. It is
extracted data AND and /ext/index.mat file containing
into a 'path/ext/plots' folder
Output:
contained in path.
TODO
See also:
FECGSYN_benchFQRS
FEGSYN_main_extract

FECGSYN_bss_compare


Call: function FECGSYN_bss_compare

This script used in Andreotti et al 2016, experiment 1. The experiment compares
mportant for evaluating the model order problem.

FECGSYN_genresults


Call: function FECGSYN_genresults(path_orig,fs,ch,exp3,debug)

this script generates a series of abdominal mixtures, containing i) a
effects, foetal movement etc).
Experiment 3 - Morphologycal Analysis
Input:
fs: Sampling frequency
exp3: Boolean, if 0 runs exp2 and 1 exp3
Examples:

TODO

FECGSYN_benchFQRS


Call: function FECGSYN_benchFQRS(path,debug)

this script generates statistics as in Experiment 2 by Andreotti et al 2016,
hardcoded in the function, make sure to alter it in case you include your
path Root directory where original data is saved. It is
extracted data AND and /ext/index.mat file containing
into a 'path/ext/plots' folder
Output:
contained in path.
TODO
See also:
FECGSYN_benchFQRS_plot

benchmark-tools/bibs


FECGSYN_morpho_loop


FECGSYN_morpho_loop(fecg,residual,fqrs,fs,SAMPS,fname,filterc,debug)
Call: Function to perform morphological analysis for TS/BSS extracted data

signals and generates morphological features (if possible) using the
fecg Propagated fetal signal before mixture with noise sources
fqrs Reference fetal QRS samplestamps
fname Filename to be used in saving plots
highpass (hp) and lowpass (lp)
qt_err Array containing QT error for each template
Jane, R et al. 1997 Evaluation of An Automatic Threshold Based Detector of Waveform Limits in Holter ECG
TODO
See also:
FECGSYN_manalysis

FECGSYN_QRSmincompare


Call: function [fqrs,maxch] = FECGSYN_QRSmincompare(data,fref,fs,varargin)

detection on a minute basis or pre-defined interval.
data Extracted signals
fs Sampling frequency (in Hz)
More detailed help is in the FECGSYN website.
Examples:

qrs_detect

FECGSYN_QTcalc


Call: function [qtint,th,qs,tends,tpeak,qrs] = FECGSYN_QTcalc(ann_types,ann_stamp,signal,fs)

Based on assumption that ECGPUWAVE only outputs a wave (p,N,t) if it can
are considered for further analysis.
ann_types: Type of ALL annotations obtained from ECGPUWAVE
fs: Sampling frequency
Output:
th: Height T-wave (no unit)
tends: Locations of T-wave (end)
TODO
See also:
FECGSYN_manalysis

qrs_detect


Call: function [qrs_pos,sign,en_thres, f_handle] = qrs_detect(ecg,varargin)

of the detector.
inputs
varargin
REF_PERIOD: refractory period in sec between two R-peaks (default: 0.250)
fid_vec: if some subsegments should not be used for finding the
the corresponding points here
Particularly usefull if we do window by window detection and want to
windows (which is necessary to build an FECG template)
qrs_pos: indexes of detected peak (in samples)
en_thres: energy threshold used
Examples:

TODO

FECGSYN_manalysis


Call: function [qt_ref,qt_test,tqrs_ref,tqrs_test] = FECGSYN_manalysis(abdm_temp,ref_temp,qrsabdm,qrsref,fs,filterc,filen,debug)

templates (reference and abdominal). Statistics are given in percentage.
required that the WFDB-App is installed and in Matlab's path.
Input:
ref_temp: Reference template
fs: Sampling frequency
highpass (hp) and lowpass (lp)
threshold based detector of waveform limits in Holter ECG with the QT database. In Computers in
This script is available at http://www.physionet.org/physiotools/ecgpuwave/
in the WFDB-App Toolbox: Silva, I, Moody, G. "An Open-source Toolbox for Analysing and Processing
[http://dx.doi.org/10.5334/jors.bi] ; 2014.
Examples:

TODO
See also:
FECGSYN_morpho_loop

data-generation


phase2qrs


Call: function qrs = phase2qrs(phase,debug)

with the ecg model. A qrs is defined as a zero crossing.
Input:
debug enter debug? (default: 0) [bool]
Output:

plot3_volume


Call: function plot3_volume(vols)

as well as electrodes positions. This allows for visual representation
cylinder centred on zero and normalised alond each direction (in [-0.5
in space is determined by vols.fheart and vols.mheart with a certain
vols: volume structure containing the different objects to position.
(cell of 3x1 vectors, one cell per foetus thus
vols.mheart: mother heart position in polar coordinates,
vols.elpos: electrodes position in polar coordinates
vols.Rf: rotation parameters for the foetus heart (thetaX,
vols.Rm: rotation parameters for the mother heart (thetaX,
TODO
See also:

traject_generator


Call: function traj = traject_generator(N,pos_i,pos_f,type)

trajectories may be applied to heart dipole in order to generate a more realistic
N size of the noise to generate at fs (sampling frequency) [datapoint number]
pos_f final position for trajectory [1x3 number array]
traj generated trajectory (Nx3 number matrix)
Examples:

run_ecg_generator

generate_ecg_mixture


generate_ecg_mixture(debug,SNRfm,SNRmn,mqrs,fqrs,fs,varargin)
generate ecg mixture (mecg, fecg and noise).
Input:
SNRfm: SNR of fetal signal with respect to maternal signal
mqrs: maternal qrs locations

.H - Dower-like matrix H (for propagation of dipole)
Obs: first source is taken as reference for SNR calculus
Output:
mecg: matrix containing projected maternal ECG signal
noise: cell array containing projected noise sources
TODO
See also:

generate_hrv


Call: function [theta,w] = generate_hrv(strhrv,n,fs,theta0)

in the middle of a time interval. This is meant, as an example,
extraction method to adapt to change of ECG morphology due to
strhrv:
- strhrv.lfhfr: low to high frequency ratio of the two Gaussians
lf->simulates Mayer
- strhrv.flo: center freqency of low frequency Gaussian (Mayer) [Hz]
- strhrv.acc: amplitude of acceleration(positive) or deceleration
- strhrv.typeacc: type of curve used, e.g. 'none', 'tanh', 'gauss',
- strhrv.accmean point of inflexion point or mean in percent [-1,1]
n: number of samples
theta0: initial phase of the synthetic dipole
Output:
w: angular frequency
TODO
See also:

clean_compress


Call: function out=clean_compress(out)

compresses the variables to int16 for saving disk space before saving
Input:
same as input
Examples:

run_ecg_generator

generate_breathing


Call: function bwa = generate_breathing(fs,N,fres,debug)

model the respiration pattern in order to modulate the orientation
Only the first three coefficients of the Fourier Transform of the
fs: sampling frequency [Hz]
fres: respiratory frequency [Hz]
bwa: normalised breathing waveform (range [-0.5: 0.5])
[1] Petrenas et al. "An Echo State Neural Network for QRST Cancellation During Atrial
[description for generating the breathing waveform for rotation matrix modulation]
TODO
See also:

add_cardiacdipole


theta,w,fres,R0,epos,traj,debug)
synthetic cardiac dipole generator using the 'direct form' of the cardiac
the mother or foetus as well as the Dower-like matrix that allows the
In this function the rotation of the heart axis and movement of the heart
the rotation matrix R with respect to breathing. Movement of the foetus
components of the model intend to reflect the non-stationary aspect of
matrix H (which is 2D in the case there is foetal movement and 3D in the
Input:
fs: sampling rate [Hz]
gp{1}{:}: Gaussian parameters of mother/foetus ecg - normal beats
modeling the x, y, and z coordinates of the cardiac
gp{i}{2}: structure contaning the amplitudes of Gaussian functions used for
gp{i}{3}: structure contaning the widths of Gaussian functions used for
gp{2}{:}: Gaussian parameters of moether/foetus ecg - ectopic beat
L: scaling of dipole in each direction [3x3 matrix]
w: angular frequency
R0: initial rotation angles
traj: [Nx3 matrix] representing trajectory taken by the dipole, if it has some
is the initial position of dipole [1x3 matrix]. Columns are trajectory in
debug: debug [bool]
Output:
dmodel.H: Dower-like matrix for dipole either 2D (time invariant) or 3D
dmodel.VCG: VCG for dipole
dmodel.traj: trajectory taken by dipole
dmodel.rax: max respiration angle in radian around X
dmodel.raz: max respiration angle in radian around Z
References
the VCG". Medical Engineering & Physics 25 (2003) 501-507.
maternal and foetal ECG signals." EURASIP Journal on Advances in Signal Processing
Electrocardiogram during Paroxysmal Atrial Fibrillation." Computing in
Examples:

run_ecg_generator

load_gparam


load Gaussian paramters for vcg modelling. The parameters are derived
20sec of the corresponding records.
vcgmodel: ID of Gaussian parameters to load
gp: Gaussian parameters for ECG [cell]
gp{2} = alphai

run_ecg_generator


Call: function out = run_ecg_generator(param,debug)

are modelled include: heart rate variability and sudden change in hr,
of the foetal heart modelling foetal movement and realistic noise.
representative of the reality) the positions of the maternal and foetal
coordinate system is normalised and centred on the cylinder (which is modeling
location are defined relative to each other (relative coordinate system).
ECG: electrocardiogram
FECG: foetal ECG
HR: heart rate
FHR: foetal heart rate
RSA: respiratory sinus arrhythmia
Input:
simulation.
picked randomly around it* -(default [2*pi/3 0.4
param.fheart foetus heart origin - actual location will be
-0.3]) [normalised]
param.n: number of datapoint to generate (default 15000)
param.ntype: noise type (default MA) [string]
function, e.g param.noise_fct=sin(linspace(-2*pi,2*pi,param.n)))
param.SNRm: SNR FECG/MECG (default -10)
param.fhr: foetus reference HR (default 150) [bpm]
param.facc: foetus acceleration in HR
e.g. 'none', 'mexhat', 'gauss' or 'flattop')
e.g. 'none', 'mexhat', 'gauss' or 'flattop')
'step','linear', 'spline' or 'spiral')
maternal movement). Analogous to fetal trajectory
empty then no file is saved
param.fres: respiratory frequency of foetus (default 0) [Hz]
param.fvcg: foetus vcg chosen (1-9)
param.posdev: position deviation (bool). 1: the position of the
their specified or default positions. 0: no variation.
param.fectb: add ectopic beats to foetal ECG (bool)
1: Some generated AECG
3: Projected FECG and MECG before being mixed
5: Heart rate
* This is in order to be able to produce many simulations with the heart
location. Locations are specified in polar coordinate because it is
1) and height 1. The cylinder is centered on zero.
NOTE: in the case only one input is entered, the function considers it to
simulation. The function only plots them.
Output:
mixture and all the important model information that would allow
out.mixture: generated ecg mixture [NB_EL x param.n matrix]
m_model.H: Dower-like matrix for dipole either 2D (time invariant) or 3D
m_model.VCG: VCG for dipole
out.f_model: structure contaning dipole model for the foetus [struct]
out.fecg: fecg projected signal
position)
out.fqrs: foetal reference QRS
selvcgm: selected maternal vcg [cell]
Examples:

exp_datagen1
exp_datagen3

add_noisedipole


Call: function [dmodel, f_handles, misc] = add_noisedipole(N,fs,ntype,epos,noisepos,debug)

files from the Physionet NSTDB can be used for that purpose. However there are
limited (thus if we only use these records then we will re-use them or part
2. there are only two channels available (if we want to model
individual only.
to describes the noisy time-varying processe. An AR model can be viewed
white noise. We learn these coefficients on a randomly selected segment
associated frequency response. In order to account for the uniqueness
poles, of the learned AR filter, are slightly randomly shifted while
N: size of the noise to generate at fs (sampling frequency) [datapoint number]
fs: sampling frequency [Hz]
dmodel structure contaning dipole model i.e.:
dmodel.VCG - VCG for dipole
dmodel.SNRfct - function which modulates SNR of noise. E.g.
2015.11.03 - Changes made by Julien Oster have been incorporated, several
Examples:

run_ecg_generator

extraction-methods


FECGSYN_kf_extraction


MECG cancellation algorithms using the Extended Kalman Filter/Smoother.
by Dr. Reza Sameni and and also in (Andreotti 2014)
Inputs
position of a MQRS
varargin (in this order):
fs: sampling frequency (NOTE: this code is meant to work at 1kHz)
the offline smoothing (EKS)
residual: residual containing the FECG
(Andreotti 2014) Andreotti, F., Riedl, M., Himmelsbach, T., Wedekind, D.,
detection from abdominal leads. Physiol. Meas., 35(8), 1551–1567.
(OSET) Sameni, R. (2010). The Open-Source Electrophysiological Toolbox (OSET).
Examples:

FECGSYN_ts_extraction
FECGSYN_adaptfilt_extraction

FECGSYN_adaptfilt_extraction


MECG cancellation algorithms using a adaptive filtring methods.
Least Mean Square (LMS)
Echo State Neural Network (ESN)
peaks: MQRS markers in ms. Each marker corresponds to the
ecg: matrix of abdominal ecg channels
method: method to use (LMS,RLS,ESN)
fs: sampling frequency (default = 250 Hz)
residual: residual containing the FECG
References:
Comparison of Single Channel Fetal ECG Extraction Methods. Annals of
Examples:

FECGSYN_ts_extraction
FECGSYN_kf_extraction

FECGSYN_main_extract


Call: function FECGSYN_main_extract(path,narrowband,wfdb)

bandwidths (defined in Experiment 2 and 3 of Andreotti2016). Results are
path Path where datasets are saved
wfdb Load data in WFDB format? [boolean]
exp_datagen1
exp_datagen1
FECGSYN_adaptfilt_extraction
FECGSYN_ts_extraction

FECGSYN_ts_extraction


Template subtraction for MECG cancellation. Five template subtraction techniques
technique is required then an the EKF technique as in (Sameni 2007) is recommended.
inputs
position of a MQRS
method: method to use ('TS','TS-CERUTTI','TS-SUZANNA','TS-LP','TS-PCA')
a scalar gain (Cerutti 1986)
TS-SUZANNA - the scaling procedure was performed for the P, QRS,
order to minimize the mean square error (as opposed to the other TS
next a back-propagation step takes place on a beat-to-beat basis, thus
varargin:
NbPC: number of principal components to use for PCA
residual: residual containing the FECG
References:
Variability analysis of fetal heart rate signals as obtained from abdominal
(Kanjilal 1997) Kanjilal P P, Palit S and Saha G 1997 Fetal ECG extraction
Trans. Biomed. Eng. 44 51–9
robust fetal ECG detection method for abdominal recordings Physiol. Meas. 28 373–88
(Vullings 2009) Vullings R, Peters C, Sluijter R, Mischi M, Oei S G and
abdominal recordings Physiol. Meas. 30 291
TODO
See also:
FECGSYN_bss_extraction
FEGSYN_main_extract

FECGSYN_bss_extraction


Uses Blind Source Separation Methods for FECG extraction given a
terms of F1-measure, is picked as best channel.
Available methods:
Principal Component Analysis (PCA)
Input
method: String containing method name i.e. 'ICA' or 'PCA'
blen: Divide signal into segment of blen length
refqrs: Array containing reference QRS detections for F1 measure
blen: Iterates method every blen (in seconds)
out_comps: selected best channels on every block
W: used mixing matrices
TODO
See also:
FECGSYN_kf_extraction
FEGSYN_main_extract

utils


FECGSYN_plotmix


Call: Function to plot generated mixtures

This functin plots Nplots channels from fecgsyn's internal struct "out".

wfdb2fecgsyn


Call: function out = wfdb2fecgsyn(path)

path complete path for wfdb file, including identifying name
outstr structure used by fecgsyn toolbox
TODO
See also:

Bxb_compare


This function is similar to the function bxb.exe from Physionet's
match the reference. The algorithm is based on the entry by Joachim Behar
EC57 Norm 1998
Input
testqrs: detections to be tested against
Output
ACC: accuracy (by Karvounis 2007) - alternative to F1
SE: sensitivity
FN: number of false negatives
[ANSI/AAMI Norm] American National Standard ANSI/AAMI EC57:1998, Testing and Reporting Performance
in MATLAB and Octave." Journal of Open Research Software 2(1):e27 [http://dx.doi.org/10.5334/jors.bi];
ECG Extraction Without Maternal or Scalp Electrode Data. Physiological Measurement, 35(8), 1569–1589.

fecgsyn2wfdb


Call: function fecgsyn2wfdb(argument)

Physionet's WFDB format.
Input:
or save path (if second argument is additionally given)
filename if single file, destination filename is required
TODO
See also:

utils/file_manipulation