-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dataset - TypeError: only integer scalar arrays can be converted to a scalar index #16
Comments
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. Code: from cardio import EcgDataset eds = EcgDataset(path="C:\PhysioNetQT_DataB\cardio\cardio\tests\data\A*.hea", no_ext=True, sort=True) batch.show_ecg("A00001", start=10, end=15, annot="hmm_annotation") print("Heart rate: {0} bpm".format(int(.5 + batch["A00001"].meta["hr"]))) Error: Traceback (most recent call last): File "", line 1, in File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\pipeline.py", line 1057, in next_batch File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\pipeline.py", line 1062, in next_batch File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\pipeline.py", line 1033, in gen_batch File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\base.py", line 162, in gen_batch File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\dsindex.py", line 276, in gen_batch File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\dsindex.py", line 250, in next_batch File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\dsindex.py", line 292, in create_batch File "C:\Anaconda3\lib\site-packages\cardio\dataset\dataset\dsindex.py", line 80, in subset_by_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.
The text was updated successfully, but these errors were encountered: