Exemple #1
0
def get_more_evidence():
    """
    Obtains a new piece of evidence and introduces it in the appropriate
    structures.
    """
    if BUF.get_status() is BUF.Status.STOPPED:
        return
    dtime = _TFACTOR * (T.time() - _T0) * 1000.0
    cursize = SIG.get_signal_length()
    if dtime - sp2ms(cursize) > sp2ms(_STEP):
        nchunks = int((min(ms2sp(dtime), _DURATION) - cursize) / _STEP)
        init = _OFFSET + cursize
        for i in xrange(len(_REC.leads)):
            fragment = _REC.signal[i, init:init + nchunks * _STEP]
            if len(fragment) < nchunks * _STEP:
                fragment = np.concatenate(
                    (fragment,
                     fragment[-1] * np.ones(_STEP - len(fragment) % _STEP)))
            SIG.add_signal_fragment(fragment, _REC.leads[i])
        for ann in (a for a in _ANNOTS
                    if ((is_qrs_annotation(a) or a.code is ECGCodes.FLWAV)
                        and init <= a.time < init + nchunks * _STEP)):
            rdef = o.RDeflection()
            atime = ann.time - _OFFSET
            rdef.time.value = Iv(atime, atime)
            #The level is established according to the annotation information.
            rdef.level = {
                SIG.VALID_LEAD_NAMES[lead]: 127
                for lead in _REC.leads
            }
            rdef.level[SIG.VALID_LEAD_NAMES[_REC.leads[ann.chan]]] = (127 -
                                                                      ann.num)
            rdef.freeze()
            BUF.publish_observation(rdef)
        newsize = SIG.get_signal_length()
        if newsize >= _DURATION or newsize >= len(_REC.signal[0]) - _OFFSET:
            BUF.set_status(BUF.Status.STOPPED)
Exemple #2
0
def get_acquisition_point():
    """
    Obtains the time point, in signal samples, where the acquisition process
    is.
    """
    return SIG.get_signal_length()
Exemple #3
0

def get_record_name():
    """Obtains the name of the input reecord"""
    return _RECNAME


if __name__ == "__main__":
    REC = '/databases/mit/100'
    set_record(REC, 'qrs')
    set_duration(10240)
    set_offset(18550)
    start()
    while True:
        get_more_evidence()
        print(SIG.get_signal_length(), BUF.get_status())
        if BUF.get_status() == BUF.Status.STOPPED:
            break
        T.sleep(0.1)
    print('Total length of acquired signal: {0} (in {1} s)'.format(
        SIG.get_signal_length(),
        T.time() - _T0))
    reset()
    #We test higher temporal factors
    _TFACTOR = 30.0
    set_duration(650240)
    set_offset(0)
    start()
    while True:
        get_more_evidence()
        print(SIG.get_signal_length(), BUF.get_status())