当前位置: 首页>>代码示例>>Python>>正文


Python Brain.scale_data_colormap方法代码示例

本文整理汇总了Python中surfer.Brain.scale_data_colormap方法的典型用法代码示例。如果您正苦于以下问题:Python Brain.scale_data_colormap方法的具体用法?Python Brain.scale_data_colormap怎么用?Python Brain.scale_data_colormap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在surfer.Brain的用法示例。


在下文中一共展示了Brain.scale_data_colormap方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_movie

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import scale_data_colormap [as 别名]
def test_movie():
    """Test saving a movie of an MEG inverse solution."""
    import imageio

    # create and setup the Brain instance
    _set_backend()
    brain = Brain(*std_args)
    stc_fname = os.path.join(data_dir, 'meg_source_estimate-lh.stc')
    stc = io.read_stc(stc_fname)
    data = stc['data']
    time = np.arange(data.shape[1]) * stc['tstep'] + stc['tmin']
    brain.add_data(data, colormap='hot', vertices=stc['vertices'],
                   smoothing_steps=10, time=time, time_label='time=%0.2f ms')
    brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)

    # save movies with different options
    tempdir = mkdtemp()
    try:
        dst = os.path.join(tempdir, 'test.mov')
        # test the number of frames in the movie
        brain.save_movie(dst)
        frames = imageio.mimread(dst)
        assert_equal(len(frames), 2)
        brain.save_movie(dst, time_dilation=10)
        frames = imageio.mimread(dst)
        assert_equal(len(frames), 7)
        brain.save_movie(dst, tmin=0.081, tmax=0.102)
        frames = imageio.mimread(dst)
        assert_equal(len(frames), 2)
    finally:
        # clean up
        if not (sys.platform == 'win32' and
                os.getenv('APPVEYOR', 'False') == 'True'):  # cleanup problems
            shutil.rmtree(tempdir)
    brain.close()
开发者ID:mwaskom,项目名称:PySurfer,代码行数:37,代码来源:test_viz.py

示例2: test_movie

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import scale_data_colormap [as 别名]
def test_movie():
    """Test saving a movie of an MEG inverse solution
    """
    # create and setup the Brain instance
    mlab.options.backend = 'auto'
    brain = Brain(*std_args)
    stc_fname = os.path.join(data_dir, 'meg_source_estimate-lh.stc')
    stc = io.read_stc(stc_fname)
    data = stc['data']
    time = np.arange(data.shape[1]) * stc['tstep'] + stc['tmin']
    brain.add_data(data, colormap='hot', vertices=stc['vertices'],
                   smoothing_steps=10, time=time, time_label='time=%0.2f ms')
    brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)

    # save movies with different options
    tempdir = mkdtemp()
    try:
        dst = os.path.join(tempdir, 'test.mov')
        brain.save_movie(dst)
        brain.save_movie(dst, tmin=0.081, tmax=0.102)
        # test the number of frames in the movie
        sp = subprocess.Popen(('ffmpeg', '-i', 'test.mov', '-vcodec', 'copy',
                               '-f', 'null', '/dev/null'), cwd=tempdir,
                              stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = sp.communicate()
        m = re.search('frame=\s*(\d+)\s', stderr)
        if not m:
            raise RuntimeError(stderr)
        n_frames = int(m.group(1))
        assert_equal(n_frames, 3)
    finally:
        # clean up
        shutil.rmtree(tempdir)
    brain.close()
开发者ID:bpinsard,项目名称:PySurfer,代码行数:36,代码来源:test_viz.py

示例3: test_meg_inverse

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import scale_data_colormap [as 别名]
def test_meg_inverse():
    """Test plotting of MEG inverse solution."""
    _set_backend()
    brain = Brain(*std_args)
    stc_fname = os.path.join(data_dir, 'meg_source_estimate-lh.stc')
    stc = io.read_stc(stc_fname)
    vertices = stc['vertices']
    colormap = 'hot'
    data = stc['data']
    data_full = (brain.geo['lh'].nn[vertices][..., np.newaxis] *
                 data[:, np.newaxis])
    time = np.linspace(stc['tmin'], stc['tmin'] + data.shape[1] * stc['tstep'],
                       data.shape[1], endpoint=False)

    def time_label(t):
        return 'time=%0.2f ms' % (1e3 * t)

    for use_data in (data, data_full):
        brain.add_data(use_data, colormap=colormap, vertices=vertices,
                       smoothing_steps=1, time=time, time_label=time_label)

    brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)
    assert_equal(brain.data_dict['lh']['time_idx'], 0)

    brain.set_time(.1)
    assert_equal(brain.data_dict['lh']['time_idx'], 2)
    # viewer = TimeViewer(brain)

    # multiple data layers
    assert_raises(ValueError, brain.add_data, data, vertices=vertices,
                  time=time[:-1])
    brain.add_data(data, colormap=colormap, vertices=vertices,
                   smoothing_steps=1, time=time, time_label=time_label,
                   initial_time=.09)
    assert_equal(brain.data_dict['lh']['time_idx'], 1)
    data_dicts = brain._data_dicts['lh']
    assert_equal(len(data_dicts), 3)
    assert_equal(data_dicts[0]['time_idx'], 1)
    assert_equal(data_dicts[1]['time_idx'], 1)

    # shift time in both layers
    brain.set_data_time_index(0)
    assert_equal(data_dicts[0]['time_idx'], 0)
    assert_equal(data_dicts[1]['time_idx'], 0)
    brain.set_data_smoothing_steps(2)

    # add second data-layer without time axis
    brain.add_data(data[:, 1], colormap=colormap, vertices=vertices,
                   smoothing_steps=2)
    brain.set_data_time_index(2)
    assert_equal(len(data_dicts), 4)

    # change surface
    brain.set_surf('white')

    # remove all layers
    brain.remove_data()
    assert_equal(brain._data_dicts['lh'], [])

    brain.close()
开发者ID:mwaskom,项目名称:PySurfer,代码行数:62,代码来源:test_viz.py

示例4: test_meg_inverse

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import scale_data_colormap [as 别名]
def test_meg_inverse():
    """Test plotting of MEG inverse solution
    """
    mlab.options.backend = 'test'
    brain = Brain(*std_args)
    stc_fname = os.path.join(data_dir, 'meg_source_estimate-lh.stc')
    stc = io.read_stc(stc_fname)
    data = stc['data']
    vertices = stc['vertices']
    time = np.linspace(stc['tmin'], stc['tmin'] + data.shape[1] * stc['tstep'],
                       data.shape[1], endpoint=False)
    colormap = 'hot'

    def time_label(t):
        return 'time=%0.2f ms' % (1e3 * t)

    brain.add_data(data, colormap=colormap, vertices=vertices,
                   smoothing_steps=10, time=time, time_label=time_label)
    brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)
    assert_equal(brain.data_dict['lh']['time_idx'], 0)

    brain.set_time(.1)
    assert_equal(brain.data_dict['lh']['time_idx'], 2)
    # viewer = TimeViewer(brain)

    brain.add_data(data, colormap=colormap, vertices=vertices,
                   smoothing_steps=10, time=time, time_label=time_label,
                   initial_time=.09, remove_existing=True)
    assert_equal(brain.data_dict['lh']['time_idx'], 1)
    brain.close()
开发者ID:Nasim-photon,项目名称:PySurfer,代码行数:32,代码来源:test_viz.py

示例5: test_movie

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import scale_data_colormap [as 别名]
def test_movie(tmpdir):
    """Test saving a movie of an MEG inverse solution."""
    import imageio
    if sys.version_info < (3,):
        raise SkipTest('imageio ffmpeg requires Python 3')
    # create and setup the Brain instance
    _set_backend()
    brain = Brain(*std_args)
    stc_fname = os.path.join(data_dir, 'meg_source_estimate-lh.stc')
    stc = io.read_stc(stc_fname)
    data = stc['data']
    time = np.arange(data.shape[1]) * stc['tstep'] + stc['tmin']
    brain.add_data(data, colormap='hot', vertices=stc['vertices'],
                   smoothing_steps=10, time=time, time_label='time=%0.2f ms')
    brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)

    # save movies with different options
    dst = str(tmpdir.join('test.mov'))
    # test the number of frames in the movie
    brain.save_movie(dst)
    frames = imageio.mimread(dst)
    assert len(frames) == 2
    brain.save_movie(dst, time_dilation=10)
    frames = imageio.mimread(dst)
    assert len(frames) == 7
    brain.save_movie(dst, tmin=0.081, tmax=0.102)
    frames = imageio.mimread(dst)
    assert len(frames) == 2
    brain.close()
开发者ID:nipy,项目名称:PySurfer,代码行数:31,代码来源:test_viz.py

示例6: test_meg_inverse

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import scale_data_colormap [as 别名]
def test_meg_inverse():
    """Test plotting of MEG inverse solution
    """
    mlab.options.backend = 'test'
    brain = Brain(*std_args)
    stc_fname = os.path.join(data_dir, 'meg_source_estimate-lh.stc')
    stc = io.read_stc(stc_fname)
    data = stc['data']
    vertices = stc['vertices']
    time = 1e3 * np.linspace(stc['tmin'],
                             stc['tmin'] + data.shape[1] * stc['tstep'],
                             data.shape[1])
    colormap = 'hot'
    time_label = 'time=%0.2f ms'
    brain.add_data(data, colormap=colormap, vertices=vertices,
                   smoothing_steps=10, time=time, time_label=time_label)
    brain.set_data_time_index(2)
    brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)
开发者ID:joewalter,项目名称:PySurfer,代码行数:20,代码来源:test_viz.py

示例7: plot_source_estimates

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import scale_data_colormap [as 别名]

#.........这里部分代码省略.........
    from mayavi import mlab

    # import here to avoid circular import problem
    from ..source_estimate import SourceEstimate

    if not isinstance(stc, SourceEstimate):
        raise ValueError('stc has to be a surface source estimate')

    if hemi not in ['lh', 'rh', 'split', 'both']:
        raise ValueError('hemi has to be either "lh", "rh", "split", '
                         'or "both"')

    n_split = 2 if hemi == 'split' else 1
    n_views = 1 if isinstance(views, string_types) else len(views)
    if figure is not None:
        # use figure with specified id or create new figure
        if isinstance(figure, int):
            figure = mlab.figure(figure, size=(600, 600))
        # make sure it is of the correct type
        if not isinstance(figure, list):
            figure = [figure]
        if not all(isinstance(f, mayavi.core.scene.Scene) for f in figure):
            raise TypeError('figure must be a mayavi scene or list of scenes')
        # make sure we have the right number of figures
        n_fig = len(figure)
        if not n_fig == n_split * n_views:
            raise RuntimeError('`figure` must be a list with the same '
                               'number of elements as PySurfer plots that '
                               'will be created (%s)' % n_split * n_views)

    # Check if using old fmin/fmid/fmax cmap behavior
    if clim is None:
        # Throw deprecation warning and indicate future behavior
        warnings.warn('Using fmin, fmid, fmax (either manually or by default)'
                      ' is deprecated and will be removed in v0.10. Set'
                      ' "clim" to define color limits. In v0.10, "clim" will'
                      ' be set to "auto" by default.',
                      DeprecationWarning)
        # Fill in any missing flim values from deprecated defaults
        dep_lims = [v or c for v, c in zip([fmin, fmid, fmax], [5., 10., 15.])]
        clim = dict(kind='value', lims=dep_lims)
    else:
        if any(f is not None for f in [fmin, fmid, fmax]):
            raise ValueError('"clim" overrides fmin, fmid, fmax')

    # convert control points to locations in colormap
    ctrl_pts, colormap = _limits_to_control_points(clim, stc.data, colormap)

    # Construct cmap manually if 'mne' and get cmap bounds
    # and triage transparent argument
    if colormap in ('mne', 'mne_analyze'):
        colormap = mne_analyze_colormap(ctrl_pts)
        scale_pts = [-1 * ctrl_pts[-1], 0, ctrl_pts[-1]]
        transparent = False if transparent is None else transparent
    else:
        scale_pts = ctrl_pts
        transparent = True if transparent is None else transparent

    subjects_dir = get_subjects_dir(subjects_dir=subjects_dir)
    subject = _check_subject(stc.subject, subject, False)
    if subject is None:
        if 'SUBJECT' in os.environ:
            subject = os.environ['SUBJECT']
        else:
            raise ValueError('SUBJECT environment variable not set')

    if hemi in ['both', 'split']:
        hemis = ['lh', 'rh']
    else:
        hemis = [hemi]

    title = subject if len(hemis) > 1 else '%s - %s' % (subject, hemis[0])
    args = inspect.getargspec(Brain.__init__)[0]
    kwargs = dict(title=title, figure=figure, config_opts=config_opts,
                  subjects_dir=subjects_dir)
    if 'views' in args:
        kwargs['views'] = views
    with warnings.catch_warnings(record=True):  # traits warnings
        brain = Brain(subject, hemi, surface, **kwargs)
    for hemi in hemis:
        hemi_idx = 0 if hemi == 'lh' else 1
        if hemi_idx == 0:
            data = stc.data[:len(stc.vertices[0])]
        else:
            data = stc.data[len(stc.vertices[0]):]
        vertices = stc.vertices[hemi_idx]
        time = 1e3 * stc.times
        with warnings.catch_warnings(record=True):  # traits warnings
            brain.add_data(data, colormap=colormap, vertices=vertices,
                           smoothing_steps=smoothing_steps, time=time,
                           time_label=time_label, alpha=alpha, hemi=hemi,
                           colorbar=colorbar)

        # scale colormap and set time (index) to display
        brain.scale_data_colormap(fmin=scale_pts[0], fmid=scale_pts[1],
                                  fmax=scale_pts[2], transparent=transparent)

    if time_viewer:
        TimeViewer(brain)
    return brain
开发者ID:XristosK,项目名称:mne-python,代码行数:104,代码来源:_3d.py

示例8: read_stc

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import scale_data_colormap [as 别名]
# Read the MNE dSPM inverse solution

hemi = 'lh'
stc_fname = os.path.join('example_data', 'meg_source_estimate-' +
                         hemi + '.stc')
stc = read_stc(stc_fname)

# data and vertices for which the data is defined
data = stc['data']
vertices = stc['vertices']
time = np.linspace(stc['tmin'], stc['tmin'] + data.shape[1] * stc['tstep'],
                   data.shape[1], endpoint=False)

# MNE will soon add the option for a "full" inverse to be computed and stored.
# In the meantime, we can get the equivalent for our data based on the
# surface normals:

data_full = brain.geo['lh'].nn[vertices][..., np.newaxis] * data[:, np.newaxis]

# Now we add the data and set the initial time displayed to 100 ms:
brain.add_data(data_full, colormap='hot', vertices=vertices, alpha=0.5,
               smoothing_steps=5, time=time, hemi=hemi, initial_time=0.1,
               vector_alpha=0.5, verbose=False)

# scale colormap
brain.scale_data_colormap(fmin=7, fmid=14, fmax=21, transparent=True,
                          verbose=False)

# viewer = TimeViewer(brain)
开发者ID:Eric89GXL,项目名称:PySurfer,代码行数:31,代码来源:plot_vector_meg_inverse_solution.py

示例9: plot_source_estimates

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import scale_data_colormap [as 别名]

#.........这里部分代码省略.........
    if surfer_version < v06:
        raise ImportError("This function requires PySurfer 0.6 (you are "
                          "running version %s). You can update PySurfer "
                          "using:\n\n    $ pip install -U pysurfer" %
                          surfer.__version__)

    if initial_time is not None and surfer_version > v06:
        kwargs = {'initial_time': initial_time}
        initial_time = None  # don't set it twice
    else:
        kwargs = {}

    if time_unit is None:
        warn("The time_unit parameter default will change from 'ms' to 's' "
             "in MNE 0.14. To avoid this warning specify the parameter "
             "explicitly.", DeprecationWarning)
        time_unit = 'ms'
    elif time_unit not in ('s', 'ms'):
        raise ValueError("time_unit needs to be 's' or 'ms', got %r" %
                         (time_unit,))

    if time_label == 'auto':
        if time_unit == 'ms':
            time_label = 'time=%0.2f ms'
        else:
            def time_label(t):
                return 'time=%0.2f ms' % (t * 1e3)

    if not isinstance(stc, SourceEstimate):
        raise ValueError('stc has to be a surface source estimate')

    if hemi not in ['lh', 'rh', 'split', 'both']:
        raise ValueError('hemi has to be either "lh", "rh", "split", '
                         'or "both"')

    # check `figure` parameter (This will be performed by PySurfer > 0.6)
    if figure is not None:
        if isinstance(figure, int):
            # use figure with specified id
            size_ = size if isinstance(size, (tuple, list)) else (size, size)
            figure = [mayavi.mlab.figure(figure, size=size_)]
        elif not isinstance(figure, (list, tuple)):
            figure = [figure]
        if not all(isinstance(f, mayavi.core.scene.Scene) for f in figure):
            raise TypeError('figure must be a mayavi scene or list of scenes')

    # convert control points to locations in colormap
    ctrl_pts, colormap = _limits_to_control_points(clim, stc.data, colormap)

    # Construct cmap manually if 'mne' and get cmap bounds
    # and triage transparent argument
    if colormap in ('mne', 'mne_analyze'):
        colormap = mne_analyze_colormap(ctrl_pts)
        scale_pts = [-1 * ctrl_pts[-1], 0, ctrl_pts[-1]]
        transparent = False if transparent is None else transparent
    else:
        scale_pts = ctrl_pts
        transparent = True if transparent is None else transparent

    subjects_dir = get_subjects_dir(subjects_dir=subjects_dir,
                                    raise_error=True)
    subject = _check_subject(stc.subject, subject, True)
    if hemi in ['both', 'split']:
        hemis = ['lh', 'rh']
    else:
        hemis = [hemi]

    title = subject if len(hemis) > 1 else '%s - %s' % (subject, hemis[0])
    with warnings.catch_warnings(record=True):  # traits warnings
        brain = Brain(subject, hemi, surface, True, title, cortex, size,
                      background, foreground, figure, subjects_dir, views,
                      config_opts=config_opts)

    if time_unit == 's':
        times = stc.times
    else:  # time_unit == 'ms'
        times = 1e3 * stc.times

    for hemi in hemis:
        hemi_idx = 0 if hemi == 'lh' else 1
        if hemi_idx == 0:
            data = stc.data[:len(stc.vertices[0])]
        else:
            data = stc.data[len(stc.vertices[0]):]
        vertices = stc.vertices[hemi_idx]
        with warnings.catch_warnings(record=True):  # traits warnings
            brain.add_data(data, colormap=colormap, vertices=vertices,
                           smoothing_steps=smoothing_steps, time=times,
                           time_label=time_label, alpha=alpha, hemi=hemi,
                           colorbar=colorbar, **kwargs)

        # scale colormap and set time (index) to display
        brain.scale_data_colormap(fmin=scale_pts[0], fmid=scale_pts[1],
                                  fmax=scale_pts[2], transparent=transparent)

    if initial_time is not None:
        brain.set_time(initial_time)
    if time_viewer:
        TimeViewer(brain)
    return brain
开发者ID:EmanuelaLiaci,项目名称:mne-python,代码行数:104,代码来源:_3d.py

示例10:

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import scale_data_colormap [as 别名]
We want to use an appropriate color map for these data: a divergent map that
is centered on 0, which is a meaningful transition-point as it marks the change
from negative correlations to positive correlations. By providing the 'center'
argument the add_data function automatically chooses a divergent colormap.
"""
brain.add_data(surf_data_lh, 0, .7, center=0, hemi='lh')
brain.add_data(surf_data_rh, 0, .7, center=0, hemi='rh')

"""
You can tune the data display by shifting the colormap around interesting
regions. For example, you can ignore small correlation up to a magnitude of 0.2
and let colors become gradually less transparent from 0.2 to 0.5 by re-scaling
the colormap as follows. For more information see the help string of this
function.
"""
brain.scale_data_colormap(.2, .5, .7, transparent=True, center=0)

"""
You can also set the overall opacity of the displayed data while maintaining
the transparency of the small values.
"""
brain.scale_data_colormap(0, .35, .7, transparent=True, center=0,
                          alpha=0.75)

"""
This overlay represents resting-state correlations with a
seed in left angular gyrus. Let's plot that seed.
"""
seed_coords = (-45, -67, 36)
brain.add_foci(seed_coords, map_surface="white", hemi='lh')
开发者ID:Eric89GXL,项目名称:PySurfer,代码行数:32,代码来源:plot_resting_correlations.py

示例11: plot_source_estimates

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import scale_data_colormap [as 别名]

#.........这里部分代码省略.........
        figure by it's id or create a new figure with the given id.
    views : str | list
        View to use. See surfer.Brain().
    colorbar : bool
        If True, display colorbar on scene.

    Returns
    -------
    brain : Brain
        A instance of surfer.viz.Brain from PySurfer.
    """
    import surfer
    from surfer import Brain, TimeViewer

    if hemi in ['split', 'both'] and LooseVersion(surfer.__version__) < '0.4':
        raise NotImplementedError('hemi type "%s" not supported with your '
                                  'version of pysurfer. Please upgrade to '
                                  'version 0.4 or higher.' % hemi)

    try:
        import mayavi
        from mayavi import mlab
    except ImportError:
        from enthought import mayavi
        from enthought.mayavi import mlab

    # import here to avoid circular import problem
    from ..source_estimate import SourceEstimate

    if not isinstance(stc, SourceEstimate):
        raise ValueError('stc has to be a surface source estimate')

    if hemi not in ['lh', 'rh', 'split', 'both']:
        raise ValueError('hemi has to be either "lh", "rh", "split", '
                         'or "both"')

    n_split = 2 if hemi == 'split' else 1
    n_views = 1 if isinstance(views, string_types) else len(views)
    if figure is not None:
        # use figure with specified id or create new figure
        if isinstance(figure, int):
            figure = mlab.figure(figure, size=(600, 600))
        # make sure it is of the correct type
        if not isinstance(figure, list):
            figure = [figure]
        if not all([isinstance(f, mayavi.core.scene.Scene) for f in figure]):
            raise TypeError('figure must be a mayavi scene or list of scenes')
        # make sure we have the right number of figures
        n_fig = len(figure)
        if not n_fig == n_split * n_views:
            raise RuntimeError('`figure` must be a list with the same '
                               'number of elements as PySurfer plots that '
                               'will be created (%s)' % n_split * n_views)

    subjects_dir = get_subjects_dir(subjects_dir=subjects_dir)

    subject = _check_subject(stc.subject, subject, False)
    if subject is None:
        if 'SUBJECT' in os.environ:
            subject = os.environ['SUBJECT']
        else:
            raise ValueError('SUBJECT environment variable not set')

    if hemi in ['both', 'split']:
        hemis = ['lh', 'rh']
    else:
        hemis = [hemi]

    title = subject if len(hemis) > 1 else '%s - %s' % (subject, hemis[0])
    args = inspect.getargspec(Brain.__init__)[0]
    kwargs = dict(title=title, figure=figure, config_opts=config_opts,
                  subjects_dir=subjects_dir)
    if 'views' in args:
        kwargs['views'] = views
    else:
        logger.info('PySurfer does not support "views" argument, please '
                    'consider updating to a newer version (0.4 or later)')
    with warnings.catch_warnings(record=True):  # traits warnings
        brain = Brain(subject, hemi, surface, **kwargs)
    for hemi in hemis:
        hemi_idx = 0 if hemi == 'lh' else 1
        if hemi_idx == 0:
            data = stc.data[:len(stc.vertices[0])]
        else:
            data = stc.data[len(stc.vertices[0]):]
        vertices = stc.vertices[hemi_idx]
        time = 1e3 * stc.times
        with warnings.catch_warnings(record=True):  # traits warnings
            brain.add_data(data, colormap=colormap, vertices=vertices,
                           smoothing_steps=smoothing_steps, time=time,
                           time_label=time_label, alpha=alpha, hemi=hemi,
                           colorbar=colorbar)

        # scale colormap and set time (index) to display
        brain.scale_data_colormap(fmin=fmin, fmid=fmid, fmax=fmax,
                                  transparent=transparent)

    if time_viewer:
        TimeViewer(brain)
    return brain
开发者ID:agramfort,项目名称:mne-python,代码行数:104,代码来源:_3d.py

示例12: time

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import scale_data_colormap [as 别名]
    time points in milliseconds
    """
    time = 1e3 * np.linspace(stc['tmin'],
                             stc['tmin'] + data.shape[1] * stc['tstep'],
                             data.shape[1])
    """
    colormap to use
    """
    colormap = 'hot'

    """
    label for time annotation
    """
    time_label = 'time=%0.2f ms'

    brain.add_data(data, colormap=colormap, vertices=vertices,
                   smoothing_steps=10, time=time, time_label=time_label,
                   hemi=hemi)

"""
scale colormap and set time (index) to display
"""
brain.set_data_time_index(2)
brain.scale_data_colormap(fmin=13, fmid=18, fmax=22, transparent=True)

"""
uncomment these lines to use the interactive TimeViewer GUI
"""
#from surfer import TimeViewer
#viewer = TimeViewer(brain)
开发者ID:vsteiger,项目名称:PySurfer,代码行数:32,代码来源:plot_meg_inverse_solution.py

示例13: read_stc

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import scale_data_colormap [as 别名]
# Read the MNE dSPM inverse solution

hemi = 'lh'
stc_fname = os.path.join('example_data', 'meg_source_estimate-' +
                         hemi + '.stc')
stc = read_stc(stc_fname)

# data and vertices for which the data is defined
data = stc['data']
vertices = stc['vertices']
time = np.linspace(stc['tmin'], stc['tmin'] + data.shape[1] * stc['tstep'],
                   data.shape[1], endpoint=False)

###############################################################################
# MNE will soon add the option for a "full" inverse to be computed and stored.
# In the meantime, we can get the equivalent for our data based on the
# surface normals:

data_full = brain.geo['lh'].nn[vertices][..., np.newaxis] * data[:, np.newaxis]

###############################################################################
# Now we add the data and set the initial time displayed to 100 ms:
brain.add_data(data_full, colormap='hot', vertices=vertices, alpha=0.5,
               smoothing_steps=5, time=time, hemi=hemi, initial_time=0.1,
               vector_alpha=0.5)

# scale colormap
brain.scale_data_colormap(fmin=7, fmid=14, fmax=21, transparent=True)

# viewer = TimeViewer(brain)
开发者ID:mwaskom,项目名称:PySurfer,代码行数:32,代码来源:plot_vector_meg_inverse_solution.py


注:本文中的surfer.Brain.scale_data_colormap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。