def load_data(dmap):
    fn = 'fn'
    r = 'r'

    def get_pul(f):
        head = rh.BundleHeader(f)
        head.load(f)
        for bi in head.oBundleItems:
            if str(bi.oExtension)[0:4] == '.pul':
                pul = rh.PULFile(f,bi)
        return pul

    {114:[[0,15]]}
    {125:[[0,11],[0,15],[0,19],[0,23],[0,27],[0,31]]}

    #filepath = "/Volumes/BigGuy/CELLS/CEN%s/%s"%(str(key),datamap[cennum][p])

    for cennum in dmap.keys():
        filepath = basepath + "CEN%s/%s"%(str(cennum),dmap[cennum][fn])
        print filepath
        celldata = list()
        f = open(filepath,'rb')
        pul = get_pul(f)
        for route in datamap[cennum][r]:
            tree_obj = pul.tree['children'][route[1]]
            celldata.append(rh.getleafs(tree_obj,f)[0])
        f.close()
        dmap[cennum].update({'d':celldata})
        #datamap[cennum]['d'][0][::10].sub_baseline(0,30,tunits='s').plot(color = 'k', alpha = 0.3)
    return dmap
def load_cell(cennum):
    censtr = "%03d"%(cennum)
    filepath = basepath + "CEN%s/%s"%(str(censtr),datamap[censtr][fn])
    #print filepath
    f = open(filepath,'rb')
    pul = get_pul(f)
    celldata = list()
    for route in datamap[censtr][r]:
        #print(route)
        tree_obj = pul.tree['children'][route[1]]
        [celldata.append(l) for l in rh.getleafs(tree_obj,f)]
    f.close()
    return celldata