paulvangentcom / heartrate_analysis_python

Python Heart Rate Analysis Package, for both PPG and ECG signals
MIT License
962 stars 322 forks source link

Process_segmentwise ignore_badsignalwarning=True causes an array size mismatch #99

Open JesseShaw opened 2 years ago

JesseShaw commented 2 years ago

This works when ignore_badsignalwarning=False but the signal length shrinks by the number of bad readings in the signal.

bvp_vec = bvp_in.iloc[:,0] filtered = hp.filter_signal(bvp_vec, [0.7, 3.5], sample_rate=bvp_smplrt, order=3, filtertype='bandpass') wd, m = hp.process_segmentwise(filtered, sample_rate = bvp_smplrt, segment_width = 60, segment_overlap = 0, replace_outliers=True, mode='full', ignore_badsignalwarning=True) bvp = pd.DataFrame(data=m, index=None)


ValueError Traceback (most recent call last)

in 2 #ts, filtered, onsets, heart_rate_ts, heart_rate = bvp(signal=bvp_flt, sampling_rate=bvp_smplrt, show=True) 3 wd, m = hp.process_segmentwise(filtered, sample_rate = bvp_smplrt, segment_width = 60, segment_overlap = 0, replace_outliers=True, mode='full', ignore_badsignalwarning=True) ----> 4 bvp = pd.DataFrame(data=m, index=None) ~/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy) 346 dtype=dtype, copy=copy) 347 elif isinstance(data, dict): --> 348 mgr = self._init_dict(data, index, columns, dtype=dtype) 349 elif isinstance(data, ma.MaskedArray): 350 import numpy.ma.mrecords as mrecords ~/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/core/frame.py in _init_dict(self, data, index, columns, dtype) 457 arrays = [data[k] for k in keys] 458 --> 459 return _arrays_to_mgr(arrays, data_names, index, columns, dtype=dtype) 460 461 def _init_ndarray(self, values, index, columns, dtype=None, copy=False): ~/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/core/frame.py in _arrays_to_mgr(arrays, arr_names, index, columns, dtype) 7354 # figure out the index, if necessary 7355 if index is None: -> 7356 index = extract_index(arrays) 7357 7358 # don't force copy because getting jammed in an ndarray anyway ~/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/core/frame.py in extract_index(data) 7400 lengths = list(set(raw_lengths)) 7401 if len(lengths) > 1: -> 7402 raise ValueError('arrays must all be same length') 7403 7404 if have_dicts: ValueError: arrays must all be same length
paulvangentcom commented 1 year ago

Can you share with me the data you're using?