def test_track_roi_intersection_check(): roi = np.array([[0, 0, 0], [1, 0, 0], [2, 0, 0]], dtype='f4') t = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 2]], dtype='f4') assert_equal(pf.track_roi_intersection_check(t, roi, 1), True) t = np.array([[0, 0, 0], [1, 0, 0], [2, 2, 2]], dtype='f4') assert_equal(pf.track_roi_intersection_check(t, roi, 1), True) t = np.array([[1, 1, 0], [1, 0, 0], [1, -1, 0]], dtype='f4') assert_equal(pf.track_roi_intersection_check(t, roi, 1), True) t = np.array([[4, 0, 0], [4, 1, 1], [4, 2, 0]], dtype='f4') assert_equal(pf.track_roi_intersection_check(t, roi, 1), False)
def test_track_roi_intersection_check(): roi=np.array([[0,0,0],[1,0,0],[2,0,0]],dtype='f4') t=np.array([[0,0,0],[1,1,1],[2,2,2]],dtype='f4') assert_equal( pf.track_roi_intersection_check(t,roi,1), True) t=np.array([[0,0,0],[1,0,0],[2,2,2]],dtype='f4') assert_equal(pf.track_roi_intersection_check(t,roi,1), True) t=np.array([[1,1,0],[1,0,0],[1,-1,0]],dtype='f4') assert_equal( pf.track_roi_intersection_check(t,roi,1), True) t=np.array([[4,0,0],[4,1,1],[4,2,0]],dtype='f4') assert_equal(pf.track_roi_intersection_check(t,roi,1), False)
def spherical_rois(fdpy,fsr,sq_radius=4): R=atlantic_points() dpr=Dpy(fdpy,'r') T=dpr.read_tracks() dpr.close() center=R['BCC'] refimg=nib.load(fref) aff=refimg.get_affine() SR={} for key in R: center=R[key] #back to world space centerw=np.dot(aff,np.array(center+(1,)))[:3] centerw.shape=(1,)+centerw.shape centerw=centerw.astype(np.float32) res= [track_roi_intersection_check(t,centerw,sq_radius) for t in T] res= np.array(res,dtype=np.int) ind=np.where(res>0)[0] SR[key]={} SR[key]['center']=center SR[key]['centerw']=tuple(np.squeeze(centerw)) SR[key]['radiusw']=np.sqrt(sq_radius) SR[key]['indices']=ind save_pickle(fsr,SR)
def roi_intersection(fdpy,fatlas,roi_no,froidpy): dpr=Dpy(fdpy,'r') T=dpr.read_tracksi(range(10000)) dpr.close() Troi=[] wI=get_roi(fatlas,roi_no,0) for (i,t) in enumerate(T): if i%1000==0: print i if track_roi_intersection_check(t,wI,.5): Troi.append(t) print(len(Troi)) dpw=Dpy(froidpy,'w') dpw.write_tracks(Troi) dpw.close() '''
def compute_intersecting(voxel, R, kdt, max_segment): """ function for finding the streamlines which are inside the specific redius for each ROI """ subset = np.unique(si[kdt.query_radius(voxel, r=R+max_segment)[0]]).astype(np.int) return subset[np.array([track_roi_intersection_check(s, voxel, sq_dist_thr=R**2) for s in tracks[subset]])]