Пример #1
0
    def __init__(self, bgcolor=None, **kwargs):
        """ Create a FosWindow. All parameters are optional.

        Parameters
        ----------
        `bgcolor` : tuple
            Specify the background color as 4-tuple with values
            between 0 and 1
        `width` : int
            Width of the window, in pixels.  Defaults to 640, or the
            screen width if `fullscreen` is True.
        `height` : int
            Height of the window, in pixels.  Defaults to 480, or the
            screen height if `fullscreen` is True.
        `caption` : str or unicode
            Initial caption (title) of the window.  Defaults to
            ``sys.argv[0]``.
        `fullscreen` : bool
            If True, the window will cover the entire screen rather
            than floating.  Defaults to False.
        `visible` : bool
            Determines if the window is visible immediately after
            creation.  Defaults to True.  Set this to False if you
            would like to change attributes of the window before
            having it appear to the user.

        """

        
        self.update_dt = 1.0/60

        if bgcolor == None:
            self.bgcolor = color.black
        else:
            self.bgcolor = bgcolor

        self.mouse_x, self.mouse_y = 0,0

        # create an empty world by default
        emptyworld = World("Zero-Point World")
        self.attach(emptyworld)

        # the frame rate display from fos.lib.pyglet
        #self.fps_display = FPSDisplay(self)
        #self.foslabel = WindowText(self, 'fos', x=10 , y=40)
        self.show_logos = False

        # pushing new event handlers
        foswinhandlers = FosWinEventHandler(self)
        self.push_handlers(foswinhandlers)

        # log handler
#        self.push_handlers(WindowEventLogger())

        self.show_fps = True
        self.fps_display = ClockDisplay()

        super(SimpleWindow, self).__init__(**kwargs)
        print "init simple window"
Пример #2
0
def test_picking_trajectories():

    curves = [
        100 * np.random.rand(10, 3), 100 * np.random.rand(5, 3),
        100 * np.random.rand(3, 3)
    ]
    #curves=[100*np.array([[0,0,0],[1,0,0]]), 100*np.array([[0,1,0],[0,1,3]]),100*np.array([[0,2,0],[0,2,3]])]
    '''
    from nibabel import trackvis as tv
    #fname='/home/eg309/Data/PROC_MR10032/subj_01/101/1312211075232351192010091419011391228126452ep2dadvdiffDSI25x25x25b4000s003a001_FA_warp.trk'
    fname='/home/eg309/Data/fibers.trk'
    streams,hdr=tv.read(fname)
    T=[s[0] for s in streams]
    curves=T[:200000]
    
    fname='/home/eg309/Data/PROC_MR10032/subj_02/101/1312211075232351192010091708112071055601107ep2dadvdiffDSI10125x25x25STs002a001_QA_native.dpy'
    from dipy.io.dpy import Dpy
    dpr=Dpy(fname,'r')
    T=dpr.read_indexed(range(20000))
    
    from dipy.core.track_metrics import length
    curves=[t for t in T if length(t) > 20]
    
    dpr.close()
'''
    #colors=np.random.rand(len(curves),4).astype('f4')
    colors = 0.5 * np.ones((len(curves), 4)).astype('f4')
    for (i, c) in enumerate(curves):
        orient = c[0] - c[-1]
        orient = np.abs(orient / np.linalg.norm(orient))
        colors[i, :3] = orient

    c = InteractiveCurves(curves, colors=colors)
    w = World()
    w.add(c)
    wi = Window()
    wi.attach(w)
Пример #3
0
import scipy.ndimage as nd
import nibabel as ni
from fos.actor.volslicer import ConnectedSlices
from fos import World, Window

# your nifti volume
f1 = 'raw_t1_image.nii.gz'
img = ni.load(f1)

data = img.get_data()
affine = img.get_affine()

cds = ConnectedSlices(affine, data)

w = World()
w.add(cds)

wi = Window()
wi.attach(w)
Пример #4
0
import numpy as np

from fos import World, Window, WindowManager
from fos.actor.network import AttributeNetwork

w = World("myworld")

# node positions
s = 1000
pos = np.random.random((s, 3)).astype(np.float32) * 100
col = np.random.random_integers(0, 255, (s, 4)).astype(np.ubyte)
col[:, 3] = 255
print pos.shape
print col.shape

size = np.array([1.0, 10.0], dtype=np.float32)
size = np.random.random((s, 1)).astype(np.float32)
print size.shape

ss = 500
edg = np.array([[0, 1]], dtype=np.uint8)
edg_weight = np.array([1.5], dtype=np.float32)
edg_col = np.array([[255, 0, 0, 255]], dtype=np.ubyte)
print edg.shape
print edg_weight.shape
print edg_col.shape

edg = np.random.random_integers(0, s - 1, (ss, 2)).astype(np.uint32)
edg_weight = np.random.random((ss, 1)).astype(np.float32)

edg_col = np.random.random_integers(0, 255 - 1, (ss, 4)).astype(np.ubyte)