NeuroKit icon indicating copy to clipboard operation
NeuroKit copied to clipboard

Running _ecg_quality_pSQI, _ecg_quality_basSQI

Open alexxony opened this issue 2 years ago • 4 comments

Question and context I tried to dismantle neurokit2.ecg.ecg_quality for speed up but I can not run _ecg_quality_pSQI, _ecg_quality_basSQI

pdf is ecg_3000hz.csv

@nb.jit def _ecg_quality_pSQI( ecg_cleaned, sampling_rate=1000, window=1024, num_spectrum=[5, 15], dem_spectrum=[5, 40], **kwargs ): """Power Spectrum Distribution of QRS Wave."""

psd = signal_power(
    ecg_cleaned,
    sampling_rate=sampling_rate,
    frequency_band=[num_spectrum, dem_spectrum],
    method="welch",
    normalize=False,
    window=window,
    **kwargs
)

num_power = psd.iloc[0][0]
dem_power = psd.iloc[0][1]

return num_power / dem_power

@nb.jit def _ecg_quality_basSQI( ecg_cleaned, sampling_rate=1000, window=1024, num_spectrum=[0, 1], dem_spectrum=[0, 40], **kwargs ): """Relative Power in the Baseline.""" psd = signal_power( ecg_cleaned, sampling_rate=sampling_rate, frequency_band=[num_spectrum, dem_spectrum], method="welch", normalize=False, window=window, **kwargs )

num_power = psd.iloc[0][0]
dem_power = psd.iloc[0][1]

return 1 - num_power / dem_power

_ecg_quality_pSQI(pdf,sampling_rate=1000, window=1024, num_spectrum=[5, 15], dem_spectrum=[5, 40] )

it raised error

**UnsupportedError: Failed in object mode pipeline (step: analyzing bytecode) Use of unsupported opcode (BUILD_MAP_UNPACK_WITH_CALL) found

File "", line 21: def _ecg_quality_pSQI(

psd = signal_power(**

how can i use these functions?

alexxony avatar Aug 19 '21 14:08 alexxony

On a side note, could you please try to edit your post using markdown syntax so that the different code chunks are clearly specified, otherwise it makes it quite difficult to read and try out

DominiqueMakowski avatar Aug 19 '21 23:08 DominiqueMakowski

def _ecg_quality_pSQI(ecg_cleaned, sampling_rate=1000, window=1024, num_spectrum=[5, 15], dem_spectrum=[5, 40], **kwargs):

psd = signal_power(ecg_cleaned, sampling_rate=sampling_rate,
                   frequency_band=[num_spectrum, dem_spectrum],
                   method="welch", normalize=False, window=window, **kwargs)

num_power = psd.iloc[0][0]
dem_power = psd.iloc[0][1]

return num_power / dem_power

def _ecg_quality_basSQI(ecg_cleaned, sampling_rate=1000, window=1024, num_spectrum=[0, 1], dem_spectrum=[0, 40], **kwargs):

  psd = signal_power(ecg_cleaned, sampling_rate=sampling_rate,
                     frequency_band=[num_spectrum, dem_spectrum],
                     method="welch", normalize=False, window=window, **kwargs)

  num_power = psd.iloc[0][0]
  dem_power = psd.iloc[0][1]

  return 1 - num_power / dem_power

two functions in neurokit2.ecg.ecg_quality

how can use these functions individually??

alexxony avatar Aug 20 '21 06:08 alexxony

Hi @alexxony,

I don't think I understand the issue that was raised. What do you mean by using them individually?

If possible, could you share with us the full script where you try to use these functions (from importing, reading data....)? A full script is one that we can run and replicate the exact error that you faced. For now, it's not clear what have you tried to do with these 2 functions

def _ecg_quality_pSQI(ecg_cleaned, sampling_rate=1000, window=1024, num_spectrum=[5, 15],  dem_spectrum=[5, 40], **kwargs):

    psd = signal_power(ecg_cleaned, sampling_rate=sampling_rate,
                       frequency_band=[num_spectrum, dem_spectrum],
                       method="welch", normalize=False, window=window, **kwargs)

    num_power = psd.iloc[0][0]
    dem_power = psd.iloc[0][1]

    return num_power / dem_power
 def _ecg_quality_basSQI(ecg_cleaned, sampling_rate=1000, window=1024, num_spectrum=[0, 1], dem_spectrum=[0, 40], **kwargs):
  
      psd = signal_power(ecg_cleaned, sampling_rate=sampling_rate,
                         frequency_band=[num_spectrum, dem_spectrum],
                         method="welch", normalize=False, window=window, **kwargs)
  
      num_power = psd.iloc[0][0]
      dem_power = psd.iloc[0][1]
  
      return 1 - num_power / dem_power

Tam-Pham avatar Aug 22 '21 08:08 Tam-Pham

Hopefully this is addressed but feel free to re-open if not

DominiqueMakowski avatar Sep 21 '22 00:09 DominiqueMakowski