MPBA / pyphysio

GNU General Public License v3.0
47 stars 13 forks source link

Allow access to Assets.ecg() #28

Closed andbiz closed 7 years ago

andbiz commented 7 years ago

We need to access sample data for the tutorial (not only for tests) Example:

from pyphysio import Assets 
ecg_data = Assets.ecg()
andbiz commented 7 years ago

Not working:

# import data from included examples
from pyphysio import Assets

ecg_data = Assets.ecg()
eda_data = Assets.eda()

Traceback:

---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-8-cd8629c1c780> in <module>()
      2 from pyphysio import Assets
      3 
----> 4 ecg_data = Assets.ecg()
      5 eda_data = Assets.eda()

/home/andrea/Trento/CODICE/workspaces/pyHRV/pyHRV/tests/context.py in ecg(cls)
     32     @classmethod
     33     def ecg(cls):
---> 34         return Assets.get_data()[:, 0]
     35 
     36     @classmethod

/home/andrea/Trento/CODICE/workspaces/pyHRV/pyHRV/tests/context.py in get_data(cls)
     25             if not _os.path.isfile(Assets._path + Assets._file_u):
     26                 _os.system("bzcat %s%s > %s%s" % (Assets._path, Assets._file_c, Assets._path, Assets._file_u))
---> 27             Assets._sing = np.genfromtxt(Assets._path + Assets._file_u, delimiter="\t")
     28         return Assets._sing
     29 

/home/andrea/anaconda3/envs/py27r32/lib/python2.7/site-packages/numpy/lib/npyio.pyc in genfromtxt(fname, dtype, comments, delimiter, skip_header, skip_footer, converters, missing_values, filling_values, usecols, names, excludelist, deletechars, replace_space, autostrip, case_sensitive, defaultfmt, unpack, usemask, loose, invalid_raise, max_rows)
   1449         if isinstance(fname, basestring):
   1450             if sys.version_info[0] == 2:
-> 1451                 fhd = iter(np.lib._datasource.open(fname, 'rbU'))
   1452             else:
   1453                 fhd = iter(np.lib._datasource.open(fname, 'rb'))

/home/andrea/anaconda3/envs/py27r32/lib/python2.7/site-packages/numpy/lib/_datasource.pyc in open(path, mode, destpath)
    149 
    150     ds = DataSource(destpath)
--> 151     return ds.open(path, mode)
    152 
    153 

/home/andrea/anaconda3/envs/py27r32/lib/python2.7/site-packages/numpy/lib/_datasource.pyc in open(self, path, mode)
    499             return _file_openers[ext](found, mode=mode)
    500         else:
--> 501             raise IOError("%s not found." % path)
    502 
    503 

IOError: ../assets/medical.txt not found.
Alebat commented 7 years ago

Numpy genfromtxt reads bzip2 files :D