コード例 #1
0
if not os.path.isdir(track_outdir):
    os.mkdir(track_outdir)
if not os.path.isfile(track_file):
    deterministic(diffusion_file,
                  bvecs_file,
                  bvals_file,
                  track_outdir,
                  mask_file=mask_file,
                  order=4,
                  nb_seeds_per_voxel=nb_seeds_per_voxel,
                  step=0.5,
                  fmt="%.4f")

if use_vtk:
    tracks = loadtxt(track_file)
    actor = pvtk.line(tracks, scalar=1)
    pvtk.add(ren, actor)
    pvtk.record(ren, qcdir, "fibers", az_ang=45, n_frames=2)
    pvtk.clear(ren)

connect_outdir = os.path.join(outdir, "det_region_connectivity")
if not os.path.isdir(connect_outdir):
    os.mkdir(connect_outdir)
if len(os.listdir(connect_outdir)) == 0:
    if use_t1_space:
        proba_file, network_file = anatomical_connectivity_matrix(
            track_file,
            label_file,
            t1_file,
            fa_file,
            trf_file,
コード例 #2
0
          np.array([[0,0.2,0],[1,0.2,0],[2,0.2,0]], dtype=np.single),
          np.array([[2,0.2,0],[1,0.2,0],[0,0.2,0]], dtype=np.single),
          np.array([[0,0,0],[0,1,0],[0,2,0]], dtype=np.single)]


if key == 0:
    clusters = agglomerative_clustering(
        tracks, "single", cutoff=0.5, nb_samples=10, nb_cpu=1,
        preserve_input=False)
    ren = pvtk.ren()
    nb_of_clusters = len(clusters)
    for cluster_id, tracks_index in clusters.iteritems():
        fibers = []
        for index in tracks_index:
            fibers.append(tracks[index])
        actor = pvtk.line(fibers, float(cluster_id) / nb_of_clusters)
        pvtk.add(ren, actor)
    pvtk.show(ren)

elif key==1:
    tracks *= 1000
    print len(tracks)
    print clustering_metric_resample(np.asarray(tracks), nb_of_threads=24)
    print clustering_metric(tracks, nb_of_threads=24, zhang_thr=0.,
                            distance_metric="max")
    
elif key==2:
    tracks *= 30
    clusters = local_skeleton_clustering(tracks, cutoff=0.7, nb_samples=10,
                                         nb_of_threads=1)
    print clusters
コード例 #3
0
    for cnt, cluster in enumerate(clusters_):
        clusters[str(cnt)] = {"indices": cluster.indices}
    with open(cluster_file, "w") as open_file:
        json.dump(clusters, open_file, indent=4)
else:
    with open(cluster_file) as open_file:
        clusters = json.load(open_file)

if 1: #use_vtk:
    ren = pvtk.ren()
    colors = numpy.ones((len(fibers),))
    nb_clusters = len(clusters)
    for clusterid, item in clusters.items():
        indices = item["indices"]
        colors[indices] = numpy.random.rand()
    actor = pvtk.line(fibers, colors.tolist())
    actor.RotateX(actor_ang[0])
    actor.RotateY(actor_ang[1])
    actor.RotateZ(actor_ang[2])
    pvtk.add(ren, actor)
    ren.SetBackground(1, 1, 1)
    #pvtk.record(ren, qcdir, "clusters", az_ang=45, n_frames=2)
    pvtk.record(ren, qcdir, "clusters", n_frames=36, az_ang=10, animate=True,
                delay=25)
    pvtk.show(ren)
    pvtk.clear(ren)
    print(stop)


"""
Bundle statistic
コード例 #4
0
    os.mkdir(track_outdir)
if not os.path.isfile(track_file):
    deterministic(
        diffusion_file,
        bvecs_file,
        bvals_file,
        track_outdir,
        mask_file=mask_file,
        order=4,
        nb_seeds_per_voxel=nb_seeds_per_voxel,
        step=0.5,
        fmt="%.4f")

if use_vtk:
    tracks = loadtxt(track_file)
    actor = pvtk.line(tracks, scalar=1)
    pvtk.add(ren, actor)
    pvtk.record(ren, qcdir, "fibers", az_ang=45, n_frames=2)
    pvtk.clear(ren)
    

connect_outdir = os.path.join(outdir, "det_region_connectivity")
if not os.path.isdir(connect_outdir):
    os.mkdir(connect_outdir)
if len(os.listdir(connect_outdir)) == 0:
    if use_t1_space:
        proba_file, network_file = anatomical_connectivity_matrix(
            track_file,
            label_file,
            t1_file,
            fa_file,