Esempio n. 1
0
def show_tracks(tracks,alpha=1.,lw=2.,bg=(1.,1.,1.,1)): 
    
    colors=compute_colors(tracks,alpha=alpha)
    ax = Line(tracks,colors,line_width=lw)
    w=World()
    w.add(ax)
    wi = Window(caption=" Curve plotting (fos.me)",\
            bgcolor=bg,width=1200,height=1000)
    #(0,0.,0.2,1)
    wi.attach(w)
    wm = WindowManager()
    wm.add(wi)
    wm.run()
Esempio n. 2
0
def load_tracks(method="pmt"):
    from nibabel import trackvis as tv

    dname = "/home/eg309/Data/orbital_phantoms/dwi_dir/subject1/"

    if method == "pmt":
        fname = "/home/eg309/Data/orbital_phantoms/dwi_dir/workflow/tractography/_subject_id_subject1/cam2trk_pico_twoten/data_fit_pdfs_tracked.trk"
        streams, hdr = tv.read(fname, points_space="voxel")
        tracks = [s[0] for s in streams]
    if method == "dti":
        fname = dname + "dti_tracks.dpy"
    if method == "dsi":
        fname = dname + "dsi_tracks.dpy"
    if method == "gqs":
        fname = dname + "gqi_tracks.dpy"
    if method == "eit":
        fname = dname + "eit_tracks.dpy"
    if method in ["dti", "dsi", "gqs", "eit"]:
        dpr_linear = Dpy(fname, "r")
        tracks = dpr_linear.read_tracks()
        dpr_linear.close()

    if method != "pmt":
        tracks = [t - np.array([96 / 2.0, 96 / 2.0, 55 / 2.0]) for t in tracks if track_range(t, 100 / 2.5, 150 / 2.5)]
    tracks = [t for t in tracks if track_range(t, 100 / 2.5, 150 / 2.5)]

    print "final no of tracks ", len(tracks)
    qb = QuickBundles(tracks, 25.0 / 2.5, 18)
    # from dipy.viz import fvtk
    # r=fvtk.ren()
    # fvtk.add(r,fvtk.line(qb.virtuals(),fvtk.red))
    # fvtk.show(r)
    # show_tracks(tracks)#qb.exemplars()[0])
    # qb.remove_small_clusters(40)
    del tracks
    # load
    tl = TrackLabeler(qb, qb.downsampled_tracks(), vol_shape=None, tracks_line_width=3.0, tracks_alpha=1)

    # return tracks
    w = World()
    w.add(tl)
    # create window
    wi = Window(caption="Fos", bgcolor=(1.0, 1.0, 1.0, 1.0), width=1600, height=900)
    wi.attach(w)
    # create window manager
    wm = WindowManager()
    wm.add(wi)
    wm.run()
Esempio n. 3
0
def load_PX_tracks():

    roi = "LH_premotor"

    dn = "/home/hadron/from_John_mon12thmarch"
    dname = "/extra_probtrackX_analyses/_subject_id_subj05_101_32/particle2trackvis_" + roi + "_native/"
    fname = dn + dname + "tract_samples.trk"
    from nibabel import trackvis as tv

    points_space = [None, "voxel", "rasmm"]
    streamlines, hdr = tv.read(fname, as_generator=True, points_space="voxel")
    tracks = [s[0] for s in streamlines]
    del streamlines
    # return tracks

    qb = QuickBundles(tracks, 25.0 / 2.5, 18)
    # tl=Line(qb.exemplars()[0],line_width=1)
    del tracks
    qb.remove_small_clusters(20)

    tl = TrackLabeler(qb, qb.downsampled_tracks(), vol_shape=None, tracks_line_width=3.0, tracks_alpha=1)

    # put the seeds together
    # seeds=np.vstack((seeds,seeds2))
    # shif the seeds
    # seeds=np.dot(mat[:3,:3],seeds.T).T + mat[:3,3]
    # seeds=seeds-shift
    # seeds2=np.dot(mat[:3,:3],seeds2.T).T + mat[:3,3]
    # seeds2=seeds2-shift
    # msk = Point(seeds,colors=(1,0,0,1.),pointsize=2.)
    # msk2 = Point(seeds2,colors=(1,0,.ppppp2,1.),pointsize=2.)
    w = World()
    w.add(tl)
    # w.add(msk)
    # w.add(msk2)
    # w.add(sl)
    # create window
    wi = Window(caption="Fos", bgcolor=(0.3, 0.3, 0.6, 1.0), width=1600, height=900)
    wi.attach(w)
    # create window manager
    wm = WindowManager()
    wm.add(wi)
    wm.run()
Esempio n. 4
0
	

if __name__ == '__main__':    
	
    tracks=[100*np.random.rand(100,3),100*np.random.rand(20,3)]
    colors=np.ones((120,4))
    colors[0:100,:3]=np.array([1,0,0.])
    colors[100:120,:3]=np.array([0,1,0])

    import nibabel as nib
    from os import path as op
    a=nib.trackvis.read( op.join(op.dirname(fos.__file__), "data", "tracks300.trk") )
    g=np.array(a[0], dtype=np.object)
    tracks = [tr[0] for tr in a[0]]
    #tracks = tracks-np.concatenate(tracks,axis=0)
    lentra = [len(t) for t in tracks]
    colors = np.ones((np.sum(lentra),4))
    #colors[:,3]=0.9

    ax = Line(tracks,colors,line_width=2)

    w=World()
    w.add(ax)        
    wi = Window(caption=" Line plotting (fos.me)",\
            bgcolor=(0,0.,0.2,1),width=800,height=600)
    wi.attach(w)    	
    wm = WindowManager()
    wm.add(wi)
    wm.run()
    
Esempio n. 5
0
except pyglet.window.NoSuchConfigException:
    # Fall back to no multisampling for old hardware
    window = Window(resizable=True, caption = mycpt)

# sample tree data
# ####
vert = np.array( [ [0,0,0],
                   [5,5,0],
                   [5,10,0],
                   [10,5,0]], dtype = np.float32 )

conn = np.array( [ 0, 1, 1, 2, 1, 3 ], dtype = np.uint32 )

cols = np.array( [ [0, 0, 1, 1],
                   [1, 0, 1, 1],
                   [0, 0, 1, 0.5] ] , dtype = np.float32 )

vert_width = np.array( [1, 5, 5, 1, 5, 1], dtype = np.float32 )

ax = Axes()
act = TreeRegion(vertices = vert, connectivity = conn, colors = cols, radius = vert_width)

w = World()
w.add(ax)
w.add(act)

window.attach(w)

wm = WindowManager()
wm.add(window)
wm.run()
Esempio n. 6
0
File: world.py Progetto: arokem/Fos
""" Create an empty Fos world and attach a window to it """

from fos import World, Window, DefaultCamera, WindowManager

# create the first window
wi = Window(caption = "My Window 1", bgcolor = (1,1,1,1) )

# return the default empty world of this window
w = World()

# add a new camera to this world
cam2 = DefaultCamera()
w.add(cam2)

# create the second window
wi2 = Window(caption = "My Window 2", bgcolor = (0,0,0,1) )

# we want to look at the same world as window 1, thus drop
# the default world and attach the window to our world with the second camera
wi2.attach(w)

# set the camera for the second window to the second camera
wi2.set_current_camera(cam2)

# Create the window manager, add the windows, and go!
wm = WindowManager()
wm.add(wi)
wm.add(wi2)
wm.run()
Esempio n. 7
0
            'Hi',
            font_name='Times New Roman',
            font_size=26,
            dpi=100,
            #                                  x=window.width//2, y=window.height//2,
            anchor_x='center',
            anchor_y='center',
            batch=self.batch)

    def update(self, dt):
        pass

    def draw(self):
        pass
        glPushMatrix()
        #glRotatef(5.0, 0, 1, 0)
        glTranslatef(-100, 0, 0)
        self.batch.draw()
        glPopMatrix()


if __name__ == '__main__':
    wi = Window()
    w = wi.get_world()
    act = Dummy()
    w.add(act)

    wm = WindowManager()
    wm.add(wi)
    wm.run()
Esempio n. 8
0
                    caption=mycpt)  # "vsync=False" to check the framerate
except pyglet.window.NoSuchConfigException:
    # Fall back to no multisampling for old hardware
    window = Window(resizable=True, caption=mycpt)

# sample tree data
# ####
vert = np.array([[0, 0, 0], [5, 5, 0], [5, 10, 0], [10, 5, 0]],
                dtype=np.float32)

conn = np.array([0, 1, 1, 2, 1, 3], dtype=np.uint32)

cols = np.array([[0, 0, 1, 1], [1, 0, 1, 1], [0, 0, 1, 0.5]], dtype=np.float32)

vert_width = np.array([1, 5, 5, 1, 5, 1], dtype=np.float32)

ax = Axes()
act = TreeRegion(vertices=vert,
                 connectivity=conn,
                 colors=cols,
                 radius=vert_width)

w = World()
w.add(ax)
w.add(act)

window.attach(w)

wm = WindowManager()
wm.add(window)
wm.run()
Esempio n. 9
0
""" Create an empty Fos world and attach a window to it """

from fos import World, Window, DefaultCamera, WindowManager

# create the first window
wi = Window(caption="My Window 1", bgcolor=(1, 1, 1, 1))

# return the default empty world of this window
w = wi.get_world()

# add a new camera to this world
cam2 = DefaultCamera()
w.add(cam2)

# create the second window
wi2 = Window(caption="My Window 2", bgcolor=(0, 0, 0, 1))

# we want to look at the same world as window 1, thus drop
# the default world and attach the window to our world with the second camera
wi2.attach(w)

# set the camera for the second window to the second camera
wi2.set_current_camera(cam2)

# Create the window manager, add the windows, and go!
wm = WindowManager()
wm.add(wi)
wm.add(wi2)
wm.run()