Skip to content

Commit 9a53a8c

Browse files
committed
New release 0.2.0
1 parent 109161f commit 9a53a8c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+7527
-10653
lines changed

.gitignore

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
*.pyc
2-
.cache/*
3-
__pycache__
4-
__pycache__/*
5-
*/__pycache__/*
6-
.ipynb_checkpoints
2+
docs/_build/
3+
.cache/
4+
__pycache__/
5+
.ipynb_checkpoints/

README.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44

55
Main features:
66

7-
* load and save signal in various formats (wfdb, blosc, etc)
7+
* load and save signal in various formats (wfdb, DICOM, EDF, etc)
88
* resample, crop, flip and filter signals
99
* detect PQ, QT, QRS segments
1010
* calculate heart rate and other ECG characteristics
11-
* apply complex transformations like fft and wavelets, as well as custom functions
11+
* perform complex processing like fourier and wavelet transformations
12+
* applpy custom functions to the data
1213
* recognize heart diseases (e.g. atrial fibrillation)
1314
* efficiently work with large datasets that do not even fit into memory
1415
* perform end-to-end ECG processing
15-
* build, train and test neural networks and other machine learning models.
16+
* build, train and test neural networks and other machine learning models
1617

1718
For more details see [the documentation and tutorials](https://analysiscenter.github.io/cardio/).
1819

@@ -22,45 +23,44 @@ For more details see [the documentation and tutorials](https://analysiscenter.gi
2223
> CardIO is based on [Dataset](https://github.com/analysiscenter/dataset). You might benefit from reading [its documentation](https://analysiscenter.github.io/dataset).
2324
However, it is not required, especially at the beginning.
2425

25-
CardIO has three modules: [``batch``](https://analysiscenter.github.io/cardio/intro/batch.html),
26-
[``models``](https://analysiscenter.github.io/cardio/intro/models.html) and
27-
[``pipelines``](https://analysiscenter.github.io/cardio/intro/pipeline.html).
2826

29-
``batch`` module contains ``EcgBatch`` class which defines how ECG are stored and includes actions for ECG processing.
30-
These actions might be used to build multi-staged workflows that can also involve machine learning models.
27+
CardIO has three modules: [``core``](https://analysiscenter.github.io/cardio/modules/core.html),
28+
[``models``](https://analysiscenter.github.io/cardio/modules/models.html) and
29+
[``pipelines``](https://analysiscenter.github.io/cardio/modules/pipelines.html).
30+
31+
32+
``core`` module contains ``EcgBatch`` and ``EcgDataset`` classes.
33+
``EcgBatch`` defines how ECGs are stored and includes actions for ECG processing. These actions might be used to build multi-staged workflows that can also involve machine learning models. ``EcgDataset`` is a class that stores indices of ECGs and generates batches of type ``EcgBatch``.
3134

3235
``models`` module provides several ready to use models for important problems in ECG analysis:
33-
* how to detect specific features of ECG like R-peaks, P-wave, T-wave, etc;
34-
* how to recognize heart diseases from ECG, for example, atrial fibrillation.
36+
37+
* how to detect specific features of ECG like R-peaks, P-wave, T-wave, etc
38+
* how to recognize heart diseases from ECG, for example, atrial fibrillation
3539

3640
``pipelines`` module contains predefined workflows to
37-
* train a model to detect PQ, QT, QRS segments
38-
* calculate heart rate
39-
* train a model to find probabilities of heart diseases, in particular, atrial fibrillation.
4041

41-
Under the hood these methods contain actions that load signals, filter it and do complex calculations.
42+
* train a model and perform an inference to detect PQ, QT, QRS segments and calculate heart rate
43+
* train a model and perform an inference to find probabilities of heart diseases, in particular, atrial fibrillation
4244

4345

4446
## Basic usage
4547

4648
Here is an example of pipeline that loads ECG signals, makes preprocessing and train a model over 50 epochs:
4749
```python
4850
train_pipeline = (
49-
dataset.train
50-
.pipeline
51-
.init_model("dynamic", DirichletModel, name="dirichlet",
52-
config=model_config)
53-
.init_variable("loss_history", init=list)
54-
.load(components=["signal", "meta"], fmt="wfdb")
55-
.load(components="target", fmt="csv", src=LABELS_PATH)
56-
.drop_labels(["~"])
57-
.replace_labels({"N": "NO", "O": "NO"})
58-
.flip_signals()
59-
.random_resample_signals("normal", loc=300, scale=10)
60-
.random_split_signals(2048, {"A": 9, "NO": 3})
61-
.binarize_labels()
62-
.train_model("dirichlet", make_data=make_data, fetches="loss", save_to=V("loss_history"), mode="a")
63-
.run(batch_size=100, shuffle=True, drop_last=True, n_epochs=50)
51+
ds.Pipeline()
52+
.init_model("dynamic", DirichletModel, name="dirichlet", config=model_config)
53+
.init_variable("loss_history", init_on_each_run=list)
54+
.load(components=["signal", "meta"], fmt="wfdb")
55+
.load(components="target", fmt="csv", src=LABELS_PATH)
56+
.drop_labels(["~"])
57+
.rename_labels({"N": "NO", "O": "NO"})
58+
.flip_signals()
59+
.random_resample_signals("normal", loc=300, scale=10)
60+
.random_split_signals(2048, {"A": 9, "NO": 3})
61+
.binarize_labels()
62+
.train_model("dirichlet", make_data=concatenate_ecg_batch, fetches="loss", save_to=V("loss_history"), mode="a")
63+
.run(batch_size=100, shuffle=True, drop_last=True, n_epochs=50)
6464
)
6565
```
6666

@@ -88,7 +88,7 @@ import cardio
8888
```
8989

9090

91-
### Installation as a project repository:
91+
### Installation as a project repository
9292

9393
When cloning repo from GitHub use flag ``--recursive`` to make sure that ``Dataset`` submodule is also cloned.
9494

RELEASE.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Release 0.2.0
2+
3+
## Major Features and Improvements
4+
* `load` method now supports new signal formats:
5+
* DICOM
6+
* EDF
7+
* wav
8+
* `meta` component structure has changed - now it always contains a number of predefined keys.
9+
* Added channels processing methods:
10+
* `EcgBatch.keep_channels`
11+
* `EcgBatch.drop_channels`
12+
* `EcgBatch.rename_channels`
13+
* Added `apply_to_each_channel` method.
14+
* Added `standardize` method.
15+
* Added complex ECG transformations:
16+
* Fourier-based transformations:
17+
* `EcgBatch.fft`
18+
* `EcgBatch.ifft`
19+
* `EcgBatch.rfft`
20+
* `EcgBatch.irfft`
21+
* `EcgBatch.spectrogram`
22+
* Wavelet-based transformations:
23+
* `EcgBatch.dwt`
24+
* `EcgBatch.idwt`
25+
* `EcgBatch.wavedec`
26+
* `EcgBatch.waverec`
27+
* `EcgBatch.pdwt`
28+
* `EcgBatch.cwt`
29+
30+
## Breaking Changes to the API
31+
* Changed signature of the following methods:
32+
* `EcgBatch.apply_transform`
33+
* `EcgBatch.show_ecg`
34+
* `EcgBatch.calc_ecg_parameters`
35+
* Changed signature of the following pipelines:
36+
* `dirichlet_train_pipeline`
37+
* `dirichlet_predict_pipeline`
38+
* `hmm_preprocessing_pipeline`
39+
* `hmm_train_pipeline`
40+
* `hmm_predict_pipeline`
41+
* `wavelet_transform` method has been deleted.
42+
* `update` method has been deleted.
43+
* `replace_labels` method has been renamed to `rename_labels`.
44+
* `slice_signal` method has been renamed to `slice_signals`.
45+
* `ravel` method has been renamed to `unstack_signals`.
46+
47+
48+
# Release 0.1.0
49+
50+
Initial release of CardIO.

cardio/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
""" ECG package """
2-
import sys
1+
""" CardIO package """
32

4-
from .batch import * # pylint: disable=wildcard-import
53
from . import dataset # pylint: disable=wildcard-import
4+
from .core import * # pylint: disable=wildcard-import
65

76

8-
__version__ = '0.1.0'
7+
__version__ = '0.2.0'

cardio/batch/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

cardio/core/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
""" Core CardIO objects """
2+
3+
from .ecg_batch import EcgBatch, add_actions
4+
from .ecg_dataset import EcgDataset
5+
from . import kernels

0 commit comments

Comments
 (0)