Change point detection algorithms for segmenting time series data.
Segmentation performance of eight different algorithms is tested in this repo.
HRVToolbox for real data analysis part
- Install R Studio to implement BCP method. Add 'bcp' package which is located here: https://cran.r-project.org/web/packages/bcp/index.html
Add also stingr package: install_package("stringr")
-
Install NAG MATLAB toolbox from following address: https://www.nag.com/content/downloads-nag-toolbox-matlab-versions
-
The executable "rrgenV3" is compiled for macOS. For other operating systems, follow these steps:
-
cd into rrGenerator folder
-
Delete
rrgenV3
since this executable is for mac -
Compile
rrgenV3.c
into executable:gcc -Wall rrgenV3.c -lm -o rrgenV3
-
Test the executable by calling
rrgenV3
from the terminal, using the number1
as a seed, and setting max elements to200
:
./rrgenV3 1 200
% For mac computer
:rrgenV3 1 200
% For windows computer
You should see output printed to the terminal.
- Modified Bayesian Online Changepoint Detection (Modified BOCD):
bocpd_revised.m
- Original Bayesian Online Changepoint Detection (Original BOCD):
bocpd_original.m
- Bayesian Blocks (BBLOCKS):
bblocks.m
- Pruned Exact Linear Time (PELT1) from NAG MATLAB toolbox
- Matlab function (PELT2) 'findchangepts'
- Binary Segmentation (BiS) from NAG MATLAB toolbox
- Recursive Mean Difference Maximization (RMDM) :
rmdm.m
Includes 2 versions,rmdm.m_v1
is written by Maxim Osipov andrmdm.m
is the modified version. - Bayesian Analysis of Changepoint Problems (BCP) :
bcp_testRRGEN.R
Physionet capslpdb database is located here: https://www.physionet.org/pn6/capslpdb/
-
Download hypnograms from above address.
-
Download EKG files in csv format.
ex: rdsamp -r capslpdb/n5.edf -H -f 0 -ps -c >n5.csv -
Arrange files in same format as CPD/Toolbox/testData/physionet_capslpdb. EKG file and hypnogram of same subject should be named the same. ex.: n1.txt
-
/bin/bash: Rscript: command not found
Add where R is located to your MATLAB environment
setenv('PATH', [getenv('PATH'),':','/usr/local/bin']); -
In artificial data analysis, no data is generated Make sure your rrgenV3 executable is suitable for your computer type. If not, delete this and re compile as decribed above.
Related to setting up parameters of NAG functions:
PELT: https://www.nag.com/numeric/mb/nagdoc_mb/manual_25_1/html/g13/g13naf.html
BiS: https://www.nag.com/numeric/mb/nagdoc_mb/manual_25_1/html/g13/g13ndf.html