Example #1
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)
Example #2
0
def visualize(pos, parents, offset, colors):

    wi = Window()
    w = wi.get_world()
    act = NeuronRegion(vertices=pos, connectivity=parents, offset=offset, colors=colors, force_centering=True)

    w.add(act)
    return act
Example #3
0
def visualize(pos, parents, offset, colors):

    wi = Window()
    w = wi.get_world()
    act = NeuronRegion(vertices=pos,
                       connectivity=parents,
                       offset=offset,
                       colors=colors,
                       force_centering=True)

    w.add(act)
    return act
Example #4
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()
Example #5
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()
Example #6
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()
Example #7
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)
Example #8
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)
Example #9
0
            "..", "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.random.rand(np.sum(lentra),4)
    #colors[:,3]=0.9
    """

    streamlines = Line('fornix', tracks, colors, line_width=2)
    from fos import Window, Region
    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))
    region = Region(regionname='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)

    region.add_actor(ax)
    region.add_actor(tex)
    region.add_actor(streamlines)
    #w.screenshot( 'red.png' )
    w.add_region(region)
Example #10
0
import numpy as np

from fos import Window
from fos.actor.spherecloud import SphereCloud

n = 100

# the positions for the sphere
positions = np.random.random( (n,3) ).astype( np.float32 ) * 500

# the radii for the spheres
radii = np.random.random( (n,) ).astype( np.float32 ) * 10

# the color for the spheres
colors = np.random.random( (n,4) ).astype( np.float32 ) * 10
colors[:,3] = 1.0

sc = SphereCloud( positions = positions, radii=radii, colors=colors )

wi = Window()
w = wi.get_world()
w.add(sc)
Example #11
0
parents = f["neurons/localtopology"].value
labeling = f["neurons/labeling"].value
colors = f["neurons/segmentcolors"].value
f.close()

print pos
print parents
print labeling
print colors

mycpt = "Treedemo - Fos.me"
try:
    # Try and create a window with multisampling (antialiasing)
    config = Config(sample_buffers=1, samples=4, depth_size=16, double_buffer=True)
    window = Window(
        resizable=True, config=config, vsync=False, width=1000, height=800, caption=mycpt
    )  # "vsync=False" to check the framerate
except fos.lib.pyglet.window.NoSuchConfigException:
    # Fall back to no multisampling for old hardware
    print "fallback"
    window = Window(resizable=True, caption=mycpt)

ac = []
s = 500
# tune it up
# this is very inefficient, because it copies the position arrays
for i in range(1000):
    pos2 = pos.copy()
    pos2[:, 0] = pos2[:, 0] + (randn() - 0.5) * s
    pos2[:, 1] = pos2[:, 1] + (randn() - 0.5) * s
    # random width array
Example #12
0
print parents
print labeling
print colors

mycpt = "Treedemo - Fos.me"
try:
    # Try and create a window with multisampling (antialiasing)
    config = Config(
        sample_buffers=1,
        samples=4,
        depth_size=16,
        double_buffer=True,
    )
    window = Window(resizable=True,
                    config=config,
                    vsync=False,
                    width=1000,
                    height=800,
                    caption=mycpt)  # "vsync=False" to check the framerate
except fos.lib.pyglet.window.NoSuchConfigException:
    # Fall back to no multisampling for old hardware
    print "fallback"
    window = Window(resizable=True, caption=mycpt)

ac = []
# spread factor
s = 500
# duplicator
d = 30

# tune it up
# this is very inefficient, because it copies the position arrays
Example #13
0
import numpy as np

from fos import Window, WindowManager
from fos.actor.network import DynamicNetwork

#import fos.lib.pyglet
#fos.lib.pyglet.options['debug_gl'] = True

wi = Window(caption = "Dynamic Network with Fos")
w = wi.get_world()

# time steps
ts = 200

# node positions
s = 1000
pos = np.zeros( (s,3,ts)).astype(np.float32)
pos[:,:,0] = np.random.random( (s,3)).astype(np.float32) * 200 - 100
for i in xrange(1,ts):
    pos[:,:,i] = pos[:,:,i-1] + np.random.random( (s,3)).astype(np.float32) * 4 - 2
col = np.random.random_integers( 0, 255-1, (s,4,ts) ).astype(np.ubyte)
#col[:, 3, :] = 255

size = np.random.random( (s ,ts) ).astype(np.float32)

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

edg_col = np.random.random_integers( 0, 255-1, (ss,4,ts) ).astype(np.ubyte)
Example #14
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()
Example #15
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 #16
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 #17
0
    """

    affine = None

    data = np.zeros((256, 128, 32), np.uint8)
    volume = np.zeros(data.shape + (3, ))
    volume[..., 0] = data.copy()
    volume[..., 1] = data.copy()
    volume[..., 2] = data.copy()
    volume = volume.astype(np.ubyte)
    volume[..., :] = (255, 0, 0)

    #volume[] =
    print volume.shape, volume.min(), volume.max()

    window = Window()
    region = Region()

    #volume = data
    tex = Texture3D('Buzz', volume, affine)
    w, h, d = volume.shape[:-1]
    depindex = 100
    dep = (0.5 + depindex) / np.float(d)
    texcoords = np.array([[dep, 0, 0], [dep, 0, 1], [dep, 1, 1], [dep, 1, 0]])
    vertcoords = np.array([[-w / 2., -h / 2., 0.], [-w / 2., h / 2., 0.],
                           [w / 2., h / 2., 0.], [w / 2, -h / 2., 0]])

    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)
Example #18
0
import numpy as np
import nibabel as nib
import os.path as op

from fos import World, Window, WindowManager
from fos.actor.curve import InteractiveCurves
from fos.core.data import get_track_filename

# exmple track file
streams, hdr = nib.trackvis.read(get_track_filename())

T = [s[0] for s in streams]
Trk = np.array(T, dtype=np.object)
print "loaded file"

cu = InteractiveCurves(curves=T)

w = World()
w.add(cu)

wi = Window(caption="Interactive Curves")
wi.attach(w)

wm = WindowManager()
wm.add(wi)
wm.run()
Example #19
0
    """
  
    affine = None
    
    data = np.zeros((256, 128, 32), np.uint8)
    volume = np.zeros(data.shape+(3,))
    volume[...,0] = data.copy()
    volume[...,1] = data.copy()
    volume[...,2] = data.copy()
    volume = volume.astype(np.ubyte)
    volume[..., :] = (255, 0 , 0)
    
    #volume[] = 
    print volume.shape, volume.min(), volume.max()
	
    window = Window()
    region = Region()
    
    #volume = data
    tex = Texture3D('Buzz', volume, affine)
    w, h, d = volume.shape[:-1]
    depindex = 100
    dep = (0.5 + depindex) / np.float(d)
    texcoords = np.array([  [dep, 0, 0], 
                            [dep, 0, 1], 
                            [dep, 1, 1],
                            [dep, 1, 0] ])
    vertcoords = np.array( [ [-w/2., -h/2., 0.],
                            [-w/2., h/2., 0.],
                            [w/2., h/2., 0.],
                            [w/2, -h/2., 0] ])
Example #20
0
print normals.min(), normals.max(), normals.mean()

print vertices.dtype, faces.dtype, colors.dtype, normals.dtype

from fos.actor.surf import Surface
from fos import Window, World, DefaultCamera

aff = np.eye(4, dtype=np.float32)
#aff[0,3] = 30

s = Surface(vertices,
            faces,
            colors,
            normals=normals,
            affine=None,
            force_centering=True,
            add_lights=False)

#vertices2=vertices+np.array([10,0,0],dtype=vertices.dtype)
#s2=Surface(vertices2,faces,colors, affine = aff, normals=normals)

w = World()
w.add(s)
#w.add(s2)

cam = DefaultCamera()
w.add(cam)

wi = Window(bgcolor=(1., 0., 1., 1.), width=1000, height=1000)
wi.attach(w)
Example #21
0
#!/usr/bin/env python

import numpy as np

import pyglet as pyglet
from pyglet.gl import *

from fos import World, Window, WindowManager
from fos.actor.treeregion import TreeRegion
from fos.actor.axes import Axes

mycpt = "TreeRegion Demo - Fos.me"
try:
    # Try and create a window with multisampling (antialiasing)
    config = Config(sample_buffers=1, samples=4,depth_size=16, double_buffer=True,)
    window = Window(resizable=True, config=config, vsync=False, width=1000, height=800, 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],
Example #22
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()
Example #23
0
from euclid import *

import fos.lib.pyglet as pyglet
from fos.lib.pyglet.gl import *
from fos.lib.pyglet.window import key

from fos.actor.tree import Tree

import numpy as np

from fos import Window

try:
    # Try and create a window with multisampling (antialiasing)
    config = Config(sample_buffers=1, samples=4,depth_size=16, double_buffer=True,)
    window = Window(resizable=True, config=config, vsync=False, width=1000, height=800) # "vsync=False" to check the framerate
except pyglet.window.NoSuchConfigException:
    # Fall back to no multisampling for old hardware
    window = Window(resizable=True)


fps_display = pyglet.clock.ClockDisplay() # see programming guide pg 48

@window.event
def on_resize(width, height):
    print "newsize ", width, height
    if height==0: height=1
    # Override the default on_resize handler to create a 3D projection
    glViewport(0, 0, width, height)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
Example #24
0
    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.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' )
Example #25
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()
    
Example #26
0
File: world.py Project: 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()