예제 #1
0
    'B': -1,
}
prob = {
    'A': 0.,
    'B': 0.,
}
allOffs = {}
OffsRaw = {}

print 'enter DB'
for rec in db.iteritems():
    # Gambi pra verificar se o spike ja foi classificado
    off, bindata = rec
    read_data = recogdb.parseDBHeader(bindata)
    offraw, direction, distA, distB, distAB, SaturationFlag, svm, pairsvm, prob[
        'A'], prob['B'], fishwins = recogdb.fishrec(rec)
    off = offraw / 4 / NumChannels

    for PIdx in fishwins.keys():
        if PIdx == 'A':
            f.write('%d %d\n' % (1, off + fishwins[PIdx][0]))
        if PIdx == 'B':
            f.write('%d %d\n' % (-1, off + fishwins[PIdx][0]))
        f.flush()
    '''correctedPosA = read_data[ recogdb.dicFields['correctedPosA'] ]
    correctedPosB = read_data[ recogdb.dicFields['correctedPosB'] ]

    if (correctedPosA != -1) and (correctedPosB != -1):
        f.write( '%d\t%d\n'%(1, correctedPosA) )
        f.write( '%d\t%d\n'%(-1, correctedPosB) )
        continue
예제 #2
0
import scipy.signal as sig

NumChannels = 7

db = bsddb3.btopen(sys.argv[1], 'r')
winfile = open(sys.argv[2], 'rb')
checkfish = sys.argv[3]
checkfile = open(sys.argv[4], 'rb')
threshold = float(sys.argv[5])

assert (checkfish in ('A', 'B'))

filt = sig.firwin(100, .1)

for rec in db.iteritems():
    off, distA, distB, distAB, fishwins = recogdb.fishrec(rec)
    wlastlen, = struct.unpack('i', winfile.read(4))
    woff, wsamples, wchannels = struct.unpack('qii', winfile.read(8 + 4 * 2))
    winfile.seek(wchannels * (4 + wsamples * 4), 1)

    assert (off == woff)

    checkoff = off / NumChannels
    checkfile.seek(checkoff)

    buf = np.frombuffer(checkfile.read(wsamples * 4), dtype=np.float32)
    buf = np.convolve(filt, buf)
    fishexists = 1 if abs(buf).max() >= threshold else 0
    fishdetected = 1 if checkfish in fishwins else 0

    if fishexists ^ fishdetected == 1:
예제 #3
0
              }
flag = {    'A': 1,
            'B': -1,
       }
prob = {    'A': 0.,
            'B': 0.,
       }
allOffs = {}
OffsRaw = {}

print 'enter DB'
for rec in db.iteritems():
    # Gambi pra verificar se o spike ja foi classificado
    off, bindata = rec
    read_data = recogdb.parseDBHeader(bindata)
    offraw, direction, distA, distB, distAB, SaturationFlag, svm, pairsvm, prob['A'], prob['B'], fishwins = recogdb.fishrec(rec)
    off = offraw/4/NumChannels

    for PIdx in fishwins.keys():
        if PIdx == 'A':
            f.write('%d %d\n'%(1, off + fishwins[PIdx][0]))
        if PIdx == 'B':
            f.write('%d %d\n'%(-1, off + fishwins[PIdx][0]))
        f.flush()

    '''correctedPosA = read_data[ recogdb.dicFields['correctedPosA'] ]
    correctedPosB = read_data[ recogdb.dicFields['correctedPosB'] ]

    if (correctedPosA != -1) and (correctedPosB != -1):
        f.write( '%d\t%d\n'%(1, correctedPosA) )
        f.write( '%d\t%d\n'%(-1, correctedPosB) )
예제 #4
0
NumChannels = 11

db = bsddb3.btopen(sys.argv[1], 'r')

searchoff = np.inf
if len(sys.argv) >= 3:
    searchoff = int(sys.argv[2])

A = [list([]) for i in xrange(NumChannels)]
B = [list([]) for i in xrange(NumChannels)]

mark = None

for rec in db.iteritems():
    off, distA, distB, distAB, fishwins = recogdb.fishrec(rec)
    if mark == None and off >= searchoff:
        print(repr(('mark', off, distA, distB, distAB)))
        mark = sum(map(len,A[0]))
    dataA = fishwins['A'][1] if 'A' in fishwins else np.zeros((NumChannels,0))
    dataB = fishwins['B'][1] if 'B' in fishwins else np.zeros((NumChannels,0))
    arrsz = max(dataA.shape[1], dataB.shape[1]) + 2
    apszA = arrsz - dataA.shape[1]
    apszB = arrsz - dataB.shape[1]
    dataA = np.concatenate((dataA, np.nan*np.ones((NumChannels,apszA))),1)
    dataB = np.concatenate((dataB, np.nan*np.ones((NumChannels,apszB))),1)
    for i in xrange(NumChannels):
        A[i].append(dataA[i,:])
        B[i].append(dataB[i,:])

A = map(np.concatenate, A)