Skip to content

Importing the yarppg package is not working/taking too long #23

@Niteesh-Kalangi

Description

@Niteesh-Kalangi

I am trying to use yarppg as a package, and I did all the instructions to install the package locally.

I have attached my code below. Basically, it prints "hello" once and then stops for like 5 mins (didn't wait longer than that), meaning it is stuck when importing yarppg. Also, just a note: it was working before. But that was like a few weeks ago, but now when I am running the same program, this issue is happening. How can I fix or debug this?

print("hello")
import yarppg
print("hello")
import matplotlib.pyplot as plt
import numpy as np
import scipy.signal
import neurokit2 as nk
import joblib
import pandas as pd
print("hello")



filename = "/Users/niteesh/Desktop/rppg-tes1.mov"

fps = yarppg.get_video_fps(filename)
filter_cfg = yarppg.digital_filter.FilterConfig(fps, 0.5, 1.5, btype="bandpass")
livefilter = yarppg.digital_filter.make_digital_filter(filter_cfg)
processor = yarppg.FilteredProcessor(yarppg.Processor(), livefilter=livefilter)

rppg = yarppg.Rppg(
    processor=processor,
    hr_calc=yarppg.PeakBasedHrCalculator(fps, window_seconds=4),
)
results = rppg.process_video(filename)

distanceVal = 0.5
values = np.array(results)
hrs = yarppg.bpm_from_frames_per_beat(values[:, -1], fps)

signals = values[:, 0]

mean_hr = np.nanmean(hrs)
peaks, _ = scipy.signal.find_peaks(signals, distance=distanceVal * fps)
hrv_indices = nk.hrv(peaks, sampling_rate=fps, show=True)
print("Type", type(hrv_indices))
sdrr = hrv_indices['HRV_SDNN'].loc[0]  # Standard deviation of NN intervals
rmssd = hrv_indices['HRV_RMSSD'].loc[0]  # Root mean square of successive differences
sdsd = hrv_indices['HRV_SDSD'].loc[0]  # Standard deviation of successive differences
pnn50 = hrv_indices['HRV_pNN50'].loc[0]  # Proportion of pairs of successive NNs that differ by more than 50 ms
HRV_metrics = {"HR": mean_hr, "SDNN": sdrr, "RMSSD": rmssd, "SDSD": sdsd, "pNN50": pnn50}
print(HRV_metrics)
print("pNN50", pnn50)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions