Example #1
0
def movieShow(images, clim=None, duration=0.1, axesAdjust=True, axes=None):
    """ movieShow(images, duration=0.1)
    
    Show the images in the given list as a movie. 
    
    Parameters
    ----------
    images : list
        The 2D images (can be color images) that the movie consists of.
    clim : (min, max)
        The color limits to apply. See imshow.
    duration : scalar
        The duration (in seconds) of each frame. The real duration can
        differ from the given duration, depending on the performance of
        your system.
    axesAdjust : bool
        If axesAdjust==True, this function will call axes.SetLimits(), set
        the camera type to 2D, and make axes.daspect[1] negative (i.e. flip 
        the y-axis). If daspectAuto has not been set yet, it is set to False.
    axes : Axes instance
        Display the image in this axes, or the current axes if not given.
    
    """
    
    # Get axes
    if axes is None:
        axes = vv.gca()
    
    # Create container
    m = vv.MotionDataContainer(axes, duration*1000)
    
    # Create images and put in container
    for im in images:
        t = vv.imshow(im, clim=clim, axesAdjust=axesAdjust, axes=axes)
        t.parent = m
    
    # Return container object
    return m
Example #2
0
        vols.append(vol)

# Start vis
f = vv.figure(3)
vv.clf()
a = vv.gca()
a.daspect = 1, 1, -1
a.axis.axisColor = 1, 1, 1
a.axis.visible = True
a.bgcolor = 0, 0, 0
vv.title(
    'Maximum intensity projection cine-loop of the original ECG-gated CT volumes of patient %s'
    % ptcode[8:])

# Setup data container
container = vv.MotionDataContainer(a)
showVol = 'mip'
for vol in vols:
    #     t = vv.volshow2(vol, clim=(-550, 500)) # -750, 1000
    t = vv.volshow(vol, clim=(0, 2500), renderStyle=showVol)
    t.isoThreshold = 350  # iso or mip work well
    t.parent = container
    if showVol == 'iso':
        t.colormap = {
            'g': [(0.0, 0.0), (0.33636364, 1.0)],
            'b': [(0.0, 0.0), (0.49545455, 1.0)],
            'a': [(0.0, 1.0), (1.0, 1.0)],
            'r': [(0.0, 0.0), (0.22272727, 1.0)]
        }

f.eventKeyDown.Bind(
Example #3
0
def showVolPhases(basedir, vols=None, ptcode=None, ctcode=None, cropname=None, 
    showVol='iso', mipIsocolor=False, isoTh=310,
            slider=False, clim=(0,3000), clim2D=(-550, 500), fname=None):
    """ Show vol phases in motion container
    showVol= mip or iso or 2D; Provide either vols or location
    """
    if vols is None:
        # Load volumes
        s = loadvol(basedir, ptcode, ctcode, cropname, 'phases', fname=fname)
        vols = []
        for key in dir(s):
            if key.startswith('vol'):
                vols.append(s[key])
        
    # Start vis
    f = vv.figure(1); vv.clf()
    f.position = 9.00, 38.00,  992.00, 944.00
    a = vv.gca()
    a.daspect = 1, 1, -1
    a.axis.axisColor = 1,1,1
    a.axis.visible = False
    a.bgcolor = 0,0,0
    if showVol=='mip':
        if not ptcode is None and not ctcode is None:
            vv.title('Maximum intensity projection cine-loop of the original ECG-gated CT volumes of patient %s at %s ' % (ptcode[8:], ctcode))
        else:
            vv.title('Maximum intensity projection cine-loop of the original ECG-gated CT volumes ')
    else:
        if not ptcode is None and not ctcode is None:
            vv.title('ECG-gated CT scan cine-loop of the original ECG-gated CT volumes of patient %s at %s ' % (ptcode[8:], ctcode))
        else:
            vv.title('ECG-gated CT scan cine-loop of the original ECG-gated CT volumes ')
    
    # Setup data container
    container = vv.MotionDataContainer(a)
    for vol in vols:
        if showVol == '2D':
            t = vv.volshow2(vol, clim=clim2D) # -750, 1000
            t.parent = container
        else:
            t = vv.volshow(vol, clim=clim, renderStyle = showVol)
            t.parent = container
            if showVol == 'iso':
                t.isoThreshold = isoTh    # iso or mip work well 
                t.colormap = {'r': [(0.0, 0.0), (0.17727272, 1.0)],
                            'g': [(0.0, 0.0), (0.27272728, 1.0)],
                            'b': [(0.0, 0.0), (0.34545454, 1.0)],
                            'a': [(0.0, 1.0), (1.0, 1.0)]}
            if mipIsocolor:
                t.colormap = {'r': [(0.0, 0.0), (0.17727272, 1.0)],
                            'g': [(0.0, 0.0), (0.27272728, 1.0)],
                            'b': [(0.0, 0.0), (0.34545454, 1.0)],
                            'a': [(0.0, 1.0), (1.0, 1.0)]}
    # bind ClimEditor to figure
    if slider:
        if showVol=='mip':
            c = vv.ClimEditor(vv.gcf())
            c.position = (10, 50)
            f.eventKeyDown.Bind(lambda event: _utils_GUI.ShowHideSlider(event, c) )
        if showVol=='iso':
            c = IsoThEditor(vv.gcf())
            c.position = (10, 50)
            f.eventKeyDown.Bind(lambda event: _utils_GUI.ShowHideSlider(event, c) )
    
    f.eventKeyDown.Bind(lambda event: _utils_GUI.ViewPresets(event, [a]) )
    print('------------------------')
    print('Use keys 1, 2, 3, 4 and 5 for preset anatomic views')
    print('Use v for a default zoomed view')
    print('Use x to show and hide axis')
    print('------------------------')
    
    return t