Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from astropy.stats import LombScargle
if len(sys.argv) != 3:
print("Bitte Datei mit dem zu analysierenden Signal angeben!")
else:
f = open(sys.argv[1], "r")
th = float(sys.argv[2])
dataEcg = []
for line in f:
lineValues = line.split()
dataEcg.append(float(lineValues[2]))
#Perform QRS detection
ecgOut = ecg.ecg(signal=dataEcg, sampling_rate=1000., show=False)
#Calculate RR Tachogram
rPeaks = ecgOut[2]
rrTachogram = []
prevPeak = rPeaks[0]
for peak in rPeaks[1:(len(rPeaks))]:
rrTachogram.append(peak - prevPeak)
prevPeak = peak
#Calculate median heartbeat template
templatesForCorrCoef = ecgOut[4]
cleanTemplates = templatesForCorrCoef
medianTemplate = [x / len(cleanTemplates) for x in [sum(x) for x in zip(*cleanTemplates)]]
#Calculate correlation coeffcients
corrCoeffs = []
import matplotlib.pyplot as plt
from scipy.stats.stats import pearsonr
from astropy.stats import LombScargle
if len(sys.argv) != 2:
print("Bitte Datei mit dem zu analysierenden Signal angeben!")
else:
f = open(sys.argv[1], "r")
dataEcg = []
for line in f:
lineValues = line.split()
dataEcg.append(float(lineValues[2]))
#Perform QRS detection
ecgOut = ecg.ecg(signal=dataEcg, sampling_rate=1000., show=False)
#Calculate RR Tachogram
rPeaks = ecgOut[2]
rrTachogram = []
prevPeak = rPeaks[0]
for peak in rPeaks[1:(len(rPeaks))]:
rrTachogram.append(peak - prevPeak)
prevPeak = peak
freq = np.linspace(0, 0.4, 1000)
def movingaverage (values, window):
weights = np.repeat(1.0, window)/window
sma = np.convolve(values, weights, 'valid')
return sma
import sys
#Getting the data
if len(sys.argv) != 3:
print("Bitte Datei mit dem zu analysierenden Signal sowie einen Grenzwert angeben!")
else:
f = open(sys.argv[1], "r")
th = float(sys.argv[2])
dataEcg = []
for line in f:
lineValues = line.split()
dataEcg.append(float(lineValues[2]))
#Perform QRS detection
ecgOut = ecg.ecg(signal=dataEcg, sampling_rate=1000., show=False)
#Calculate RR Tachogram
rPeaks = ecgOut[2]
rrTachogram = []
prevPeak = rPeaks[0]
for peak in rPeaks[1:(len(rPeaks))]:
rrTachogram.append(peak - prevPeak)
prevPeak = peak
#Calculate median heartbeat template
templatesForCorrCoef = ecgOut[4]
cleanTemplates = templatesForCorrCoef
medianTemplate = [x / len(cleanTemplates) for x in [sum(x) for x in zip(*cleanTemplates)]]
#Calculate correlation coeffcients
corrCoeffs = []
def getEcgSignal(file=f, delimiter="", positionInCsvFile=2):
return ecg.ecg(signal=dataEcg, sampling_rate=1000., show=False)
self._general_info_latex = {}
self.set_general_info()
self.figsizes = (12, 4)
# Reset sections that should be shown in the report
self.sections = self._reset_sections()
self.results = results if results is not None else {}
self.signal = signal
self.sampling_rate = sampling_rate if sampling_rate is not None else 1000.
# Get the list of available pyHRV parameters, keys, and other information (see ./files/hrv_keys.json)
self.hrv_keys = pyhrv.utils.load_hrv_keys_json()
# Get the NNI series
if self.signal is not None:
rpeaks = ecg(self.signal, self.sampling_rate, show=False)[2]
self.nni = pyhrv.utils.check_input(None, rpeaks)
else:
# Check input data series
if nni is not None or rpeaks is not None:
self.nni = pyhrv.utils.check_input(nni, rpeaks)
# Clear all the data and files from the working directory
self.clear()
.. SDNN Index and SDANN: In some cases, the NN interval may start in a segment (or
.. Default bin size set to recommended bin size of 1/128 (with 128Hz being the minimum recommended sampling
frequency) as recommended by the HRV guidelines.
.. 'show' has only effect if 'plot' is also True.
.. 'legend' has only effect if 'plot' is also True.
.. 'figsize' has only effect if 'plot' is also True.
Raises
------
TypeError
If no input data for 'nni', 'rpeaks', and 'signal' provided.
"""
# Check input
if signal is not None:
rpeaks = ecg(signal=signal, sampling_rate=sampling_rate, show=False)[2]
elif nni is None and rpeaks is None:
raise TypeError('No input data provided. Please specify input data.')
# Get NNI series
nn = tools.check_input(nni, rpeaks)
# Call time domain functions & wrap results in a single biosspy.utils.ReturnTuple object
results = nni_parameters(nn)
results = tools.join_tuples(results, hr_parameters(nn))
results = tools.join_tuples(results, nni_differences_parameters(nn))
results = tools.join_tuples(results, sdnn(nn))
results = tools.join_tuples(results, sdnn_index(nn))
results = tools.join_tuples(results, sdann(nn))
results = tools.join_tuples(results, rmssd(nn))
results = tools.join_tuples(results, sdsd(nn))
results = tools.join_tuples(results, nn50(nn))