MPBA / pyphysio

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

No need Signal segment #59

Closed AlanConstantine closed 3 years ago

AlanConstantine commented 3 years ago

How to pass the parameter to ph.fmap() if I don't want to segment my signals?

I have tried to use ph.CustomSegments(),

fixed_length = ph.CustomSegments(begins=[x_values_time_bvp[0]], ends=[x_values_time_bvp[-1]])
FD_HRV_ind, col_names = ph.fmap(fixed_length, ph.preset_hrv_fd(), ibi.resample(4))
FD_HRV_df = pd.DataFrame(FD_HRV_ind, columns=col_names)

However, it encountered an error:

IndexError                                Traceback (most recent call last)
<ipython-input-48-050706c3471d> in <module>
----> 1 FD_HRV_ind, col_names = ph.fmap(fixed_length, ph.preset_hrv_fd(), ibi.resample(4))
      2 FD_HRV_df = pd.DataFrame(FD_HRV_ind, columns=col_names)

~/anaconda3/lib/python3.7/site-packages/pyphysio/__init__.py in fmap(segments, algorithms, alt_signal)
    235     #for compatibility
    236     if not alt_signal.is_multi():
--> 237         values = values[:,:,0]
    238 
    239     col_names = ["begin", "end", "label"] + [x.__repr__() for x in algorithms]

IndexError: too many indices for array

Also, when I removing .resample(4), it encountered:

AssertionError: The PSD can be computed on EvenlySignals only. Consider interpolating the signal: signal.resample(fsamp)
Alebat commented 3 years ago

Hi, did you try to run each of the algorithms in the HRV FD preset directly on ibi.resample(4)?

AlanConstantine commented 3 years ago

Hi, did you try to run each of the algorithms in the HRV FD preset directly on ibi.resample(4)?

It works! thanks for your hints!