def surf_lab_match_bci_uscbrain(uscbrain, uscbrain_dict, bci, bci_dict, error_ind): uscbrain_new = copy.deepcopy(uscbrain) class from_surf: pass class to_surf: pass for bci_lab in bci_dict: lab_ind = (bci.labels == bci_lab) error_ind = np.array(error_ind, dtype=bool) to_ind = lab_ind & error_ind from_ind = lab_ind & (~error_ind) from_surf.vertices = uscbrain.vertices[from_ind, :] to_surf.vertices = uscbrain.vertices[to_ind, :] from_surf.labels = uscbrain.labels[from_ind] to_surf = interpolate_labels(from_surf, to_surf) uscbrain_new.labels[to_ind] = to_surf.labels return uscbrain_new
pass t.vertices = sp.concatenate((Xc[:, None], Yc[:, None], Zc[:, None]), axis=1) f.vertices = sp.concatenate((left_mid.vertices, right_mid.vertices, left_inner.vertices, right_inner.vertices, left_pial.vertices, right_pial.vertices, l1_vert, r1_vert, l2_vert, r2_vert)) f.labels = sp.concatenate((left_mod.attributes, right_mod.attributes, left_mod.attributes, right_mod.attributes, left_mod.attributes, right_mod.attributes, left_mod.attributes, right_mod.attributes, left_mod.attributes, right_mod.attributes)) t = interpolate_labels(fromsurf=f, tosurf=t) # %% here make sure that hanns labels are not modified TBD vol_attrib[ind] = t.labels vol = image.load_img('/big_disk/ajoshi/coding_ground/hybridatlas/\ BCI-DNI_brain_atlas_refined_4_18_2017/BCI-DNI_brain.bfc.nii.gz') prob_img = image.new_img_like(vol, vol_attrib) prob_img.to_filename('/big_disk/ajoshi/coding_ground/hybridatlas/hBCI_DNI_fsl/\ BCI-DNI_brain-prob.nii.gz') msk = image.threshold_img(prob_img, threshold=.5) lab = image.load_img('/big_disk/ajoshi/coding_ground/hybridatlas/hBCI_DNI_fsl/\ BCI-DNI_brain.label.nii.gz') lab1 = image.new_img_like(lab, lab.get_data() * (prob_img.get_data() > 0))
freq1 = data1['freq'].squeeze() freq1 = freq1 / nSub freq1[labs == 0] = 0 # bci_labs = reduce3_to_bci_lh(labs) # freq1 = reduce3_to_bci_lh(freq1) bci_labs = labs.squeeze().copy() bci_labs_orig = bci_labs.copy() if sp.amax(bci_labs) > 0: bci_labs[bci_bst.labels != roino * 10] = 0 indt = (bci_bst.labels == roino * 10) & (bci_labs == 0) ts.vertices = bci_bst.vertices[indt, :] ind = (bci_bst.labels == roino * 10) & (bci_labs != 0) fs.vertices = bci_bst.vertices[ind, :] fs.labels = bci_labs[ind] ts = interpolate_labels(fs, ts) bci_labs[indt] = ts.labels freq1[(bci_labs > 0) & (freq1 == 0)] = \ sp.amin(freq1[(bci_labs_orig > 0) & (freq1 != 0)]) freq[(bci_bst.labels == roino * 10)] += freq1[(bci_bst.labels == roino * 10)] bci_bst.labels += sp.uint16(bci_labs) freq[freq == 0] = 1 bci_bst.attributes = freq bci_bst = patch_color_labels(bci_bst, freq=freq, cmap='Paired') # bci_bst = smooth_patch(bci_bst, iterations=90, relaxation=10.8) view_patch_vtk(bci_bst, show=1) ####writedfs('/home/ajoshi/data/BCI-DNI_brain_atlas/BCI-DNI_brain.left.\
freq1 = data1['freq'].squeeze() freq1 = freq1 / nSub freq1[labs == 0] = 0 # bci_labs = reduce3_to_bci_rh(labs) # freq1 = reduce3_to_bci_rh(freq1) bci_labs = labs.squeeze().copy() bci_labs_orig = bci_labs.copy() if sp.amax(bci_labs) > 0: bci_labs[bci_bst.labels != roino * 10] = 0 indt = (bci_bst.labels == roino * 10) & (bci_labs == 0) ts.vertices = bci_bst.vertices[indt, :] ind = (bci_bst.labels == roino * 10) & (bci_labs != 0) fs.vertices = bci_bst.vertices[ind, :] fs.labels = bci_labs[ind] ts = interpolate_labels(fs, ts) bci_labs[indt] = ts.labels freq1[(bci_labs > 0) & (freq1 == 0)] = \ sp.amin(freq1[(bci_labs_orig > 0) & (freq1 != 0)]) freq[(bci_bst.labels == roino * 10)] += freq1[(bci_bst.labels == roino * 10)] bci_bst.labels += sp.uint16(bci_labs) freq[freq == 0] = 1 bci_bst.attributes = freq bci_bst = patch_color_labels(bci_bst, cmap='Paired') # bci_bst = smooth_patch(bci_bst, iterations=90, relaxation=10.8) view_patch_vtk(bci_bst, show=1) ####writedfs('/home/ajoshi/data/BCI-DNI_brain_atlas/BCI-DNI_brain.right.\