Exemplo n.º 1
0
def save_id_tract_plus_sff(tracks_filename, id_file, num_proto, distance, out_fname):
   
    if (tracks_filename[-3:]=='dpy'):
        dpr_tracks = Dpy(tracks_filename, 'r')
        all_tracks=dpr_tracks.read_tracks()
        dpr_tracks.close()
    else:
        all_tracks = load_whole_tract_trk(tracks_filename)
    
    tracks_id = load_pickle(id_file)
    	
    tract = [all_tracks[i] for i  in tracks_id]    
    
    not_tract_fil = []
    id_not_tract_fil = []
    min_len = min(len(i) for i in tract)
    #print 'min_len of cst', min_len
    min_len = min_len*2.2/3#2./3.2# - 20
    for i in np.arange(len(all_tracks)):
        if (i not in tracks_id) and (length(all_tracks[i]) > min_len):
            not_tract_fil.append(all_tracks[i])
            id_not_tract_fil.append(i)
    
    not_tract_fil = np.array(not_tract_fil,dtype=np.object)        
    sff_pro_id = sff(not_tract_fil, num_proto, distance)        
    
    tract_sff_id = []
    for i in tracks_id:
        tract_sff_id.append(i)
        
    for idx in sff_pro_id:        
        tract_sff_id.append(id_not_tract_fil[idx])
        
    #tract_sff_id.append(id_not_tract_fil[i] for i in sff_pro_id)
    print len(tract), len(tract_sff_id)
    save_pickle(out_fname, tract_sff_id)
    return tract_sff_id
Exemplo n.º 2
0
def save_id_tract_plus_sff_in_ext(tracks_filename, id_file, num_proto, distance,  out_fname_ext , out_fname_sff_in_ext, thres_len= 2.2/3., thres_vol = 1.4 , thres_dis = 3./2.):
    
    
    tract_ext_id = save_id_tract_ext1(tracks_filename,id_file, distance, out_fname_ext, thres_len, thres_vol , thres_dis)
    
    if (tracks_filename[-3:]=='dpy'):
        dpr_tracks = Dpy(tracks_filename, 'r')
        all_tracks=dpr_tracks.read_tracks()
        dpr_tracks.close()
    else:
        all_tracks = load_whole_tract_trk(tracks_filename)
    
    tracks_id = load_pickle(id_file)
    	
    ext_not_tract_id = []
    ext_not_tract = []
    for idx in tract_ext_id:
        if idx not in tracks_id:
            ext_not_tract.append(all_tracks[idx])
            ext_not_tract_id.append(idx)
        
          
    ext_not_tract = np.array(ext_not_tract,dtype=np.object)        
    sff_pro_id = sff(ext_not_tract, num_proto, distance)        
    
    tract_sff_in_ext_id = []
    for i in tracks_id:
        tract_sff_in_ext_id.append(i)
        
    for k in sff_pro_id:        
        tract_sff_in_ext_id.append(ext_not_tract_id[k])
        
    #tract_sff_id.append(id_not_tract_fil[i] for i in sff_pro_id)
    print len(tracks_id), len(tract_sff_in_ext_id), len(tract_ext_id)
    save_pickle( out_fname_sff_in_ext, tract_sff_in_ext_id)
    return tract_sff_in_ext_id