def demoICA():
t = np.linspace(0.0, 30*np.pi, 1000)
s1 = spsig.sawtooth(t)
s2 = np.cos(5.0*t)
s3 = np.random.uniform(-1.0, 1.0, size=t.size)
s = np.vstack((s1,s2,s3)).T
m = np.random.random((3,3))
m /= m.sum(axis=0)
sMixed = s.dot(m)
icaFilt = ICA(sMixed, kurtosis='sub', verbose=True)
fig = plt.figure()
axOrig = fig.add_subplot(4,1, 1)
axOrig.plot(s+util.colsep(s))
axOrig.set_title('Unmixed Signal')
axOrig.autoscale(tight=True)
axMixed = fig.add_subplot(4,1, 2)
axMixed.plot(sMixed+util.colsep(sMixed))
axMixed.set_title('Mixed Signal (random transform)')
axMixed.autoscale(tight=True)
axUnmixed = fig.add_subplot(4,1, 3)
icaFilt.plotTransform(sMixed, ax=axUnmixed)
axUnmixed.set_title('ICA Components')
axUnmixed.autoscale(tight=True)
axCleaned = fig.add_subplot(4,1, 4)
icaFilt.plotFilter(sMixed, comp=(0,1,), ax=axCleaned)
axCleaned.set_title('Cleaned Signal (First two components kept)')
axCleaned.autoscale(tight=True)
fig.tight_layout()
评论列表
文章目录