Esempio n. 1
0
def render_fmri(volume):
    data = np.zeros(mask.shape)
    data[mask] = volume
    data  *= blurred_data

    fmri_src = viz3d.affine_img_src(data, fmri_affine,
                                        name='fMRI')
    vol = mlab.pipeline.volume(fmri_src)

    # Change the opacity function
    from enthought.tvtk.util.ctf import PiecewiseFunction

    width = .1
    otf = PiecewiseFunction()
    otf.add_point(-FMRI_MAX, .2)
    otf.add_point(-width*FMRI_MAX, 0.)
    otf.add_point(width*FMRI_MAX, 0.)
    otf.add_point(FMRI_MAX, .2)
    vol._volume_property.set_scalar_opacity(otf)
    vol.update_ctf = True
    return fmri_src
Esempio n. 2
0
mlab.options.offscreen = True

f = mlab.figure(512, bgcolor=(0, 0, 0), size=(1025/REDUCE, 769/REDUCE))
mlab.clf()
f.scene.disable_render = True

################################################################################
# Constants

mem = Memory(cachedir='cache', mmap_mode='r', debug=True)

################################################################################
# Volume rendering of the anat
anat_data, anat_affine, anat_vmax = anat_cache._AnatCache.get_anat()
anat_src = viz3d.affine_img_src(anat_data, anat_affine, name='Anat')

anat_blurred = ndimage.gaussian_filter(
                (ndimage.morphology.binary_fill_holes(
                    ndimage.gaussian_filter(
                            (anat_data > 4800).astype(np.float), 6)
                        > 0.5
                    )).astype(np.float),
                2)

# The cortex shell
vol = mlab.pipeline.volume(anat_src, color=(1, 1, 1))

# Change the opacity function
from enthought.tvtk.util.ctf import PiecewiseFunction