예제 #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()
예제 #2
0
파일: slicer1.py 프로젝트: baothien/tiensy
#        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)
    



    

예제 #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()
예제 #4
0
파일: line.py 프로젝트: shdwdln/fos
    """

    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()


예제 #5
0
파일: tex3d.py 프로젝트: tsiaras/fos
    #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)
    #scene.add_actor(ax)
    #scene.add_actor(text)
    window.add_scene(scene)
    window.refocus_camera()



예제 #6
0
                        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()

예제 #7
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()
예제 #8
0
파일: coords.py 프로젝트: Paolopost/fos
                          [0, j, K], 
                          [I, j, K], 
                          [I, j, 0]], dtype='f8')
    
    vertcoords = img_to_ras_coords_container(imgcoords, data.shape, affine)
    vertcoords = ras_to_las_coords(vertcoords)
    texcoords = img_to_tex_coords(imgcoords, data.shape)
    
    vertcoords = vertcoords - centershift
    texj.update_quad(texcoords, vertcoords)

    k = K / 2.
    imgcoords = np.array([[0, 0, k], 
                          [0, J, k], 
                          [I, J, k], 
                          [I, 0, k]], dtype='f8')

    vertcoords = img_to_ras_coords_container(imgcoords, data.shape, affine)
    vertcoords = ras_to_las_coords(vertcoords)
    texcoords = img_to_tex_coords(imgcoords, data.shape)
    
    vertcoords = vertcoords - centershift
    texk.update_quad(texcoords, vertcoords)

    scene.add_actor(texi)
    scene.add_actor(texj)
    scene.add_actor(texk)
    window.add_scene(scene)
    window.refocus_camera()

예제 #9
0
파일: slicer.py 프로젝트: Paolopost/fos
    
    #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()


예제 #10
0
파일: coords.py 프로젝트: shdwdln/fos
    vertcoords = vertcoords - centershift
    texi.update_quad(texcoords, vertcoords)

    j = J / 2.
    imgcoords = np.array([[0, j, 0], [0, j, K], [I, j, K], [I, j, 0]],
                         dtype='f8')

    vertcoords = img_to_ras_coords_container(imgcoords, data.shape, affine)
    vertcoords = ras_to_las_coords(vertcoords)
    texcoords = img_to_tex_coords(imgcoords, data.shape)

    vertcoords = vertcoords - centershift
    texj.update_quad(texcoords, vertcoords)

    k = K / 2.
    imgcoords = np.array([[0, 0, k], [0, J, k], [I, J, k], [I, 0, k]],
                         dtype='f8')

    vertcoords = img_to_ras_coords_container(imgcoords, data.shape, affine)
    vertcoords = ras_to_las_coords(vertcoords)
    texcoords = img_to_tex_coords(imgcoords, data.shape)

    vertcoords = vertcoords - centershift
    texk.update_quad(texcoords, vertcoords)

    scene.add_actor(texi)
    scene.add_actor(texj)
    scene.add_actor(texk)
    window.add_scene(scene)
    window.refocus_camera()