Esempio n. 1
0
def main(argv):
    an = wfdb.WFDB_AnninfoArray(2)
    annot = wfdb.WFDB_Annotation()
    record = raw_input("Type record name: ")
    iann = raw_input("Type input annotatior name")
    oann = raw_input("Type output annotator name: ")
    
    a = wfdb.WFDB_Anninfo()
    a.name = iann
    a.stat = wfdb.WFDB_READ
    an[0] = a
    
    a = wfdb.WFDB_Anninfo()
    a.name = oann
    a.stat = wfdb.WFDB_WRITE
    an[1] = a
    
    if wfdb.annopen(record ,an , 2) < 0:  sys.exit(1)
    
    while wfdb.getann(0 , annot) ==0:
        if wfdb.wfdb_isqrs(annot.anntyp):
            annot.anntyp = wfdb.NORMAL
            if wfdb.putann(0 , annot)<0: break
    
    wfdb.wfdbquit()
Esempio n. 2
0
def main(argv):
    an = wfdb.WFDB_AnninfoArray(2)
    annot = wfdb.WFDB_Annotation()
    if len(argv) < 2:
        print "usage:", argv[0], "record"
        sys.exit(1)
    a = an[0]
    a.name = "atr"
    a.stat = wfdb.WFDB_READ
    an[0] = a
    a = an[1]
    a.name = "aha"
    a.stat = wfdb.WFDB_AHA_WRITE
    an[1] = a
    if wfdb.annopen(argv[1], an.cast(), 2) < 0: sys.exit(2)
    while 1:
        if not (wfdb.getann(0, annot) == 0 and wfdb.putann(0,annot) == 0):
            break
    wfdb.wfdbquit()
Esempio n. 3
0
def main(argv):

    time = maxslope = nslope = scmin = 0
    a = wfdb.WFDB_Anninfo()
    annot = wfdb.WFDB_Annotation()

    if len(argv) < 2:
        print "usage:", argv[0], "record [threshold]"
        sys.exit(1)
    
    a.name = "qrs"
    a.stat = wfdb.WFDB_WRITE

    nsig = wfdb.isigopen(argv[1], None, 0)
    if nsig < 1: sys.exit(2)
    s = wfdb.WFDB_SiginfoArray(nsig)
    v = wfdb.WFDB_SampleArray(nsig)
    if wfdb.wfdbinit(argv[1], a, 1, s.cast(), nsig) != nsig: sys.exit(2)
    if wfdb.sampfreq(None) < 240. or wfdb.sampfreq(None) > 260.:
	wfdb.setifreq(250.)
    if len(argv) > 2: scmin = wfdb.muvadu(0, argv[2])
    if scmin < 1: scmin = wfdb.muvadu(0, 1000)
    slopecrit = scmax = 10 * scmin
    ms160 = wfdb.strtim("0.16")
    ms200 = wfdb.strtim("0.2")
    s2 = wfdb.strtim("2")
    annot.subtyp = annot.chan = annot.num = 0
    annot.aux = None
    wfdb.getvec(v.cast())
    t9 = t8 = t7 = t6 = t5 = t4 = t3 = t2 = t1 = v[0]

    while 1:
        t0 = v[0]
        filter = t0 + 4*t1 + 6*t2 + 4*t3 + t4 - t5 - 4*t6 - 6*t7 - 4*t8 - t9
        if time % s2 == 0:
            if nslope == 0:
                slopecrit -= slopecrit >> 4
                if slopecrit < scmin: slopecrit = scmin
            elif nslope >= 5:
                slopecrit += slopecrit >> 4
                if slopecrit > scmax: slopecrit = scmax
        if nslope == 0 and abs(filter) > slopecrit: 
            nslope = 1
            maxtime = ms160
            if filter > 0:
                sign = 1
            else:
                sign = -1
            qtime = time
        if nslope != 0:
            if filter * sign < -slopecrit: 
                sign = -sign
                nslope = nslope + 1
                if nslope > 4:       
                    maxtime = ms200
                else:
                    maxtime = ms160
            elif filter * sign > slopecrit and \
                     abs(filter) > maxslope:
                maxslope = abs(filter)
            if maxtime < 0:
                if 2 <= nslope and nslope <= 4:
                    slopecrit += ((maxslope>>2) - slopecrit) >> 3
                    if slopecrit < scmin:
                        slopecrit = scmin
                    elif slopecrit > scmax:
                        slopecrit = scmax
                    annot.time = wfdb.strtim("i") - (time - qtime) - 4
                    annot.anntyp = wfdb.NORMAL
                    wfdb.putann(0, annot)
                    time = 0
                elif nslope >= 5: 
                    annot.time = wfdb.strtim("i") - (time - qtime) - 4
                    annot.anntyp = wfdb.ARFCT
                    wfdb.putann(0, annot)
                nslope = 0
            maxtime = maxtime - 1
        t9 = t8
        t8 = t7
        t7 = t6
        t6 = t5
        t5 = t4
        t4 = t3
        t3 = t2
        t2 = t1
        t1 = t0
        time = time + 1
        if not wfdb.getvec(v.cast()) > 0: break

    wfdb.wfdbquit()
Esempio n. 4
0
def main(argv):
    # First get a wrapper object to C array of Anninfo structures.
    an = wfdb.WFDB_AnninfoArray(2)
    # In early versions of the wrapper this would have also allocated
    # the WFDB_Anninfo C-structures in the array.  As of SWIG v2.0.8
    # it appears that only the array is allocated, not the Anninfo
    # structures within.


    # Get a wrapper object for an annotation structure 
    annot = wfdb.WFDB_Annotation()

    # Check to see if there is command line argument
    if len(argv) < 2:
        # no command line argument, so print usage and exit
        print "usage:", argv[0], "record"
        sys.exit(1)

    record = argv[1] # the record name is the first argument

    # Now we're going to setup the Anninfo structures so we can call
    # annopen later

    # First get a new Anninfo structure.
    a = wfdb.WFDB_Anninfo()   
    # In the early version this line was:
    #   a = an[0]
    # because calling wfdb.AnninfoArray(2), previously allocated
    # each Anninfo info the the array as well. Now we need to explicitly
    # allocate a new Anninfo struct instead of getting one from the 
    # AnninfoArray "an"

    # now assign the values of a
    a.name = "atr"
    a.stat = wfdb.WFDB_READ

    # finally assign the anninfo struct, "a", to its place in the
    # array "an"
    an[0] = a

    # repeat for output annotation
    a = wfdb.WFDB_Anninfo()
    a.name = "aha"
    a.stat = wfdb.WFDB_AHA_WRITE
    an[1] = a

    # We call annopen with the record name, given on the command line,
    # and the AnninfoArray, "an", we just setup.  
    if wfdb.annopen(record, an, 2) < 0: sys.exit(2)
    # note that in previous versions, it was necessary to use 'an.cast()',
    # rather then simply 'an', when passing an AnninfoArray to a wfdb
    # functoin.  Now the wrappers no longer require the 'cast()' in most
    # cases.

    # now iterate until all annotations have been ready
    while 1:
        # read an annotation from the input annotator and put it into
        # the output, AHA formatted, annotator
        if not (wfdb.getann(0, annot) == 0 and wfdb.putann(0,annot) == 0):
            break
    wfdb.wfdbquit()