Example #1
0
    

if __name__ == '__main__':

    import nibabel as nib    
    
    dname = '/usr/share/fsl/data/standard/'
    fname = dname + 'FMRIB58_FA_1mm.nii.gz'

    fname = '/home/eg309/Data/trento_processed/subj_01/MPRAGE_32/rawbet.nii.gz'
    img=nib.load(fname)
    data = img.get_data()
    data = np.interp(data, [data.min(), data.max()], [0, 255])

    from fos import Init, Run

    Init()

    window = Window(caption="[F]OS", bgcolor=(0.4, 0.4, 0.9))
    scene = Scene(activate_aabb=False)
    guil = Guillotine('VolumeSlicer', data)
    scene.add_actor(guil)
    window.add_scene(scene)
    window.refocus_camera()

    #window = Window()
    window.show()
    #print get_ipython()

    Run()
Example #2
0
#        if modifiers & key.MOD_SHIFT:            
#            print 'Shift'

if __name__ == '__main__':

    import nibabel as nib    
    dname = '/usr/share/fsl/data/standard/'
    fname = dname + 'FMRIB58_FA_1mm.nii.gz'
    img=nib.load(fname)
    data = img.get_data()
    data = np.interp(data, [data.min(), data.max()], [0, 255])
    #data = np.ones((156, 122, 96), dtype=np.ubyte)
    #data = 255*data
    #data[70:100, 70:90, 70:80 ] = 140
    window = Window(caption="Interactive Slicer", 
                        bgcolor=(0.4, 0.4, 0.9))
    scene = Scene(activate_aabb=False)
    slicer = Slicer('VolumeSlicer', data)
    scene.add_actor(slicer)
    window.add_scene(scene)
    window.refocus_camera()
    
    #ax = Axes(name="3 axes", scale=200, linewidth=10.0)
    #scene.add_actor(ax)
    



    

Example #3
0
    import nibabel as nib
    from fos import Window, Scene, Init, Run

    #dname='/home/eg309/Data/trento_processed/subj_03/MPRAGE_32/'
    #fname = dname + 'T1_flirt_out.nii.gz'
    #dname = '/home/eg309/Data/111104/subj_05/'
    #fname = dname + '101_32/DTI/fa.nii.gz'
    dname = '/usr/share/fsl/data/standard/'
    fname = dname + 'FMRIB58_FA_1mm.nii.gz'
    #fname = '/home/eleftherios/Data/trento_processed/subj_01/MPRAGE_32/raw.nii'
    img = nib.load(fname)
    data = img.get_data()
    data[np.isnan(data)] = 0
    data = np.interp(data, [data.min(), data.max()], [0, 255])
    data = data.astype(np.ubyte)
    affine = img.get_affine()
    print data.shape

    Init()

    window = Window(caption='[F]OS', bgcolor=(0.1, 0.2, 0.6))
    scene = Scene(activate_aabb=False)

    sli = Slicer('Volume Slicer', data, affine, convention='RAS')

    scene.add_actor(sli)
    window.add_scene(scene)
    window.refocus_camera()

    Run()
Example #4
0
File: line.py Project: shdwdln/fos
    colors = np.random.rand(np.sum(lentra),4)
    #colors[:,3]=0.9
    """

    streamlines = Line('fornix',tracks,colors,line_width=2)
    from fos import Window, Scene
    from fos.actor.axes import Axes
    from fos.actor.text import Text3D

    title='Bundle Picker'
    w = Window(caption = title, 
                width = 1200, 
                height = 800, 
                bgcolor = (0.,0.,0.2) )
    scene = Scene( scenename = 'Main',
                        extent_min = np.array([-5.0, -5, -5]),
                        extent_max = np.array([5, 5 ,5]))
    
    ax = Axes(name = "3 axes", linewidth=2.0)

    vert = np.array( [[2.0,3.0,0.0]], dtype = np.float32 )
    ptr = np.array( [[.2,.2,.2]], dtype = np.float32 )
    tex = Text3D( "Text3D", vert, "Reg", 10, 2, ptr)

    scene.add_actor(ax)
    scene.add_actor(tex)
    scene.add_actor(streamlines)
    #w.screenshot( 'red.png' )
    w.add_scene(scene)
    w.refocus_camera()
Example #5
0
File: tex3d.py Project: tsiaras/fos
    
    #dname='/home/eg309/Data/trento_processed/subj_03/MPRAGE_32/'
    #fname = dname + 'T1_flirt_out.nii.gz'
    dname = '/usr/share/fsl/data/standard/'
    fname = dname + 'FMRIB58_FA_1mm.nii.gz'
    img=nib.load(fname)
    data = img.get_data()
    data = np.interp(data, [data.min(), data.max()], [0, 255])
    #affine = img.get_affine()  
    affine = None

    #volume = prepare_volume(data)
    i, j, k = data.shape[:3]
	
    window = Window(bgcolor=(0, 0, 0.6))
    scene = Scene()
    
    tex = Texture3D('Buzz', data, affine, type=GL_RGBA, interp=GL_LINEAR)

    #texcoords, vertcoords = tex.slice_i(i/2) 
    #texcoords, vertcoords = tex.slice_j(j/2) 
    texcoords, vertcoords = tex.slice_k(k/2 - 5) 

    tex.update_quad(texcoords, vertcoords)

    ax = Axes(name="3 axes", linewidth=2.0)
    vert = np.array([[2.0,3.0,0.0]], dtype = np.float32)
    ptr = np.array([[.2,.2,.2]], dtype = np.float32)
    #text = Text3D("Text3D", vert, "Reg", 20, 6, ptr)

    scene.add_actor(tex)
Example #6
0
    tl = TrackLabeler('Bundle Picker',
                        qb,qb.downsampled_tracks(),
                        vol_shape=(182, 218, 182),tracks_alpha=1)   
    #add a interactive slicing/masking tool
    #sl = Slicer(affine,data)    
    #add one way communication between tl and sl
    #tl.slicer=sl

    title = 'Bundle Picking'
    w = Window(caption = title, 
                width = 1200, 
                height = 800, 
                bgcolor = (0.,0.,0.2) )

    scene = Scene( scenename = 'Main',
                        extent_min = np.array([-5.0, -5, -5]),
                        extent_max = np.array([5, 5 ,5]))
    
    ax = Axes(name = "3 axes", scale= 10, linewidth=2.0)

    vert = np.array( [[2.0,3.0,0.0]], dtype = np.float32 )
    ptr = np.array( [[.2,.2,.2]], dtype = np.float32 )
    tex = Text3D( "Text3D", vert, "(0,0,0)", 10*2.5, 10*.5, ptr)

    #scene.add_actor(ax)
    #scene.add_actor(tex)
    scene.add_actor(tl)
    #scene.add_actor(streamlines)
    #w.screenshot( 'red.png' )
    w.add_scene(scene)
    w.refocus_camera()
Example #7
0
    #create the interaction system for tracks
    tl = TrackLabeler('Bundle Picker',
                      qb,
                      qb.downsampled_tracks(),
                      vol_shape=(182, 218, 182),
                      tracks_alpha=1)
    #add a interactive slicing/masking tool
    #sl = Slicer(affine,data)
    #add one way communication between tl and sl
    #tl.slicer=sl

    title = 'Bundle Picking'
    w = Window(caption=title, width=1200, height=800, bgcolor=(0., 0., 0.2))

    scene = Scene(scenename='Main',
                  extent_min=np.array([-5.0, -5, -5]),
                  extent_max=np.array([5, 5, 5]))

    ax = Axes(name="3 axes", scale=10, linewidth=2.0)

    vert = np.array([[2.0, 3.0, 0.0]], dtype=np.float32)
    ptr = np.array([[.2, .2, .2]], dtype=np.float32)
    tex = Text3D("Text3D", vert, "(0,0,0)", 10 * 2.5, 10 * .5, ptr)

    #scene.add_actor(ax)
    #scene.add_actor(tex)
    scene.add_actor(tl)
    #scene.add_actor(streamlines)
    #w.screenshot( 'red.png' )
    w.add_scene(scene)
    w.refocus_camera()
Example #8
0
    dname = '/home/eg309/Data/111104/subj_05/'
    fname = dname + '101_32/DTI/fa.nii.gz'
    #dname = '/usr/share/fsl/data/standard/'
    #fname = dname + 'FMRIB58_FA_1mm.nii.gz'
    img=nib.load(fname)
    data = img.get_data()
    data[np.isnan(data)] = 0
    data = np.interp(data, [data.min(), data.max()], [0, 255])
    data = data.astype(np.ubyte)
    affine = img.get_affine() 
    print data.shape

    I, J, K = data.shape[:3]
	
    window = Window(caption='[F]OS',bgcolor = (0, 0, 0.6))
    scene = Scene(activate_aabb = False)
    
    texi = Texture3D('i', data, affine=None, interp='linear')
    texj = Texture3D('j', data, affine=None, interp='linear')
    texk = Texture3D('k', data, affine=None, interp='linear')

    container_size = texi.container.shape[0]

    #centershift, _ = ijktoras(np.array([[I/2., J/2., K/2.]]), data.shape,
    #                        affine, 3 * (container_size,), True)

    #print centershift
    centershift = img_to_ras_coords_container(np.array([[I/2., J/2., K/2.]]), 
                    data.shape, affine)

    centershift = ras_to_las_coords(centershift)
Example #9
0
    
    #dname='/home/eg309/Data/trento_processed/subj_03/MPRAGE_32/'
    #fname = dname + 'T1_flirt_out.nii.gz'
    #dname = '/home/eg309/Data/111104/subj_05/'
    #fname = dname + '101_32/DTI/fa.nii.gz'
    dname = '/usr/share/fsl/data/standard/'
    fname = dname + 'FMRIB58_FA_1mm.nii.gz'
    #fname = '/home/eleftherios/Data/trento_processed/subj_01/MPRAGE_32/raw.nii'
    img=nib.load(fname)
    data = img.get_data()
    data[np.isnan(data)] = 0
    data = np.interp(data, [data.min(), data.max()], [0, 255])
    data = data.astype(np.ubyte)
    affine = img.get_affine() 
    print data.shape 
	
    Init()

    window = Window(caption='[F]OS',bgcolor = (0.1, 0.2, 0.6))
    scene = Scene(activate_aabb = False)
    
    sli = Slicer('Volume Slicer', data, affine, convention='RAS')

    scene.add_actor(sli)
    window.add_scene(scene)
    window.refocus_camera()

    Run()


Example #10
0
    dname = '/home/eg309/Data/111104/subj_05/'
    fname = dname + '101_32/DTI/fa.nii.gz'
    #dname = '/usr/share/fsl/data/standard/'
    #fname = dname + 'FMRIB58_FA_1mm.nii.gz'
    img = nib.load(fname)
    data = img.get_data()
    data[np.isnan(data)] = 0
    data = np.interp(data, [data.min(), data.max()], [0, 255])
    data = data.astype(np.ubyte)
    affine = img.get_affine()
    print data.shape

    I, J, K = data.shape[:3]

    window = Window(caption='[F]OS', bgcolor=(0, 0, 0.6))
    scene = Scene(activate_aabb=False)

    texi = Texture3D('i', data, affine=None, interp='linear')
    texj = Texture3D('j', data, affine=None, interp='linear')
    texk = Texture3D('k', data, affine=None, interp='linear')

    container_size = texi.container.shape[0]

    #centershift, _ = ijktoras(np.array([[I/2., J/2., K/2.]]), data.shape,
    #                        affine, 3 * (container_size,), True)

    #print centershift
    centershift = img_to_ras_coords_container(
        np.array([[I / 2., J / 2., K / 2.]]), data.shape, affine)

    centershift = ras_to_las_coords(centershift)