コード例 #1
0
from glob import glob

locsfile, sps = sys.argv[1:3]

analysis_dir = os.path.dirname(locsfile)
groundfile = locsfile.rsplit('.', 1)[0] + '.ground'
if os.path.exists(groundfile):
    grounds = [numpy.fromfile(groundfile, sep='\n')]
else:
    grounds = [
        numpy.fromfile(g, sep='\n')
        for g in sorted(glob(analysis_dir + '/*.ground'))
    ]

actoutfile = locsfile.rsplit('.', 1)[0] + '.newactout'

if os.path.exists(actoutfile):
    actout = eval(open(actoutfile).read())
else:
    actout = eval(open(sorted(glob(analysis_dir+'/*.preactout'))[-1]).read()) + \
             eval(open(sorted(glob(analysis_dir+'/*.newactout'))[-1]).read())

print >> sys.stderr, 'loaded %s ground lines, %s activity polygons (%s total vertices) from %s' % (
    len(grounds), len(actout), sum([len(p) for p in actout]), analysis_dir)

viz_vidtools.draw_class_scatter_and_pie(locsfile,
                                        sps=float(sps),
                                        scatter_lines=grounds,
                                        scatter_polys=actout,
                                        draw_pie=False)
コード例 #2
0
import os, sys, re, Util, pylab
from glob import glob
from video_analysis import viz_vidtools

adir = sys.argv[1]

sps = re.search('([\d+])sec_', adir).groups()[0]

newacts = sorted(glob(adir + '/*-*.newactout'))[:-1]
preacts = sorted(glob(adir + '/*-*.preactout'))[:-1]
actterms = sorted(glob(adir + '/*-*.newactterm'))[:-1]
locs = sorted(glob(adir + '/*-*.mouselocs'))
for i in range(len(newacts)):
    na = filter(None, eval(open(newacts[i]).read()))
    pa = filter(None, eval(open(preacts[i]).read()))
    polys = pa + na
    poly_col = ['y'] * len(pa) + ['b'] * len(na)
    ml = locs[i + 1]
    viz_vidtools.draw_class_scatter_and_pie(ml,
                                            'png',
                                            sps=float(sps),
                                            scatter_polys=polys,
                                            poly_col=poly_col,
                                            draw_pie=False)
    at = eval(open(actterms[i]).read())
    try:
        x, y = Util.dezip(at[0])
        pylab.plot(x, y, 'c')
    except:
        pass
コード例 #3
0
#!/usr/bin/env python
'''given a summary .mouselocs file and number of seconds per segment (e.g. written at the end of analyze_antfarm) draws a final scatter-and-pie summarizing all ground, mouse and activity calls'''

import os, sys, numpy
from video_analysis import viz_vidtools
from glob import glob

locsfile,sps = sys.argv[1:3]

analysis_dir = os.path.dirname(locsfile)
groundfile = locsfile.rsplit('.',1)[0]+'.ground'
if os.path.exists(groundfile):
    grounds = [numpy.fromfile(groundfile,sep='\n')]
else:
    grounds = [numpy.fromfile(g,sep='\n') for g in sorted(glob(analysis_dir+'/*.ground'))]

actoutfile = locsfile.rsplit('.',1)[0]+'.newactout'

if os.path.exists(actoutfile):
    actout = eval(open(actoutfile).read())
else:
    actout = eval(open(sorted(glob(analysis_dir+'/*.preactout'))[-1]).read()) + \
             eval(open(sorted(glob(analysis_dir+'/*.newactout'))[-1]).read())

print >> sys.stderr, 'loaded %s ground lines, %s activity polygons (%s total vertices) from %s' % (len(grounds), len(actout), sum([len(p) for p in actout]),analysis_dir)

viz_vidtools.draw_class_scatter_and_pie(locsfile,sps=float(sps),scatter_lines=grounds,scatter_polys=actout,draw_pie=False)
コード例 #4
0
'''given an analysis directory, draws a .png summary of mouse locations, prior and new burrows, and ground line for each segment

NB 20091105 ASSUMES OFF-BY-ONE error where all burrowing information for a given segment has filenames corresponding to the SUBSEQUENT segment, i.e. each .newactout outlines activity from the previous segment
'''

import os, sys, re, Util, pylab
from glob import glob
from video_analysis import viz_vidtools

adir = sys.argv[1]

sps = re.search('([\d+])sec_',adir).groups()[0]

newacts = sorted(glob(adir+'/*-*.newactout'))[:-1]
preacts = sorted(glob(adir+'/*-*.preactout'))[:-1]
actterms = sorted(glob(adir+'/*-*.newactterm'))[:-1]
locs = sorted(glob(adir+'/*-*.mouselocs'))
for i in range(len(newacts)):
    na = filter(None,eval(open(newacts[i]).read()))
    pa = filter(None,eval(open(preacts[i]).read()))
    polys = pa+na
    poly_col = ['y']*len(pa) + ['b']*len(na)
    ml = locs[i+1]
    viz_vidtools.draw_class_scatter_and_pie(ml,'png',sps=float(sps),scatter_polys=polys,poly_col=poly_col,draw_pie=False)
    at = eval(open(actterms[i]).read())
    try:
        x,y = Util.dezip(at[0])
        pylab.plot(x,y,'c')
    except:
        pass