Skip to content

Commit

Permalink
V. 0.0.7 - Beta
Browse files Browse the repository at this point in the history
- Moved sample signals
- Added sample signal loading module
  • Loading branch information
Gabrock94 committed Apr 20, 2018
1 parent 812456d commit 36e2bd6
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 48 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ if(__name__ == "__main__"):
### Requirements
- Numpy
- Scipy
- peakutils
- Peakutils
- Matplotlib

## Credits

Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
author = 'Giulio Gabrieli'

# The short X.Y version
version = '0.0.6'
version = '0.0.7'
# The full version, including alpha/beta/rc tags
release = '0.0.6 - Alpha version'
release = '0.0.7 - Beta version'


# -- General configuration ---------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion pysiology/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from . import heartrate
from . import electromiography
from . import electrodermalactivity
from . import sampledata

__version__ = '0.0.7' #Version Control

__version__ = '0.0.6' #Version Control
9 changes: 4 additions & 5 deletions pysiology/electrodermalactivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ def butter_highpass_filter(data, cutoff, fs, order):
import pickle
import os
import pprint
fakesignal = []
with open(os.getcwd().replace('/pysiology/pysiology','/pysiology') + '/data/convertedEDA.pkl',"rb") as f: # Python 3: open(..., 'rb')
fakesignal = pickle.load(f) #load a fake signal
GSRResults = analyzeGSR(fakesignal,1000) #analyze it
pprint.pprint(GSRResults) #print the results for each peak found
import sampledata
fakesignal = sampledata.loadsampleEDA()
GSRResults = analyzeGSR(fakesignal,1000) #analyze it
pprint.pprint(GSRResults) #print the results for each peak found
28 changes: 12 additions & 16 deletions pysiology/electromiography.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,19 +975,15 @@ def analyzeEMG(rawEMGSignal, samplerate, preprocessing=True,lowpass=50,highpass=
import os
import pickle
import pprint
basepath = os.path.dirname(os.path.realpath(__file__)) #This get the basepath of the script
datafolder = "/".join(basepath.split("/")[:-1])+"/data/"

fakesignal = []
with open(datafolder+"convertedEMG.pkl","rb") as f: # Python 3: open(..., 'rb')
events = [30] #set a fake event
tmin = 0 #start from the beginning of the events
tmax = 5 #end from the beginning of the events
fakesignal = pickle.load(f) #load a fake signal
samplerate = 1000 #samplerate of the fake signal
for event in events: #for each event
smin = tmin*samplerate + event
smax = tmax*samplerate + event
eventSignal = fakesignal[smin:smax]
analyzedEMG = analyzeEMG(eventSignal,samplerate,preprocessing=False) #analyze it
pprint.pprint(analyzedEMG) #print the results of the analysis
import sampledata
fakesignal = sampledata.loadsampleEMG()
events = [30] #set a fake event
tmin = 0 #start from the beginning of the events
tmax = 5 #end from the beginning of the events
samplerate = 1000 #samplerate of the fake signal
for event in events: #for each event
smin = tmin*samplerate + event
smax = tmax*samplerate + event
eventSignal = fakesignal[smin:smax]
analyzedEMG = analyzeEMG(eventSignal,samplerate,preprocessing=False) #analyze it
pprint.pprint(analyzedEMG) #print the results of the analysis
29 changes: 12 additions & 17 deletions pysiology/heartrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,20 +389,15 @@ def analyzeECG(rawECGSignal,samplerate,preprocessing = True, highpass = 0.5, low
import os
import pickle
import pprint

basepath = os.path.dirname(os.path.realpath(__file__)) #This get the basepath of the script
datafolder = "/".join(basepath.split("/")[:-1])+"/data/"

fakesignal = []
with open(datafolder+"convertedECG.pkl","rb") as f: # Python 3: open(..., 'rb')
events = [30000] #set a list of fake fake events
tmin = 0 #start from the beginning of the events
tmax = 8 #end from the beginning of the events
fakesignal = pickle.load(f) #load a fake signal
samplerate = 1000 #samplerate of the fake signal
for event in events: #for each event
smin = tmin*samplerate + event
smax = tmax*samplerate + event
eventSignal = fakesignal[smin:smax]
analyzedECG = analyzeECG(eventSignal,samplerate) #analyze it
pprint.pprint(analyzedECG) #print the results of the analysis
import sampledata
fakesignal = sampledata.loadsampleECG()
events = [30000] #set a list of fake fake events
tmin = 0 #start from the beginning of the events
tmax = 8 #end from the beginning of the events
samplerate = 1000 #samplerate of the fake signal
for event in events: #for each event
smin = tmin*samplerate + event
smax = tmax*samplerate + event
eventSignal = fakesignal[smin:smax]
analyzedECG = analyzeECG(eventSignal,samplerate) #analyze it
pprint.pprint(analyzedECG) #print the results of the analysis
32 changes: 32 additions & 0 deletions pysiology/sampledata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
""" This module is used to load sample data from the share/data folder. """
import os
import pickle
import pkg_resources
###############################################################################
# #
# DEBUG #
# #
###############################################################################

def loadsampleECG():
fakesignal = os.stat(pkg_resources.resource_filename('pysiology','../share/data/convertedECG.pkl'))
with open(fakesignal,"rb") as f: # Python 3: open(..., 'rb')
return(pickle.load(f)) #load a fake signal

def loadsampleEMG():
fakesignal = os.stat(pkg_resources.resource_filename('pysiology','../share/data/convertedEMG.pkl'))
with open(fakesignal,"rb") as f: # Python 3: open(..., 'rb')
return(pickle.load(f)) #load a fake signal

def loadsampleEDA():
fakesignal = os.stat(pkg_resources.resource_filename('pysiology','../share/data/convertedEDA.pkl'))
with open(fakesignal,"rb") as f: # Python 3: open(..., 'rb')
return(pickle.load(f)) #load a fake signal

""" For debug purposes"""

if(__name__=='__main__'):
ecg = loadsampleECG()
emg = loadsampleEMG()
eda = loadsampleEDA()
19 changes: 13 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
from setuptools import setup
import os

datadir = os.path.join("share","data")
datafiles = [(d,[os.path.join(d,f) for f in files]) for d, folders, files in os.walk(datadir)]


setup(name='pysiology',
version='0.0.6',
version='0.0.7',
description='Physiological signal processing in Python',
long_description="A simple python package for physiological signal processing (ECG,EMG,GSR).",
long_description="A simple python package for physiological signal processing (ECG,EMG,GSR). Tutorial and documentation can be found on the Github Repository or at pysiology.rtfd.io.",
url='https://github.com/Gabrock94/Pysiology',
download_url='https://github.com/Gabrock94/Pysiology/archive/0.0.6.tar.gz',
author='Giulio Gabrieli',
author_email='[email protected]',
license='Apache2',
license='GPL-3.0',
packages=['pysiology'],
install_requires=[
'numpy',
Expand All @@ -22,10 +27,10 @@
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 3 - Alpha',
'Development Status :: 4 - Beta',

# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: MIT License',
'License :: OSI Approved :: GNU General Public License (GPL)',

# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
Expand All @@ -37,4 +42,6 @@
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
],
zip_safe=False)
zip_safe=False,
include_package_data=True,
data_files = datafiles)
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 36e2bd6

Please sign in to comment.