def test_load_wfdb_annotation(self, setup_module_load): #pylint: disable=redefined-outer-name """ Testing wfdb loader for annotation. """ # Arrange path = setup_module_load[1] ind = bf.FilesIndex(path=os.path.join(path, 'sel100.hea'), no_ext=True, sort=True) batch = EcgBatch(ind) # Act batch = batch.load(fmt="wfdb", components=["signal", "annotation", "meta"], ann_ext="pu1") # Assert assert isinstance(batch.signal, np.ndarray) assert isinstance(batch.meta, np.ndarray) assert isinstance(batch.annotation, np.ndarray) assert batch.signal.shape == (1, ) assert batch.annotation.shape == (1, ) assert batch.meta.shape == (1, ) assert isinstance(batch.signal[0], np.ndarray) assert isinstance(batch.annotation[0], dict) assert isinstance(batch.meta[0], dict) assert 'annsamp' in batch.annotation[0] assert 'anntype' in batch.annotation[0] del batch
def test_load_wfdb(self, setup_module_load): #pylint: disable=redefined-outer-name """ Testing wfdb loader. """ # Arrange ind = setup_module_load[0] batch = EcgBatch(ind) # Act batch = batch.load(fmt="wfdb", components=["signal", "annotation", "meta"]) # Assert assert isinstance(batch.signal, np.ndarray) assert isinstance(batch.meta, np.ndarray) assert isinstance(batch.annotation, np.ndarray) assert batch.signal.shape == (6,) assert batch.annotation.shape == (6,) assert batch.meta.shape == (6,) assert isinstance(batch.signal[0], np.ndarray) assert isinstance(batch.annotation[0], dict) assert isinstance(batch.meta[0], dict) del batch
def test_load_wav(self, setup_module_load): #pylint: disable=redefined-outer-name """ Testing EDF loader. """ # Arrange path = setup_module_load[1] ind = ds.FilesIndex(path=os.path.join(path, 'sample*.wav'), no_ext=True, sort=True) batch = EcgBatch(ind) # Act batch = batch.load(fmt="wav", components=["signal", "annotation", "meta"]) # Assert assert isinstance(batch.signal, np.ndarray) assert isinstance(batch.meta, np.ndarray) assert isinstance(batch.annotation, np.ndarray) assert batch.signal.shape == (1,) assert batch.annotation.shape == (1,) assert batch.meta.shape == (1,) assert isinstance(batch.signal[0], np.ndarray) assert isinstance(batch.annotation[0], dict) assert isinstance(batch.meta[0], dict) del batch
def setup_class_methods(request): """ Fixture to setup class to test EcgBatch methods separately. """ path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/') ind = ds.FilesIndex(path=os.path.join(path, 'A*.hea'), no_ext=True, sort=True) batch_loaded = (EcgBatch(ind, unique_labels=["A", "O", "N"]) .load(fmt="wfdb", components=["signal", "annotation", "meta"])) def teardown_class_methods(): """ Teardown class """ request.addfinalizer(teardown_class_methods) return batch_loaded