Пример #1
0
    sf1snrs = []
    sf2snrs = []
    sfwp1snrs = []
    sfwp2snrs = []

    sf1mses = []
    sf2mses = []
    sfwp1mses = []
    sfwp2mses = []
    tds = [s.createSin(50, 60, 0), s.createPulse(50, 60, 0), s.createSpikes(0)]
    for i in range(len(tds)):
        sf1dr = DenoiseRsult(tds[i], sf1pds[i])
        sf2dr = DenoiseRsult(tds[i], sf2pds[i])
        sfwp1dr = DenoiseRsult(tds[i], sfp1pds[i])
        sfwp2dr = DenoiseRsult(tds[i], sfp2pds[i])
        sf1snrs.append(sf1dr.snr())
        sf2snrs.append(sf2dr.snr())
        sfwp1snrs.append(sfwp1dr.snr())
        sfwp2snrs.append(sfwp2dr.snr())

        sf1mses.append(sf1dr.mse())
        sf2mses.append(sf2dr.mse())
        sfwp1mses.append(sfwp1dr.mse())
        sfwp2mses.append(sfwp2dr.mse())
        
    snrss = [sf1snrs, sf2snrs, sfwp1snrs, sfwp2snrs]
    snrsn = ['sf1snrs', 'sf2snrs', 'sfwp1snrs', 'sfwp2snrs']
    msess = [sf1mses, sf2mses, sfwp1mses, sfwp2mses]
    msesn = ['sf1mses', 'sf2mses', 'sfwp1mses', 'sfwp2mses']
    for i in range(len(snrss)):
        print('{0} = {1}'.format(snrsn[i], snrss[i]))
                                  thf='thf3',
                                  thps=[2 + 2 * k for k in range(dl)])
        gthpd = dwd.dwtrec(ncoeffs1, wtname='db4')
        bsthpd = dwd.dwtrec(ncoeffs2, wtname='db4')
        gthpds.append(gthpd)
        bsthpds.append(bsthpd)

    gthsnrs = []
    bsthsnrs = []
    gthmses = []
    bsthmses = []
    tds = [s.createSin(50, 60, 0), s.createPulse(50, 60, 0), s.createSpikes(0)]
    for i in range(len(tds)):
        gthdr = DenoiseRsult(tds[i], gthpds[i])
        bsthdr = DenoiseRsult(tds[i], bsthpds[i])
        gthsnrs.append(gthdr.snr())
        bsthsnrs.append(bsthdr.snr())
        gthmses.append(gthdr.mse())
        bsthmses.append(bsthdr.mse())
    print('gthsnrs = {0}'.format(gthsnrs))
    print('bsthsnrs = {0}'.format(bsthsnrs))
    print('gthmses = {0}'.format(gthmses))
    print('bsthmses = {0}'.format(bsthmses))

    x = [x for x in range(1000)]
    plt.figure()
    for i in range(len(ods)):
        plt.subplot(3, 2, 2 * i + 1)
        plt.title('{0} signal processed by gth'.format(dnames[i]))
        plt.plot(x, gthpds[i])
        plt.subplot(3, 2, 2 * i + 2)
Пример #3
0
    smses = []
    hmses = []
    thsemismses = []
    thf1mses = []
    thf2mses = []
    thf3mses = []
    tds = [s.createSin(50, 60, 0), s.createPulse(50, 60, 0), s.createSpikes(0)]
    for i in range(len(ods)):
        sdr = DenoiseRsult(tds[i], spds[i])
        hdr = DenoiseRsult(tds[i], hpds[i])
        thsemisdr = DenoiseRsult(tds[i], thsemispds[i])
        thf1dr = DenoiseRsult(tds[i], thf1pds[i])
        thf2dr = DenoiseRsult(tds[i], thf2pds[i])
        thf3dr = DenoiseRsult(tds[i], thf3pds[i])
        ssnrs.append(sdr.snr())
        hsnrs.append(hdr.snr())
        thsemissnrs.append(thsemisdr.snr())
        thf1snrs.append(thf1dr.snr())
        thf2snrs.append(thf2dr.snr())
        thf3snrs.append(thf3dr.snr())

        smses.append(sdr.mse())
        hmses.append(hdr.mse())
        thsemismses.append(thsemisdr.mse())
        thf1mses.append(thf1dr.mse())
        thf2mses.append(thf2dr.mse())
        thf3mses.append(thf3dr.mse())

    snrss = [ssnrs, hsnrs, thsemissnrs, thf1snrs, thf2snrs, thf3snrs]
    snrsn = ['ssnrs', 'hsnrs', 'thsemissnrs', 'thf1snrs', 'thf2snrs', 'thf3snrs']
    gcvsnrs = []
    srmsnrs = []

    smses = []
    cvmses = []
    gcvmses = []
    srmmses = []

    tds = [s.createSin(50, 60, 0), s.createPulse(50, 60, 0), s.createSpikes(0)]
    for i in range(len(tds)):
        sdr = DenoiseRsult(tds[i], gpds[i])
        cvdr = DenoiseRsult(tds[i], cvpds[i])
        gcvdr = DenoiseRsult(tds[i], gcvpds[i])
        srmdr = DenoiseRsult(tds[i], srmpds[i])

        ssnrs.append(sdr.snr())
        cvsnrs.append(cvdr.snr())
        gcvsnrs.append(gcvdr.snr())
        srmsnrs.append(srmdr.snr())

        smses.append(sdr.mse())
        cvmses.append(cvdr.mse())
        gcvmses.append(gcvdr.mse())
        srmmses.append(srmdr.mse())

    snrss = [ssnrs, cvsnrs, gcvsnrs, srmsnrs]
    snrsn = ['ssnrs', 'cvsnrs', 'gcvsnrs', 'srmsnrs']
    msess = [smses, cvmses, gcvmses, srmmses]
    msesn = ['smses', 'cvmses', 'gcvmses', 'srmmses']
    for i in range(len(snrss)):
        print('{0} = {1}'.format(snrsn[i], snrss[i]))
Пример #5
0
    hmses = []
    thf3mses = []
    thf3wpmses = []

    tds = [
        s.createSin(200, 60, 0),
        s.createPulse(200, 60, 0),
        s.createSpikes(0)
    ]
    for i in range(len(tds)):
        sdr = DenoiseRsult(tds[i], spds[i])
        hdr = DenoiseRsult(tds[i], hpds[i])
        thf3dr = DenoiseRsult(tds[i], thf3pds[i])
        thf3wpdr = DenoiseRsult(tds[i], thf3wppds[i])

        ssnrs.append(sdr.snr())
        hsnrs.append(hdr.snr())
        thf3snrs.append(thf3dr.snr())
        thf3wpsnrs.append(thf3wpdr.snr())

        smses.append(sdr.mse())
        hmses.append(hdr.mse())
        thf3mses.append(thf3dr.mse())
        thf3wpmses.append(thf3wpdr.mse())

    snrss = [ssnrs, hsnrs, thf3snrs, thf3wpsnrs]
    snrsn = ['ssnrs', 'hsnrs', 'thf3snrs', 'thf3wpsnrs']
    msess = [smses, hmses, thf3mses, thf3wpmses]
    msesn = ['smses', 'hmses', 'thf3mses', 'thf3wpmses']
    for i in range(len(snrss)):
        print('{0} = {1}'.format(snrsn[i], snrss[i]))
Пример #6
0
        hpds.append(hpd)

    ssnrs = []
    hsnrs = []
    smses = []
    hmses = []

    ssms = []
    hsms = []
    slrepvs = []
    hlrepvs = []
    tds = [s.createSin(50, 60, 0), s.createPulse(50, 60, 0), s.createSpikes(0)]
    for i in range(len(tds)):
        sdr = DenoiseRsult(tds[i], spds[i])
        hdr = DenoiseRsult(tds[i], hpds[i])
        ssnrs.append(sdr.snr())
        hsnrs.append(hdr.snr())
        smses.append(sdr.mse())
        hmses.append(hdr.mse())

        ssms.append(sdr.smooth(ods[i]))
        hsms.append(hdr.smooth(ods[i]))
        slrepvs.append(sdr.lrepv(ods[i], 32))
        hlrepvs.append(hdr.lrepv(ods[i], 32))
    print('ssnrs = {0}'.format(ssnrs))
    print('hsnrs = {0}'.format(hsnrs))
    print('smses = {0}'.format(smses))
    print('hmses = {0}'.format(hmses))
    print()
    print('ssms = {0}'.format(ssms))
    print('hsms= {0}'.format(hsms))
Пример #7
0
x = [x for x in range(1000)]
plt.figure()
plt.subplot(3, 2, 1)
plt.plot(x, td1)
plt.title("True sine signal")
plt.subplot(3, 2, 2)
plt.plot(x, od1)
plt.title("Noisy sine signal")
plt.subplot(3, 2, 3)
plt.plot(x, td2)
plt.title("True pulse signal")
plt.subplot(3, 2, 4)
plt.plot(x, od2)
plt.title("Noisy pulse signal")
plt.subplot(3, 2, 5)
plt.plot(x, td3)
plt.title("True spike signal")
plt.subplot(3, 2, 6)
plt.plot(x, od3)
plt.title("Noisy spike signal")

dn1 = DenoiseRsult(td1, od1)
dn2 = DenoiseRsult(td2, od2)
dn3 = DenoiseRsult(td3, od3)
print(dn1.snr(), dn2.snr(), dn3.snr())

plt.tight_layout()
plt.show()


Пример #8
0
            nbcoeff = BlockThMethod(coeffs[j]).recoverdata(
                nbces[1:])  # 除去添加的[0]系数
            nbcoeffs.append(np.asarray(nbcoeff))

        blpd = DWTP(od).dwtrec(nbcoeffs, 'db4')
        blpds.append(blpd)

    ssnrs = []
    blsnrs = []
    smses = []
    blmses = []
    tds = [s.createSin(50, 60, 0), s.createPulse(50, 60, 0), s.createSpikes(0)]
    for i in range(len(tds)):
        sdr = DenoiseRsult(tds[i], spds[i])
        bldr = DenoiseRsult(tds[i], blpds[i])
        ssnrs.append(sdr.snr())
        blsnrs.append(bldr.snr())
        smses.append(sdr.mse())
        blmses.append(bldr.mse())
    print('ssnrs = {0}'.format(ssnrs))
    print('blsnrs = {0}'.format(blsnrs))
    print('smses = {0}'.format(smses))
    print('blmses = {0}'.format(blmses))

    x = [x for x in range(1000)]
    plt.figure()
    plt.subplot(3, 2, 1)
    plt.title('Sine signal processed by soft threshold')
    plt.plot(x, spds[0])
    plt.subplot(3, 2, 2)
    plt.title('Sine signal processed by BP method')