Skip to content

Commit

Permalink
Merge pull request #6 from analysiscenter/release
Browse files Browse the repository at this point in the history
New release 0.2.0
  • Loading branch information
roman-kh authored Jan 20, 2018
2 parents 109161f + 9a53a8c commit 4b49825
Show file tree
Hide file tree
Showing 60 changed files with 7,527 additions and 10,653 deletions.
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.pyc
.cache/*
__pycache__
__pycache__/*
*/__pycache__/*
.ipynb_checkpoints
docs/_build/
.cache/
__pycache__/
.ipynb_checkpoints/
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

Main features:

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

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

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

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

``batch`` module contains ``EcgBatch`` class which defines how ECG 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.
CardIO has three modules: [``core``](https://analysiscenter.github.io/cardio/modules/core.html),
[``models``](https://analysiscenter.github.io/cardio/modules/models.html) and
[``pipelines``](https://analysiscenter.github.io/cardio/modules/pipelines.html).


``core`` module contains ``EcgBatch`` and ``EcgDataset`` classes.
``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``.

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

* how to detect specific features of ECG like R-peaks, P-wave, T-wave, etc
* how to recognize heart diseases from ECG, for example, atrial fibrillation

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

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


## Basic usage

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

Expand Down Expand Up @@ -88,7 +88,7 @@ import cardio
```


### Installation as a project repository:
### Installation as a project repository

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

Expand Down
50 changes: 50 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Release 0.2.0

## Major Features and Improvements
* `load` method now supports new signal formats:
* DICOM
* EDF
* wav
* `meta` component structure has changed - now it always contains a number of predefined keys.
* Added channels processing methods:
* `EcgBatch.keep_channels`
* `EcgBatch.drop_channels`
* `EcgBatch.rename_channels`
* Added `apply_to_each_channel` method.
* Added `standardize` method.
* Added complex ECG transformations:
* Fourier-based transformations:
* `EcgBatch.fft`
* `EcgBatch.ifft`
* `EcgBatch.rfft`
* `EcgBatch.irfft`
* `EcgBatch.spectrogram`
* Wavelet-based transformations:
* `EcgBatch.dwt`
* `EcgBatch.idwt`
* `EcgBatch.wavedec`
* `EcgBatch.waverec`
* `EcgBatch.pdwt`
* `EcgBatch.cwt`

## Breaking Changes to the API
* Changed signature of the following methods:
* `EcgBatch.apply_transform`
* `EcgBatch.show_ecg`
* `EcgBatch.calc_ecg_parameters`
* Changed signature of the following pipelines:
* `dirichlet_train_pipeline`
* `dirichlet_predict_pipeline`
* `hmm_preprocessing_pipeline`
* `hmm_train_pipeline`
* `hmm_predict_pipeline`
* `wavelet_transform` method has been deleted.
* `update` method has been deleted.
* `replace_labels` method has been renamed to `rename_labels`.
* `slice_signal` method has been renamed to `slice_signals`.
* `ravel` method has been renamed to `unstack_signals`.


# Release 0.1.0

Initial release of CardIO.
7 changes: 3 additions & 4 deletions cardio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
""" ECG package """
import sys
""" CardIO package """

from .batch import * # pylint: disable=wildcard-import
from . import dataset # pylint: disable=wildcard-import
from .core import * # pylint: disable=wildcard-import


__version__ = '0.1.0'
__version__ = '0.2.0'
3 changes: 0 additions & 3 deletions cardio/batch/__init__.py

This file was deleted.

5 changes: 5 additions & 0 deletions cardio/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
""" Core CardIO objects """

from .ecg_batch import EcgBatch, add_actions
from .ecg_dataset import EcgDataset
from . import kernels
Loading

0 comments on commit 4b49825

Please sign in to comment.