-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #5 Add mlpy find peaks functions mlpy.findpeaks_dist and mlpy.…
…findpeaks_win
- Loading branch information
Showing
7 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,6 @@ docs/_build/ | |
# PyBuilder | ||
target/ | ||
|
||
venv/ | ||
venv/ | ||
|
||
tests/mlpy-code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" | ||
MLPY_DIR="$DIR/mlpy-code" | ||
|
||
# Pulling code. | ||
if [ -d "$MLPY_DIR" ]; then | ||
cd $MLPY_DIR && hg pull | ||
else | ||
hg clone http://hg.code.sf.net/p/mlpy/code $MLPY_DIR | ||
fi | ||
|
||
# We try to install mlpy on Python 2, as the install is not compatible with Python 3.7+. | ||
# (CPython must be updated to support Python 3.7+. See https://github.com/cython/cython/issues/1978) | ||
|
||
# Installating dependencies. | ||
# We also install matplotlib for our tests. | ||
pip2 install -U --user numpy scipy matplotlib | ||
|
||
# Also requires http://www.gnu.org/software/gsl/ to be installed. | ||
|
||
# Installing. | ||
# http://mlpy.sourceforge.net/docs/3.5/install.html | ||
cd $MLPY_DIR | ||
python2 setup.py build_ext --include-dirs=/usr/include/ --rpath=/usr/lib/ | ||
python2 setup.py install --user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
""" | ||
To install the mlpy, you may read (and run) /tests/install_mlpy.sh | ||
""" | ||
import numpy as np | ||
from vector import vector, plot_peaks | ||
import mlpy | ||
|
||
print('Detect peaks without any filters.') | ||
indexes = mlpy.findpeaks_dist(vector) | ||
print('Peaks are: {}'.format(indexes)) | ||
plot_peaks( | ||
np.array(vector), | ||
indexes, | ||
algorithm='mlpy.findpeaks_dist' | ||
) | ||
|
||
print('Detect peaks with minimum distance filter.') | ||
mdp = 2.1 | ||
indexes = mlpy.findpeaks_dist(vector, mindist=mdp) | ||
print('Peaks are: {}'.format(indexes)) | ||
plot_peaks( | ||
np.array(vector), | ||
indexes, | ||
mpd=mdp, algorithm='mlpy.findpeaks_dist' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
""" | ||
To install the mlpy, you may read (and run) /tests/install_mlpy.sh | ||
""" | ||
import numpy as np | ||
from vector import vector, plot_peaks | ||
import mlpy | ||
|
||
span = 3 | ||
print('Detect peaks with a sliding window of {} (minimum possible).'.format(span)) | ||
indexes = mlpy.findpeaks_win(vector, span=span) | ||
print('Peaks are: {}'.format(indexes)) | ||
plot_peaks( | ||
np.array(vector), | ||
indexes, | ||
mpd=span, algorithm='mlpy.findpeaks_win' | ||
) | ||
|
||
span = 5 | ||
print('Detect peaks with a sliding window of {}.'.format(span)) | ||
indexes = mlpy.findpeaks_win(vector, span=span) | ||
print('Peaks are: {}'.format(indexes)) | ||
plot_peaks( | ||
np.array(vector), | ||
indexes, | ||
mpd=span, algorithm='mlpy.findpeaks_win' | ||
) |