Пример #1
0
def main(argv):
    nc = len(argv) - 4

    if len(argv) < 4:
        print "usage:",  argv[0], "record start duration [ coefficients ... ]"
        sys.exit(1)
    if nc < 1: nc = 1
    c = [0.] * nc
    for i in range(0, nc):
        c[i] = float(argv[i+4])
    nsig = wfdb.isigopen(argv[1], None, 0)
    if nsig < 1: sys.exit(3)
    s = wfdb.WFDB_SiginfoArray(nsig)
    v = wfdb.WFDB_SampleArray(nsig)
    if wfdb.isigopen(argv[1], s.cast(), nsig) != nsig: sys.exit(3)
    if wfdb.isigsettime(wfdb.strtim(argv[2])) < 0: sys.exit(4)
    nsamp = wfdb.strtim(argv[3])
    if nsamp < 1:
        print argv[0]+ ": inappropriate value for duration"
        sys.exit(5)
    if wfdb.osigopen("16l", s.cast(), nsig) != nsig: sys.exit(6)
    wfdb.sample(0, 0)
    for t in range(0, nsamp):
        if not wfdb.sample_valid(): break
        for j in range(0, nsig):
            vv = 0
            for i in range(0, nc):
                if c[i] != 0.: vv += c[i] * wfdb.sample(j, t+i)
            v[j] = int(vv)
        if wfdb.putvec(v.cast()) < 0: break
    wfdb.newheader("out")
    wfdb.wfdbquit()
Пример #2
0
def main(argv):
    nsamp = 1000
    if len(argv) < 2:
        print "usage:", argv[0], "record"
        sys.exit(1)
    nsig = wfdb.isigopen(argv[1], None, 0)
    if nsig <= 0: sys.exit(2)
    s = wfdb.WFDB_SiginfoArray(nsig)
    vin = wfdb.WFDB_SampleArray(nsig)
    vout = wfdb.WFDB_SampleArray(nsig)
    if wfdb.isigopen(argv[1], s.cast(), nsig) != nsig: sys.exit(2)
    if wfdb.osigopen("8l", s.cast(), nsig) <= 0: sys.exit(3)
    while nsamp > 0 and wfdb.getvec(vin.cast()) > 0:
        nsamp -= 1
        for i in range(0, nsig): vout[i] -= vin[i]
        if wfdb.putvec(vout.cast()) < 0: break
        for i in range(0, nsig): vout[i] = vin[i]
    wfdb.newheader("dif")
    wfdb.wfdbquit()