Ejemplo n.º 1
0
 def test_calc_instant_freq(self):
     t = np.linspace(0, 1, 50)
     S = t + np.cos(np.cos(4. * t**2))
     emd = EMD()
     imfs = emd.emd(S, t)
     vis = Visualisation()
     freqs = vis._calc_inst_freq(imfs, t, False, None)
     assert imfs.shape == freqs.shape
Ejemplo n.º 2
0
 def test_calc_instant_phase2(self):
     t = np.linspace(0, 1, 50)
     S = t + np.cos(np.cos(4. * t**2))
     emd = EMD()
     imfs = emd.emd(S, t)
     vis = Visualisation()
     phase = vis._calc_inst_phase(imfs, 0.4)
     assert len(imfs) == len(phase)
Ejemplo n.º 3
0
 def test_calc_instant_phase3(self):
     t = np.linspace(0, 1, 50)
     S = t + np.cos(np.cos(4. * t**2))
     emd = EMD()
     imfs = emd.emd(S, t)
     vis = Visualisation()
     with self.assertRaises(AssertionError):
         phase = vis._calc_inst_phase(imfs, 0.8)
Ejemplo n.º 4
0
 def test_check_imfs5(self):
     t = np.linspace(0, 1, 50)
     S = t + np.cos(np.cos(4. * t**2))
     emd = EMD()
     emd.emd(S, t)
     imfs, res = emd.get_imfs_and_residue()
     vis = Visualisation(emd)
     imfs2, res2 = vis._check_imfs(imfs, res, False)
     assert (imfs == imfs2).all()
     assert (res == res2).all()
Ejemplo n.º 5
0
 def test_instantiation2(self):
     t = np.linspace(0, 1, 50)
     S = t + np.cos(np.cos(4. * t**2))
     emd = EMD()
     emd.emd(S, t)
     imfs, res = emd.get_imfs_and_residue()
     vis = Visualisation(emd)
     assert (vis.imfs == imfs).all()
     assert (vis.residue == res).all()
Ejemplo n.º 6
0
 def test_calc_instant_phase(self):
     sig = np.arange(10)
     vis = Visualisation()
     phase = vis._calc_inst_phase(sig, None)
     assert len(sig) == len(phase)
Ejemplo n.º 7
0
 def test_plot_imfs(self):
     vis = Visualisation()
     with self.assertRaises(AttributeError):
         vis.plot_imfs()
Ejemplo n.º 8
0
 def test_check_imfs4(self):
     vis = Visualisation()
     imfs = np.arange(50).reshape(2, 25)
     with self.assertRaises(AttributeError):
         vis._check_imfs(imfs, None, True)
Ejemplo n.º 9
0
 def test_check_imfs3(self):
     vis = Visualisation()
     imfs = np.arange(50).reshape(2, 25)
     vis._check_imfs(imfs, None, False)
Ejemplo n.º 10
0
 def test_check_imfs2(self):
     vis = Visualisation()
     with self.assertRaises(AttributeError):
         vis._check_imfs(None, None, False)
Ejemplo n.º 11
0
 def test_check_imfs(self):
     vis = Visualisation()
     imfs = np.arange(50).reshape(2, 25)
     res = np.arange(25)
     imfs, res = vis._check_imfs(imfs, res, False)
     assert len(imfs) == 2
Ejemplo n.º 12
0
 def test_instantiation(self):
     emd = EMD()
     with self.assertRaises(ValueError):
         Visualisation(emd)
Ejemplo n.º 13
0
 def test_plot_instant_freq(self):
     vis = Visualisation()
     t = np.arange(20)
     with self.assertRaises(AttributeError):
         vis.plot_instant_freq(t)
from PyEMD.EMD import EMD
from PyEMD.visualisation import Visualisation

# Perform decomposition
print("Performing decomposition... ")

emd = EMD()
emd.emd(senial_indep_2500_muestras, max_imf=5)

emd_dis = EMD()
emd_dis.emd(senial_indep_2500_muestras_dislexia, max_imf=5)

imfs, res = emd.get_imfs_and_residue()
imfs_dis, res_dis = emd_dis.get_imfs_and_residue()

vis = Visualisation()

print("Sujeto Normal")
vis.plot_imfs(imfs=imfs, residue=res, t=time, include_residue=False)
vis.plot_instant_freq(time, imfs=imfs)
vis.show()

print("Sujeto Dislexia")
vis.plot_imfs(imfs=imfs_dis,
              residue=res_dis,
              t=time_dislex,
              include_residue=False)
vis.plot_instant_freq(time_dislex, imfs=imfs_dis)
vis.show()

# Una vez extraída la señal hago la media: