def get_signals(self, start=0, interval=10, number_of_signals=2):
        """Returns 2D array :
        1) dimension: channel_idxes
        2) dimension: sample_idxes"""

        end = int(start + interval * self.get_frequency())

        self._signals = np.zeros((end - start + 1, number_of_signals))

        if self._database == "ptb":
            parser = ecg_recording_parser_ptb.ECGRecordingPTBDataParser()
            index = 0
            if number_of_signals != 2:
                signal_indexes = range(0, number_of_signals)
            else:
                signal_indexes = [6, 7]

            for signal_index in signal_indexes:
                self._signals[:, index] = parser.parse(self._path + ".dat",
                                                       channel_no=signal_index,
                                                       modulo=12,
                                                       from_sample=start,
                                                       to_sample=12 *
                                                       (end + 1) - 1,
                                                       invert=False)
                index += 1
        elif self._database == "af":
            parser = ecg_recording_parser_af.ECGRecordingDataParser()
            self._signals[:, :] = parser.parse(self._path + ".dat",
                                               from_sample=start,
                                               to_sample=end)
        else:
            print("Brak zdefiniowanego rodzaju danych do parsowania")

        return (self._signals)
from AF.parsers import ecg_recording_parser_af

import wfdb
import numpy as np

file_path = path.join("downloads", "af", "04048")
record = wfdb.rdsamp(file_path, sampto=556777 + 3000, sampfrom=556777 - 3000)

#a= wfdb.rdann('04746','atr',pbdir='afdb', sampto=103000)
annotation = wfdb.rdann(file_path, 'atr')
annsamp = annotation.__dict__["annsamp"]
names = annotation.__dict__["aux"]
print(annsamp, names)

# SIGNALS
parser = ecg_recording_parser_af.ECGRecordingDataParser()
signals_af = np.array(
    parser.parse(dat_file_name=file_path + '.dat',
                 from_sample=556777 - 3000,
                 to_sample=556777 + 3000))

signal_0 = signals_af[:, 0]
signal_1 = signals_af[:, 1]

plt.figure(4)
plt.subplot(2, 1, 1)
plt.plot(signal_0)
plt.subplot(2, 1, 2)
plt.plot(signal_1)

#
Exemple #3
0
from AF.parsers import ecg_recording_parser_ptb, ecg_recording_parser_af
from AF.model import record

from matplotlib import pyplot as plt
import numpy as np
from os import path

parser_ptb = ecg_recording_parser_ptb.ECGRecordingPTBDataParser()
parser_mit_bih_af = ecg_recording_parser_af.ECGRecordingDataParser()

file_ptb_name_dat = path.join("downloads", "ptb", "patient104", "s0306lre.dat")
file_af_name_dat = path.join("downloads", "af", "04048.dat")

for channel_no in [0]:

    signal_af = np.array(
        parser_mit_bih_af.parse(file_af_name_dat,
                                from_sample=0,
                                to_sample=3000))

    plt.figure(0)
    plt.plot(signal_af[:, 0].ravel())

    plt.figure(1)
    plt.plot(signal_af[:, 1].ravel())

for channel_no in [6, 7]:
    signal = parser_ptb.parse(file_ptb_name_dat,
                              channel_no=channel_no,
                              invert=False,
                              modulo=12,