def show(): #brains=[(1,1),(1,2),(2,1),(3,1),(3,2)] brains=[(1,1),(2,1),(3,1)] ids=tl.emi_atlas() #print ids.keys() for (b,s) in brains: ids2 = pbc.load_pickle(path+'/Relabelling_8_sc1_'+str(b)+'_'+str(s)+'.pkl') #'/Relabelling_8_sc1_'+str(b)+'_'+str(s)+'.pkl' print b,s, ids2.keys() tracks = pbc.load_approximate_tracks(path,b,s) for i in ids: if i >0: r=fos.ren() color=np.array(ids[i]['color']) indices=ids2[i]['indices'] bundle=[tracks[ind] for ind in indices] fos.add(r,fos.line(bundle,color,opacity=0.9)) print 'Bundle_name',i,ids[i]['bundle_name'] fos.show(r,title=ids[i]['bundle_name'][0])
def load_template_tes_and_tracks(path,brain,scan): volpath=path+'/ICBM_WMPM_tweaked_'+str(brain) +'_'+str(scan)+'.nii' print volpath template,voxsz,aff=pbc.loadvol(volpath) tracks=pbc.load_approximate_tracks(path,brain,scan) print 'template shape', template.shape tcs,tes = tv.track_counts(tracks, template.shape, vox_sizes=(1,1,1), return_elements=True) print 'tcs shape', tcs.shape return template,tcs,tes,tracks
import numpy as np import itertools from dipy.core import performance as pf from dipy.core import track_learning as tl from dipy.core import track_metrics as tm from dipy.viz import fos import pbc import cPickle import cProfile as profile import pstats path='/home/eg01/Data/PBC/pbc2009icdm' G,hdr,R=pbc.load_training_set(path) tracks=pbc.load_approximate_tracks(path,1,1) #tracks=[t for (i,t) in enumerate(tracks) if i%25==0] def test(bundle_list, divergence_threshold_list=[0.25], fibre_weight_list=[0.8],index_lists=False): comments = open('/home/ian/tractarian/commentary.txt','w') #reduced_hits = [] #for b in [1,2,3,4,5,6,7,8]: for b in bundle_list: #print 'Starting ...' refindex = G[b]['indices'].index([R[b]]) ref = G[b]['tracks'][refindex]