Example #1
0
def batch_make_measurements(sourcepath, ext = '*.seq', label = 'curated'):
  """
  To update/remake a measurements table, delete the *.npy and *.measurements
  files in the `sourcepath`.
  """
  warnings.simplefilter("ignore")
  from glob import glob
  from ui.whiskerdata import load_trajectories
  from trace import Load_Whiskers
  import summary
  warnings.simplefilter("default")

  def get_summary_data( filename, whiskers, trajectories ):
    if os.path.exists(filename):
      data = numpy.load(filename)
    else:
      data = array(list( summary.features(whiskers) ))
      numpy.save( filename, data )
      return data
    return summary.commit_traj_to_data_table( trajectories, data )

  for name in glob( os.path.join( sourcepath, ext ) ):
    root,ext = os.path.splitext( name )
    prefix = root + '[%s]'%label
    if not os.path.exists( prefix + '.measurements' ):
      t,tid = load_trajectories( prefix + '.trajectories' )
      print prefix
      print t.keys()
      w = Load_Whiskers( prefix + '.whiskers' ) 
      data = get_summary_data( prefix + '.npy', w, t )
      MeasurementsTable( data ).update_velocities().save( prefix + '.measurements' )
Example #2
0
def load():
    from ui.whiskerdata import load_whiskers, load_trajectories
    from ui.genetiff import Reader
    movie = Reader('../../data/seq/whisker_data_0140.seq', adjuststipple=1)
    w, wid = load_whiskers('seq-heal.whiskers')
    t, tid = load_trajectories('seq-heal.trajectories')
    #w,wid = load_whiskers('whisk-vc/whisk-vc/seq.whiskers')
    #movie = Reader('../../data/JF8410_041808_001.tif',adjuststipple=1)
    #w,wid = load_whiskers('test.whiskers')
    #w,wid = load_whiskers('results/seq-hand.whiskers')
    #t,tid = load_trajectories('results/seq-hand.trajectories')
    return w, t, movie
Example #3
0
def load():
    from ui.whiskerdata import load_whiskers, load_trajectories
    from ui.genetiff import Reader

    movie = Reader("../../data/seq/whisker_data_0140.seq", adjuststipple=1)
    w, wid = load_whiskers("seq-heal.whiskers")
    t, tid = load_trajectories("seq-heal.trajectories")
    # w,wid = load_whiskers('whisk-vc/whisk-vc/seq.whiskers')
    # movie = Reader('../../data/JF8410_041808_001.tif',adjuststipple=1)
    # w,wid = load_whiskers('test.whiskers')
    # w,wid = load_whiskers('results/seq-hand.whiskers')
    # t,tid = load_trajectories('results/seq-hand.trajectories')
    return w, t, movie
Example #4
0
      raise IOError, "Could not find destination path %s"%os.path.split(dst)[0]
  if not all( map( os.path.exists, args )):
    raise IOError, "Could not find one or more input source files."


  if all(map( lambda f: os.path.splitext(f)[-1] in ['.trajectories','.whiskers'], args )):
    if len(args)==1:
      src = args[0]
      tfile = None
    else:
      src = args[1]   #know the order b.c. already sorted by file extenstion
      tfile = args[0]
    w = trace.Load_Whiskers( src )
    data = numpy.array(list( summary.features(w, options.face) ))
    if tfile:
      t,tid = load_trajectories( tfile )
      summary.commit_traj_to_data_table( t, data ) 
    
  elif all(map( lambda f: os.path.splitext(f)[-1] in ['.trajectories','.measurements'], args )):  
    sources = dict( map( lambda f: (os.path.splitext(f)[-1], f), args ) )

    
    try:
      data = traj.MeasurementsTable( sources['.measurements'] ).asarray()
    except KeyError:
      raise UserException, "A .measurements file must be provided as one of the source files."

    try:
      t,tid = load_trajectories( sources['.trajectories'] )
      summary.commit_traj_to_data_table( t, data ) 
    except KeyError:
Example #5
0
    if all(
            map(
                lambda f: os.path.splitext(f)[-1] in
                ['.trajectories', '.whiskers'], args)):
        if len(args) == 1:
            src = args[0]
            tfile = None
        else:
            src = args[
                1]  #know the order b.c. already sorted by file extenstion
            tfile = args[0]
        w = trace.Load_Whiskers(src)
        data = numpy.array(list(summary.features(w, options.face)))
        if tfile:
            t, tid = load_trajectories(tfile)
            summary.commit_traj_to_data_table(t, data)

    elif all(
            map(
                lambda f: os.path.splitext(f)[-1] in
                ['.trajectories', '.measurements'], args)):
        sources = dict(map(lambda f: (os.path.splitext(f)[-1], f), args))

        try:
            data = traj.MeasurementsTable(sources['.measurements']).asarray()
        except KeyError:
            raise UserException, "A .measurements file must be provided as one of the source files."

        try:
            t, tid = load_trajectories(sources['.trajectories'])