#print >> sys.stderr, 'link %s from %s' % (new_base+'.ground',source_base+'.ground')
        os.system('ln -s %s %s' % (os.path.join(os.getcwd(),source_base+'.ground'), os.path.join(os.getcwd(),new_base+'.ground') ) )

    #if we need to compute frame avg:
    if not os.path.exists(new_base+'.frame'):
        frameav = vidtools.average_frames(vidtools.load_normed_arrays(new_ims[i:i+segment_step],pixav))
        frameav.tofile(new_base+'.frame')

frameavs = sorted(glob(new_outroot+'/*.frame'))
print >> sys.stderr, 'compute activity matrices from frame averages (%s frame averages found)' % len(frameavs)
for i,f in enumerate(frameavs):
    actmatf = os.path.splitext(f)[0]+'.actmat'
    if not os.path.exists(actmatf) and i>0 and i<len(frameavs)-1:
        actmat = Util.zscore(numpy.fromfile(frameavs[i-1]).reshape(shape) - numpy.fromfile(frameavs[i+1]).reshape(shape))
        actmat.tofile(actmatf)
    




# switches cumulative activity calc to activity below an artificial "lowest ground" - should fix squirrely groundfinding

allgrounds = numpy.array([numpy.fromfile(f,sep='\n') for f in glob(prev_adir+'/*.ground')])
low_ground = numpy.array([max(col) for col in allgrounds.transpose()])

#zburrow = 3
#for now, force_all is set manually; might migrate to opts eventually
activity,termini,progress = vidtools.calculate_cumulative_activity(new_outroot,float(zburrow),shape=shape,be=None,suppress_ground=5,force_all=False,use_ground=low_ground)

viz_vidtools.draw_reanalysis_activity_summary(new_outroot,prev_adir,outformat='pdf')
        actmask.tofile(actmaskf)
    ##### end classify_mouse_locs logic
    
if opts['ground_anchors'] is not None and eval(opts['burrowz']) is not None:
    print >> sys.stderr, 'calculating burrowing activity over segments'


    ###################
    # added 20091030
    # switches cumulative activity calc to activity below an artificial "lowest ground" - should fix squirrely groundfinding

    allgrounds = numpy.array([numpy.fromfile(f,sep='\n') for f in glob(outroot+'/*.ground')])
    low_ground = numpy.array([max(col) for col in allgrounds.transpose()])

    #for now, force_all is set manually; might migrate to opts eventually
    activity,termini,progress = vidtools.calculate_cumulative_activity(outroot,float(burrowz),shape=SHAPE,be=eval(opts['burrow_entrance_xy']), \
                                                                       suppress_ground=5,force_all=False,use_ground=low_ground)

    # end 20091030 addition
    ###################


#Goal for final analysis movie: split into segments in order to control files-per-directory
if opts['vid_format'] != 'None':
    movie = os.path.join(outroot,'%s%s_%szmouse_%szburrow_%spixav_%stimeav_%sbit' % (seglen,unit,mousez,burrowz,pixav,timeav,opts['vid_bitrate']))
if opts['vid_format'] != 'None' and not os.path.exists('%s.%s' % (movie,opts['vid_format'])):

    interval = 1

    print >> sys.stderr, 'render analysis-markup video as %s' % movie
    
    print >> sys.stderr, 'get source image count ...',
Example #3
0
print >> sys.stderr, 'compute activity matrices from frame averages (%s frame averages found)' % len(
    frameavs)
for i, f in enumerate(frameavs):
    actmatf = os.path.splitext(f)[0] + '.actmat'
    if not os.path.exists(actmatf) and i > 0 and i < len(frameavs) - 1:
        actmat = Util.zscore(
            numpy.fromfile(frameavs[i - 1]).reshape(shape) -
            numpy.fromfile(frameavs[i + 1]).reshape(shape))
        actmat.tofile(actmatf)

# switches cumulative activity calc to activity below an artificial "lowest ground" - should fix squirrely groundfinding

allgrounds = numpy.array(
    [numpy.fromfile(f, sep='\n') for f in glob(prev_adir + '/*.ground')])
low_ground = numpy.array([max(col) for col in allgrounds.transpose()])

#zburrow = 3
#for now, force_all is set manually; might migrate to opts eventually
activity, termini, progress = vidtools.calculate_cumulative_activity(
    new_outroot,
    float(zburrow),
    shape=shape,
    be=None,
    suppress_ground=5,
    force_all=False,
    use_ground=low_ground)

viz_vidtools.draw_reanalysis_activity_summary(new_outroot,
                                              prev_adir,
                                              outformat='pdf')
if opts["ground_anchors"] is not None and eval(opts["burrowz"]) is not None:
    print >>sys.stderr, "calculating burrowing activity over segments"

    ###################
    # added 20091030
    # switches cumulative activity calc to activity below an artificial "lowest ground" - should fix squirrely groundfinding

    allgrounds = numpy.array([numpy.fromfile(f, sep="\n") for f in glob(outroot + "/*.ground")])
    low_ground = numpy.array([max(col) for col in allgrounds.transpose()])

    # for now, force_all is set manually; might migrate to opts eventually
    activity, termini, progress = vidtools.calculate_cumulative_activity(
        outroot,
        float(burrowz),
        shape=SHAPE,
        be=eval(opts["burrow_entrance_xy"]),
        suppress_ground=5,
        force_all=False,
        use_ground=low_ground,
    )

    # end 20091030 addition
    ###################


# Goal for final analysis movie: split into segments in order to control files-per-directory
if opts["vid_format"] != "None":
    movie = os.path.join(
        outroot,
        "%s%s_%szmouse_%szburrow_%spixav_%stimeav_%sbit"
        % (seglen, unit, mousez, burrowz, pixav, timeav, opts["vid_bitrate"]),