Skip to content

Commit

Permalink
Rlign v1.1 (#2)
Browse files Browse the repository at this point in the history
* Fix offset and simplify template handling

* Added different beat aggregation methods

* Update hrc-method (#3)

* Updated examples 

* Added test-CICD
  • Loading branch information
l-bick authored Sep 17, 2024
1 parent 48f8185 commit e321ea5
Show file tree
Hide file tree
Showing 12 changed files with 488 additions and 248 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/gitlab-mirror-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Mirror and run GitLab CI
on:
push:
branches:
- main
- main
- 'dev-*'
workflow_dispatch: {} # manual dispatch

jobs:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ __pycache__/
*$py.class
.DS_Store
.idea/*
.vscode/*

# C extensions
*.so
Expand Down
12 changes: 12 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
stages:
- test
- build

tests:
stage: test
image: python:3.11-slim-bookworm
environment: production
before_script:
- pip install pytest
script:
- pip install .
- pytest -W error test/


build:
stage: build
image: python:3.11-slim-bookworm
Expand Down
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ normalizer = rlign.Rlign(scale_method='hrc')
ecg_aligned = normalizer.transform(ecg)

# You can set different configuration like median_beat-averaging or the template_bpm
normalizer = rlign.Rlign(scale_method='hrc', median_beat=True, template_bpm=80)
normalizer = rlign.Rlign(scale_method='hrc', agg_beat='median', template_bpm=80)

ecg_aligned_80hz = normalizer.transform(ecg)
ecg_aligned_80bpm = normalizer.transform(ecg)
```

### Configurations

* `sampling_rate`: Defines the sampling rate for all ECG recordings and the template. Default is set to 500.

* `seconds_len`: Determines the duration of all ECG recordings and the template in seconds.
* `seconds_len`: Determines the duration of all ECG recordings and the template in seconds. Default is 10 (sec).

* `template_bpm`: The desired normalized BPM value for the template.
This parameter sets the heart rate around which the QRST pattern
is structured, thereby standardizing the R-peak positions according to a specific BPM.

* `offset`: The offset specifies the starting point for the first normalized QRS complex in the
template. In percentage of sampling_rate. Default is set to 0.5.
template. In percentage of sampling_rate. Default is set to 0.01.

* `select_lead`: Specifies the lead (e.g., 'Lead II', 'Lead V1') for R-peak detection.
Different leads can provide varying levels of clarity for these features.
Expand All @@ -62,11 +62,11 @@ ecg_aligned_80hz = normalizer.transform(ecg)

* `neurokit_method`: Chooses the algorithm for R-peak detection from the
NeuroKit package. Different algorithms may offer varying performance
based on the ECG signal characteristics.
based on the ECG signal characteristics. Default is 'neurokit'.

* `correct_artifacts`: If set to True, artifact correction is applied
exclusively for R-peak detections, enhancing the accuracy of peak
identification in noisy signals.
identification in noisy signals. Default is True.

* `scale_method`: Selects the scaling method from options like 'resampling'
or 'hrc'. This choice dictates the interval used for resampling
Expand All @@ -77,10 +77,16 @@ ecg_aligned_80hz = normalizer.transform(ecg)
set to True, the problematic ECG is excluded from the dataset. If False,
the original, unscaled ECG signal is returned instead. Default is False.

* `median_beat`: Calculates the median from a set of aligned beats
and returns a single, representative beat.
* `agg_beat`: Calculates the aggregated beat from a set of aligned beats
and returns a single, representative beat if using 'mean' or 'median'.
'list' returns the additional dimension of aligned beats without per-lead
aggregation. 'none' disables any aggregation and returns as a time-series.
Also works with a lambda function, such as 'np.std'. Default is 'none'.

* `silent`: Disable all warnings. Default True.
* `detrend`: Detrend each beat individually using the robust median of slopes.
This is only computed if using `agg_beat`. Default is True.

* `silent`: Disable all warnings. Default is True.

## Citation
Please use the following citation:
Expand Down
158 changes: 158 additions & 0 deletions examples/agg_modes.ipynb

Large diffs are not rendered by default.

69 changes: 35 additions & 34 deletions examples/example.ipynb

Large diffs are not rendered by default.

71 changes: 36 additions & 35 deletions examples/example_hz.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ requires = [

[project]
name='rlign'
version='1.0.post2'
version='1.1'
description='Beat normalization for ECG data.'
readme = "README.md"
requires-python = ">=3.11"
requires-python = ">=3.10"
authors=[
{name="Lucas Bickmann"},
{name="Lucas Plagwitz"}
]
dependencies = [
'neurokit2>=0.2.7',
'neurokit2>=0.2.10',
'numpy>=1.24.2',
'scipy>=1.12.0',
'pandas>=2.2.0',
Expand Down
Loading

0 comments on commit e321ea5

Please sign in to comment.