Skip to content

Commit fd116eb

Browse files
committed
Initial public release
1 parent d654f72 commit fd116eb

Some content is hidden

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

69 files changed

+16459
-3
lines changed

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto
3+
4+
# Explicitly declare text files you want to always be normalized on checkout.
5+
*.py text
6+
*.sh text

.gitignore

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

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "cardio/dataset"]
2+
path = cardio/dataset
3+
url = https://github.com/analysiscenter/dataset.git

CONTRIBUTING.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
- Перед любыми операциями с репозиториями у каждого пользователя должно быть настроено имя и адрес почты:
2+
```bash
3+
git config --global user.name "Firstname Lastnameov"
4+
git config --global user.email [email protected]
5+
```
6+
Причем email **должен совпадать** с email'ом, который указан в вашем github-аккаунте (в нем может быть несколько email'ов).
7+
8+
- В корневом каталоге каждого репозитория должен быть размещен файл README.md с кратким описанием проекта, структуры исходного кода, инструкцией по установке и ссылками на документацию.
9+
10+
- Все содержательные файлы рекомендуется размещать в подкаталогах, а в корневом хранить только описательные (README.md, INSTALL.md и т.п.),
11+
инсталляционные (setup.py, requirements.txt и т.п.), а также конфигурационные и make-файлы.
12+
13+
- Имена файлов должны содержать только латинские буквы. Пробелы в наименованиях файлов не допускаются.
14+
15+
- Коммиты в ветку `master` не допускаются. Она должна быть защищена от удаления и изменения истории
16+
(Settings - Branches - Protected branches).
17+
18+
- Изменения в исходном коде и файлах репозитория рекомендуется производить только в рамках задач (issues).
19+
Для каждого изменения исполнитель открывает отдельную ветку с наименованием вида <iTASK-ID>-<short branch name> (например, `i15-dataset` или `i22-HMM`).
20+
21+
- В рамках одной задачи можно создавать несколько веток в одном репозитории.
22+
23+
- Если у вас нет задачи, имеет смысл ее открыть и явным образом завести в issues.
24+
25+
- Коммиты в рабочие ветки рекомендуется делать регулярно, чтобы каждый коммит содержал не слишком объемные,
26+
но вместе с тем завершенные и независимые от всего остального изменения в репозитории
27+
(лучше закоммитить 3 измененных строки, чем сразу 300).
28+
29+
- Коммит должен содержать однострочный англоязычный комментарий (длиной 20-60 символов),
30+
отражающий содержание включенных в него изменений исходного кода и файлов.
31+
32+
- Более подробное описание изменений следует сохранять в файле HISTORY.md, размещенном в корневом каталоге репозитория.
33+
34+
- Выполнив задачу и завершив все изменения, исполнитель открывает pull request на слияние рабочей и продуктивной ветки (например, master).
35+
36+
- Перед слиянием рабочая ветка не должна отставать от продуктивной (что можно проверить с помощью `git status`). Для этого следует предварительно синхронизировать рабочую ветку (`git pull`).
37+
38+
- После слияния рабочая ветка удаляется.

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@
178178
APPENDIX: How to apply the Apache License to your work.
179179

180180
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "[]"
181+
boilerplate notice, with the fields enclosed by brackets "{}"
182182
replaced with your own identifying information. (Don't include
183183
the brackets!) The text should be enclosed in the appropriate
184184
comment syntax for the file format. We also recommend that a
185185
file or class name and description of purpose be included on the
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright {yyyy} {name of copyright owner}
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

MANIFEST.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
include MANIFEST.in
2+
include LICENSE
3+
include README.md
4+
include setup.py
5+
6+
recursive-include cardio *
7+
recursive-include docs *
8+
recursive-include tutorials *
9+
recursive-exclude docs/_build *
10+
11+
global-exclude *.pyc *.pyo *.pyd
12+
global-exclude *.git
13+
global-exclude *.so
14+
global-exclude *~
15+
global-exclude \#*
16+
global-exclude .DS_Store

README.md

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,97 @@
1-
# cardio
1+
# CardIO
2+
3+
CardIO is a library that works with electrocardiograms (ECG). With CardIO you can
4+
5+
* load and save signal in various formats
6+
* resample, crop, filter and flip signal
7+
* allocate PQ, QT, QRS segments
8+
* calculate heart rate and other standard ECG characteristics
9+
* apply complex transformations like fft and wavelets, or any other custom functions.
10+
* recognize heart diseases from ECG
11+
* efficiently work with large datasets that do not even fit into memory
12+
* easily arrange new custom actions into pipelines
13+
* do end-to-end ECG processing
14+
* build, train and test custom models for deep research
15+
16+
… and do everything under a single API.
17+
18+
For more details see [the documentation and tutorials](https://analysiscenter.github.io/cardio/).
19+
20+
## About CardIO
21+
22+
The library is based on [Dataset](https://github.com/analysiscenter/dataset/). We suggest to read Dataset's [documentation](https://analysiscenter.github.io/dataset/) to learn more.
23+
24+
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).
25+
26+
Module ```batch``` contains low-level actions for ECG processing.
27+
Actions are included in ```EcgBatch``` class that also defines how
28+
to store ECGs. From these actions you can biuld new pipelines. You can also
29+
write custom action and include it in ```EcgBatch```.
30+
31+
In ```models``` we provide several models that were elaborated to learn the most important problems in ECG:
32+
* how to recognize specific features of ECG like R-peaks, P-wave, T-wave
33+
* how to recognize heart diseases from ECG, for example - atrial fibrillation.
34+
35+
Module ```pipelines``` contains high-level methods that
36+
* train model to allocate PQ, QT, QRS segments
37+
* calculate heart rate
38+
* train model to find probabilities of heart diseases.
39+
40+
Under the hood these methods contain many actions that load signals, filter it and do complex caclulations. Using pipelines you do not think about this part of work and simply pass ECG datasets and get results.
41+
42+
## Basic usage
43+
44+
Here is an example of pipeline that loads ECG signals, makes some preprocessing and learns model over 50 epochs.
45+
```python
46+
train_ppl = (
47+
dtst.train
48+
.pipeline
49+
.init_model("dynamic", DirichletModel, name="dirichlet",
50+
config=model_config)
51+
.init_variable("loss_history", init=list)
52+
.load(components=["signal", "meta"], fmt="wfdb")
53+
.load(components="target", fmt="csv", src=LABELS_PATH)
54+
.drop_labels(["~"])
55+
.replace_labels({"N": "NO", "O": "NO"})
56+
.flip_signals()
57+
.random_resample_signals("normal", loc=300, scale=10)
58+
.random_split_signals(2048, {"A": 9, "NO": 3})
59+
.binarize_labels()
60+
.train_model("dirichlet", make_data=make_data, fetches="loss", save_to=V("loss_history"), mode="a")
61+
.run(batch_size=100, shuffle=True, drop_last=True, n_epochs=50)
62+
)
63+
```
64+
65+
As a result of this pipeline one obtains a trained model.
66+
67+
## Installation
68+
69+
> `CardIO` module is in the beta stage. Your suggestions and improvements are very welcome.
70+
71+
> `CardIO` supports python 3.5 or higher.
72+
73+
### Installation as python package
74+
75+
With [pipenv](https://docs.pipenv.org/):
76+
77+
pipenv install git+https://github.com/analysiscenter/cardio.git#egg=cardio
78+
79+
With [pip](https://pip.pypa.io/en/stable/):
80+
81+
pip3 install git+https://github.com/analysiscenter/cardio.git
82+
83+
After that just import `cardio`:
84+
```python
85+
import cardio
86+
```
87+
88+
### Installation as a project repository:
89+
90+
git clone --recursive https://github.com/analysiscenter/ecg.git
91+
92+
Flag `--recursive` is used to clone submodules.
93+
94+
## Citing CardIO
95+
Please cite CardIO in your publications if it helps your research.
96+
97+
Khudorozhkov R., Illarionov E., Kuvaev A., Podvyaznikov D. CardIO library for data science research of heart signals. 2017.

cardio/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
""" ECG package """
2+
import sys
3+
4+
from .batch import * # pylint: disable=wildcard-import
5+
from . import dataset # pylint: disable=wildcard-import
6+
7+
8+
__version__ = '0.1.0'

cardio/batch/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
""" ECG Batch """
2+
from .ecg_batch import EcgBatch
3+
from .ecg_dataset import EcgDataset

0 commit comments

Comments
 (0)