x1 = np.zeros((NumTri)) y1 = np.zeros((NumTri)) v2_v1temp = V2 - V1 x2 = np.linalg.norm(v2_v1temp, axis=1) y2 = np.zeros((NumTri)) x3 = np.einsum('ij,ij->i', (V3 - V1), (v2_v1temp / np.column_stack( (x2, x2, x2)))) mynorm = np.cross((v2_v1temp), V3 - V1, axis=1) yunit = np.cross(mynorm, v2_v1temp, axis=1) y3 = np.einsum('ij,ij->i', yunit, (V3 - V1)) / np.linalg.norm(yunit, axis=1) sqrt_DT = (np.abs((x1 * y2 - y1 * x2) + (x2 * y3 - y2 * x3) + (x3 * y1 - y3 * x1))) Ar = 0.5 * (np.abs((x1 * y2 - y1 * x2) + (x2 * y3 - y2 * x3) + (x3 * y1 - y3 * x1))) TC = face_v_conn(surf1) Wt = (1.0 / 3.0) * (TC) # Wt = sp.sparse.spdiags(Wt*Ar, (0), NumTri, NumTri) surf_weight = Wt * Ar surf1.attributes = surf_weight surf_weight = surf_weight[:, None] # smooth_surf_function(dfs_left_sm, Wt*Ar*0.1, a1=0, a2=1) surf1.attributes = ind_rois surf1 = patch_color_attrib(surf1) view_patch_vtk(surf1, show=1) # sub = '110411' # p_dir = '/home/ajoshi/data/HCP_data' lst = os.listdir('/big_disk/ajoshi/HCP5') rho1 = 0
# skull = readdfs(skull_name) # skull = reducepatch(skull,.9,0) brain = add_normals(brain) # brain.normals=brain.vertices/5.0 skull = add_normals(skull) # view_patch(brain) # view_patch(skull) writedfs('brain.dfs', brain) writedfs('skull.dfs', skull) print "# vertices in Brain: " + str(brain.vertices.shape[0]) print "# vertices in Skull: " + str(skull.vertices.shape[0]) m = mean_curvature(brain) # m = smooth_surf_function(brain, m, 10, 100) br = view_patch(brain, attrib=m, opacity=1, show=0) view_patch(skull, opacity=.1, fig=br, show=1) Tri = face_v_conn(brain) Q = 1.0 + sp.zeros((brain.faces.shape[0], 1)) Q = (1.0 / 3.0) * Tri * Q Q = Q[:, 0] br_face_area = face_areas(brain) Q = 1.0 + sp.zeros(brain.vertices.shape[0]) # Q=0.0*Q # Q[1800]=1 # Q=smooth_surf_function(brain,Q,10,10) area_v = (1.0 / 3.0) * Tri * br_face_area v = sp.zeros(skull.vertices.shape[0]) # eq 8 from Sarvas v_aaj = sp.zeros(skull.vertices.shape[0]) # joshi view_patch(brain, attrib=Q, opacity=1) for i in range(skull.vertices.shape[0]): r0 = brain.vertices