phuselab / pyVHR

Python framework for Virtual Heart Rate

Home Page:http://phuselab.di.unimi.it/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KeyError: 'method' when running on dataset

eliwagnercode opened this issue · comments

Hello, I'm having the same problem as was described in this issue that was closed on 2023.01.15, but I am using the latest version of pyVHR (2.0):
#48

When I run the following code I get a naming warning and an error:

`from pyVHR.analysis.pipeline import Pipeline, DeepPipeline
from pyVHR.analysis.stats import StatAnalysis
from pyVHR.plot.visualize import *
import os
import pandas as pd
import plotly.express as px
from numpy import round as r
import plotly.io as pio
pio.renderers.default = 'jupyterlab'

path_h5 = '../results/h5/UBFC2_holistic.h5'
path_cfg = '../results/cfg/UBFC2_holistic.cfg'

pl = Pipeline()
res = pl.run_on_dataset(path_cfg, verb=1)
res.saveResults(path_h5)
print('Written file: ' + path_h5 + '\n\n')

st = StatAnalysis(path_h5)
fig = st.displayBoxPlot(metric='MAE', scale='log')
fig.show()`

** Run the test with the following config:
dataset: UBFC2
methods: ['CHROM', 'POS', 'LGI', 'ICA', 'PCA']

CUDA devices: 2

device number 0 : NVIDIA RTX A4000

device number 1 : NVIDIA RTX A4000

  • cuda device: True
  • skin extractor: convexhull
  • ROI approach: holistic
    Written file: ../results/h5/UBFC2_holistic.h5

../results/h5/UBFC2_holistic.h5


KeyError Traceback (most recent call last)
~/miniconda3/envs/pyvhr/lib/python3.9/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
3628 try:
-> 3629 return self._engine.get_loc(casted_key)
3630 except KeyError as err:

~/miniconda3/envs/pyvhr/lib/python3.9/site-packages/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

~/miniconda3/envs/pyvhr/lib/python3.9/site-packages/pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'method'

The above exception was the direct cause of the following exception:

KeyError Traceback (most recent call last)
/tmp/ipykernel_1059/10681237.py in
18 print('Written file: ' + path_h5 + '\n\n')
19
---> 20 st = StatAnalysis(path_h5)
21 fig = st.displayBoxPlot(metric='MAE', scale='log')
22 fig.show()

~/miniconda3/envs/pyvhr/lib/python3.9/site-packages/pyVHR/analysis/stats.py in init(self, filepath, join_data, remove_outliers)
48
49 # -- get data
---> 50 self.__getMethods()
51 self.metricSort = {'MAE': 'min', 'RMSE': 'min', 'PCC': 'max', 'CCC': 'max', 'SNR': 'max'}
52 self.scale = {'MAE': 'log', 'RMSE': 'log', 'PCC': 'linear', 'CCC': 'linear', 'SNR': 'linear'}

~/miniconda3/envs/pyvhr/lib/python3.9/site-packages/pyVHR/analysis/stats.py in __getMethods(self)
426 data = pd.read_hdf(filename)
427 mets.append(set(list(data['method'])))
--> 428 dataFrame.append(data)
429
430 if not self.join_data:

~/miniconda3/envs/pyvhr/lib/python3.9/site-packages/pandas/core/frame.py in getitem(self, key)
3503 if self.columns.nlevels > 1:
3504 return self._getitem_multilevel(key)
-> 3505 indexer = self.columns.get_loc(key)
3506 if is_integer(indexer):
3507 indexer = [indexer]

~/miniconda3/envs/pyvhr/lib/python3.9/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
3629 return self._engine.get_loc(casted_key)
3630 except KeyError as err:
-> 3631 raise KeyError(key) from err
3632 except TypeError:
3633 # If we have a listlike key, _check_indexing_error will raise

KeyError: 'method'

I'm not understanding if this is an issue with the package itself or how my environment is set up, or how I defined the filepath to the cfg and h5 files. Thanks in advance for any guidance you can provide!