Closed dimang777 closed 6 years ago
I simply didn't specify the correct path with the data files. Once I downloaded the QT database and specified the correct path, it worked. But I have another problem now. After I built the model and saved it as a .dll file, I used it to predict, but it showed another error (the same error as before).
Code:
from cardio import EcgDataset from cardio.pipelines import hmm_predict_pipeline import warnings warnings.filterwarnings('ignore')
eds = EcgDataset(path="C:\PhysioNetQT_DataB\cardio\cardio\tests\data\A*.hea", no_ext=True, sort=True) batch = (eds >> hmm_predict_pipeline("C:\PhysioNetQT_DataB\model_dump.dll", annot="hmm_annotation")).next_batch()
batch.show_ecg("A00001", start=10, end=15, annot="hmm_annotation")
print("Heart rate: {0} bpm".format(int(.5 + batch["A00001"].meta["hr"])))
Error: batch = (eds >> hmm_predict_pipeline("C:\PhysioNetQT_DataB\model_dump.dll", annot="hmm_annotation")).next_batch()
Traceback (most recent call last):
File "
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\pipeline.py", line 1057, in next_batch batch_res = self.next_batch(*self._lazy_run[0], **self._lazy_run[1])
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\pipeline.py", line 1062, in next_batch batch_res = next(self._batch_generator)
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\pipeline.py", line 1033, in gen_batch for batch in batch_generator:
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\base.py", line 162, in gen_batch for ix_batch in self.index.gen_batch(batch_size, shuffle, n_epochs, drop_last):
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\dsindex.py", line 276, in gen_batch batch = self.next_batch(batch_size, shuffle, n_epochs, drop_last, iter_params)
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\dsindex.py", line 250, in next_batch return self.create_batch(rest_items, pos=True)
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\dsindex.py", line 292, in create_batch batch = self.subset_by_pos(_batch_indices)
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\dsindex.py", line 80, in subset_by_pos return self.index[pos]
TypeError: only integer scalar arrays can be converted to a scalar index
This is the same error I got when there was no file to load. I checked the directory and it's correct and files are all there. Any advice would be much appreciated.
I think it was file name/path issue as well. It's been fixed.
Hi, I'm new to Python but wanted to try ECG segmentation so I tried using cardio. I've installed below packages on Python 3.6.5 in addition to all the other packages that were needed in the process. I tried executing the example code of the ECG segmentation in the III. Models tutorial, and got an error message "TypeError: only integer scalar arrays can be converted to a scalar index". I've listed the codes that were executed followed by the error message.
pip3 install git+https://github.com/analysiscenter/cardio.git pip3 install git+https://github.com/analysiscenter/dataset.git pip install hmmlearn-0.2.1-cp36-cp36m-win_amd64.whl (after I downloaded the file from https://www.lfd.uci.edu/~gohlke/pythonlibs/#hmmlearn - installing hmmlearn from GitHub gave an error while installing)
Code:
import sys, os sys.path.append('..')
from cardio import EcgDataset
SIGNALS_PATH = "/notebooks/data/ECG/QT/" #set path to the QT database SIGNALS_MASK = os.path.join(SIGNALS_PATH, "*.hea")
dtst = EcgDataset(path=SIGNALS_MASK, no_ext=True, sort=True)
from cardio.pipelines import hmm_preprocessing_pipeline, hmm_train_pipeline import warnings warnings.filterwarnings('ignore')
pipeline = hmm_preprocessing_pipeline() ppl_inits = (dtst >> pipeline).run()
Error message: ppl_inits = (dtst >> pipeline).run()
Traceback (most recent call last):
File "", line 1, in
ppl_inits = (dtst >> pipeline).run()
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\pipeline.py", line 1088, in run for _ in self.gen_batch(*args, **kwargs):
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\pipeline.py", line 1033, in gen_batch for batch in batch_generator:
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\base.py", line 162, in gen_batch for ix_batch in self.index.gen_batch(batch_size, shuffle, n_epochs, drop_last):
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\dsindex.py", line 276, in gen_batch batch = self.next_batch(batch_size, shuffle, n_epochs, drop_last, iter_params)
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\dsindex.py", line 250, in next_batch return self.create_batch(rest_items, pos=True)
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\dsindex.py", line 292, in create_batch batch = self.subset_by_pos(_batch_indices)
File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\dsindex.py", line 80, in subset_by_pos return self.index[pos]
TypeError: only integer scalar arrays can be converted to a scalar index
I'm not sure what is the problem. I appreciate your help in advance.