Skip to content

Commit bdfc3a0

Browse files
committed
Archive old gastropy scaffolding for reference
1 parent 319d21d commit bdfc3a0

14 files changed

Lines changed: 1406 additions & 0 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ docs/_build/
2828
# IDE
2929
.vscode/
3030
.idea/
31+
.claude/
3132
*.swp
3233
*.swo
3334
*~

_archive/.flake8

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = E203, E722, E501
4+
exclude =
5+
__init__.py

_archive/.isort.cfg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[settings]
2+
known_third_party = numpy,pandas,pytest,scipy
3+
multi_line_output = 3
4+
include_trailing_comma = True
5+
force_grid_wrap = 0
6+
use_parentheses = True
7+
ensure_newline_before_comments = True
8+
line_length = 88

_archive/.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/mirrors-isort
3+
rev: v5.9.3
4+
hooks:
5+
- id: isort
6+
files: ^gastropy/
7+
- repo: https://github.com/ambv/black
8+
rev: 21.8b0
9+
hooks:
10+
- id: black
11+
language_version: python3
12+
files: ^gastropy/
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
14+
rev: v2.3.0
15+
hooks:
16+
- id: flake8
17+
files: ^gastropy/
18+
- repo: https://github.com/pre-commit/mirrors-mypy
19+
rev: 'v0.910' # Use the sha / tag you want to point at
20+
hooks:
21+
- id: mypy
22+
files: ^gastropy/
23+
args: [--ignore-missing-imports]

_archive/.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: python
2+
3+
python:
4+
- "3.7"
5+
- "3.8"
6+
- "3.9"
7+
8+
install:
9+
- pip install -r requirements-test.txt
10+
- pip install -r requirements.txt
11+
- pip install coverage pytest black mypy flake8 isort
12+
13+
script:
14+
- coverage run -m pytest
15+
- black --check ./gastropy/
16+
- isort ./gastropy/
17+
- mypy ./gastropy/ --ignore-missing-imports --follow-imports=skip
18+
- flake8 ./gastropy/
19+
20+
after_success:
21+
- bash <(curl -s https://codecov.io/bash)

_archive/README.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
.. image:: https://img.shields.io/badge/License-GPL%20v3-blue.svg
3+
:target: https://github.com/embodied-computation-group/gastropy/blob/master/LICENSE
4+
5+
.. image:: https://travis-ci.org/embodied-computation-group/gastropy.svg?branch=master
6+
:target: https://travis-ci.org/embodied-computation-group/gastropy
7+
8+
.. image:: https://codecov.io/gh/embodied-computation-group/gastropy/branch/master/graph/badge.svg
9+
:target: https://codecov.io/gh/embodied-computation-group/gastropy
10+
11+
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
12+
:target: https://github.com/psf/black
13+
14+
.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336
15+
:target: https://pycqa.github.io/isort/
16+
17+
.. image:: http://www.mypy-lang.org/static/mypy_badge.svg
18+
:target: http://mypy-lang.org/
19+
20+
.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
21+
:target: https://github.com/pre-commit/pre-commit
22+
23+
================
24+
25+
**gastropy** is an open-source Python package providing simple tools for electrogastrography data visualization and analysis.
26+
27+
================
28+
29+
Installation
30+
============
31+
32+
Getting started
33+
===============
34+
35+
Development
36+
===========
37+
38+
This module was created and is maintained by Ignacio Rebello, Micah Allen and Nicolas Legrand (ECG group, https://the-ecg.org/). If you want to contribute, feel free to contact one of the developers, open an issue or submit a pull request.
39+
40+
This program is provided with NO WARRANTY OF ANY KIND.
41+
42+
Acknowledgements
43+
================
44+
45+
This software and the ECG are supported by a Lundbeckfonden Fellowship (R272-2017-4345), and the AIAS-COFUND II fellowship programme that is supported by the Marie Skłodowska-Curie actions under the European Union’s Horizon 2020 (Grant agreement no 754513), and the Aarhus University Research Foundation.

_archive/gastropy_old/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .plots import *
2+
from .preprocessing import *
3+
4+
__version__ = "0.0.1a"

_archive/gastropy_old/plots.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Author: Nicolas Legrand <nicolas.legrand@cfin.au.dk>
2+
3+
from typing import List, Union
4+
5+
import numpy as np
6+
import pandas as pd
7+
from bokeh.layouts import column
8+
from bokeh.models import ColumnDataSource, Panel, RangeTool, Tabs
9+
from bokeh.plotting import figure
10+
11+
12+
def plot_raw(
13+
signal: Union[np.array, List[np.array]], sfreq: int = 1000, figsize: int = 400
14+
) -> Tabs:
15+
"""Plot raw EGG recording.
16+
17+
Parameters
18+
----------
19+
signal : list or np.ndarray
20+
The EGG signal as a Numpy array. If a list is provided, it should
21+
contain *n* Numpy array of equal length.
22+
sfreq : int
23+
Signal sampling frequency. Default is set to 1000 Hz.
24+
figsize : int
25+
Figure height. Default is `300`.
26+
27+
Returns
28+
-------
29+
fig : :class:`bokeh.models.Tabs`
30+
The bokeh figure containing the plot(s).
31+
32+
"""
33+
34+
if isinstance(signal, list):
35+
for i, sig in enumerate(signal):
36+
if i == 0:
37+
# Create the time vector
38+
time = pd.to_datetime(
39+
np.arange(0, len(sig)) / sfreq, unit="s", origin="unix"
40+
)
41+
data = {"time": time}
42+
data[f"EGG_{i+1}"] = sig
43+
elif isinstance(signal, np.ndarray):
44+
# Create the time vector
45+
time = pd.to_datetime(
46+
np.arange(0, len(signal)) / sfreq, unit="s", origin="unix"
47+
)
48+
data = {"time": time}
49+
data["EGG_1"] = signal
50+
else:
51+
raise ValueError(
52+
"Invalid data format provided. Should be list or 1d Numpy array"
53+
)
54+
55+
source = ColumnDataSource(data=data)
56+
tabs = []
57+
for i in range(1, len(data)):
58+
raw = figure(
59+
title="Raw data",
60+
x_axis_type="datetime",
61+
sizing_mode="stretch_width",
62+
plot_height=figsize,
63+
x_axis_label="Time",
64+
y_axis_label="EGG",
65+
output_backend="webgl",
66+
x_range=(time[0], time[-1]),
67+
)
68+
69+
raw.line("time", f"EGG_{i}", source=source)
70+
71+
select = figure(
72+
title="Drag the middle and edges of the selection box to change the range above",
73+
plot_height=130,
74+
plot_width=800,
75+
y_range=raw.y_range,
76+
x_axis_type="datetime",
77+
y_axis_type=None,
78+
tools="",
79+
toolbar_location=None,
80+
background_fill_color="#efefef",
81+
)
82+
range_tool = RangeTool(x_range=raw.x_range)
83+
range_tool.overlay.fill_color = "navy"
84+
range_tool.overlay.fill_alpha = 0.2
85+
86+
select.line("time", f"EGG_{i}", source=source)
87+
select.ygrid.grid_line_color = None
88+
select.add_tools(range_tool)
89+
select.toolbar.active_multi = range_tool
90+
91+
tabs.append(
92+
Panel(
93+
child=column(*(raw, select), sizing_mode="stretch_width"),
94+
title=f"EGG_{i}",
95+
)
96+
)
97+
98+
return Tabs(tabs=tabs)

_archive/gastropy_old/preprocessing.py

Whitespace-only changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Author: Nicolas Legrand <nicolas.legrand@cfin.au.dk>
2+
3+
import unittest
4+
from unittest import TestCase
5+
6+
import numpy as np
7+
8+
from gastropy.plots import plot_raw
9+
10+
11+
class TestHrv(TestCase):
12+
def test_plot_raw(self):
13+
"""Test plot_raw function"""
14+
signal1, signal2 = np.random.normal(0, 1, 10000), np.random.normal(0, 1, 10000)
15+
plot_raw(signal=[signal1, signal2])
16+
17+
18+
if __name__ == "__main__":
19+
unittest.main(argv=["first-arg-is-ignored"], exit=False)

0 commit comments

Comments
 (0)