Example #1
0
 def __init__(self, track_file, label_file=None):
     """ Create a new tractogram.
     """
     self.tracks = loadtxt(track_file)
     if label_file is None:
         self.labels = [0, ] * self.shape()
     else:
         self.labels = {}
         with open(label_file) as open_file:
             clusters = json.load(open_file)
             for clusterid, clusteritem in clusters.items():
                 for trkindex in clusteritem["indices"]:
                     self.labels[trkindex] = clusterid    
     self.length = [None, ] * self.shape()
Example #2
0
 def __init__(self, track_file, label_file=None):
     """ Create a new tractogram.
     """
     self.tracks = loadtxt(track_file)
     if label_file is None:
         self.labels = [
             0,
         ] * self.shape()
     else:
         self.labels = {}
         with open(label_file) as open_file:
             clusters = json.load(open_file)
             for clusterid, clusteritem in clusters.items():
                 for trkindex in clusteritem["indices"]:
                     self.labels[trkindex] = clusterid
     self.length = [
         None,
     ] * self.shape()
Example #3
0
track_file = os.path.join(track_outdir, "fibers.txt")
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,
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,