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


Python sample.data_path函数代码示例

本文整理汇总了Python中mne.datasets.sample.data_path函数的典型用法代码示例。如果您正苦于以下问题:Python data_path函数的具体用法?Python data_path怎么用?Python data_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_flash_bem

def test_flash_bem():
    """Test mne flash_bem."""
    check_usage(mne_flash_bem, force_help=True)
    # Using the sample dataset
    subjects_dir = op.join(sample.data_path(download=False), 'subjects')
    # Copy necessary files to tempdir
    tempdir = _TempDir()
    mridata_path = op.join(subjects_dir, 'sample', 'mri')
    mridata_path_new = op.join(tempdir, 'sample', 'mri')
    os.makedirs(op.join(mridata_path_new, 'flash'))
    os.makedirs(op.join(tempdir, 'sample', 'bem'))
    shutil.copyfile(op.join(mridata_path, 'T1.mgz'),
                    op.join(mridata_path_new, 'T1.mgz'))
    shutil.copyfile(op.join(mridata_path, 'brain.mgz'),
                    op.join(mridata_path_new, 'brain.mgz'))
    # Copy the available mri/flash/mef*.mgz files from the dataset
    files = glob.glob(op.join(mridata_path, 'flash', 'mef*.mgz'))
    for infile in files:
        shutil.copyfile(infile, op.join(mridata_path_new, 'flash',
                                        op.basename(infile)))
    # Test mne flash_bem with --noconvert option
    # (since there are no DICOM Flash images in dataset)
    currdir = os.getcwd()
    with ArgvSetter(('-d', tempdir, '-s', 'sample', '-n'),
                    disable_stdout=False, disable_stderr=False):
        mne_flash_bem.run()
    os.chdir(currdir)
开发者ID:SherazKhan,项目名称:mne-python,代码行数:27,代码来源:test_commands.py

示例2: test_flash_bem

def test_flash_bem():
    """Test mne flash_bem."""
    check_usage(mne_flash_bem, force_help=True)
    # Using the sample dataset
    subjects_dir = op.join(sample.data_path(download=False), 'subjects')
    # Copy necessary files to tempdir
    tempdir = _TempDir()
    mridata_path = op.join(subjects_dir, 'sample', 'mri')
    subject_path_new = op.join(tempdir, 'sample')
    mridata_path_new = op.join(subject_path_new, 'mri')
    os.makedirs(op.join(mridata_path_new, 'flash'))
    os.makedirs(op.join(subject_path_new, 'bem'))
    shutil.copyfile(op.join(mridata_path, 'T1.mgz'),
                    op.join(mridata_path_new, 'T1.mgz'))
    shutil.copyfile(op.join(mridata_path, 'brain.mgz'),
                    op.join(mridata_path_new, 'brain.mgz'))
    # Copy the available mri/flash/mef*.mgz files from the dataset
    flash_path = op.join(mridata_path_new, 'flash')
    for kind in (5, 30):
        in_fname = op.join(mridata_path, 'flash', 'mef%02d.mgz' % kind)
        shutil.copyfile(in_fname, op.join(flash_path, op.basename(in_fname)))
    # Test mne flash_bem with --noconvert option
    # (since there are no DICOM Flash images in dataset)
    out_fnames = list()
    for kind in ('outer_skin', 'outer_skull', 'inner_skull'):
        out_fnames.append(op.join(subject_path_new, 'bem', 'outer_skin.surf'))
    assert not any(op.isfile(out_fname) for out_fname in out_fnames)
    with ArgvSetter(('-d', tempdir, '-s', 'sample', '-n'),
                    disable_stdout=False, disable_stderr=False):
        mne_flash_bem.run()
    # do they exist and are expected size
    for out_fname in out_fnames:
        _, tris = read_surface(out_fname)
        assert len(tris) == 5120
开发者ID:jhouck,项目名称:mne-python,代码行数:34,代码来源:test_commands.py

示例3: _assemble_forward_model_matrix

    def _assemble_forward_model_matrix(inverse_operator):
        from mne.datasets import sample

        warn('Currently info is read from the raw file. TODO: change to getting it from the stream')
        data_path = sample.data_path()
        fname_raw = data_path + '/MEG/sample/sample_audvis_raw.fif'
        raw = mne.io.read_raw_fif(fname_raw, verbose='ERROR')
        info = raw.info
        channel_cnt = info['nchan']
        I = np.identity(channel_cnt)
        dummy_raw = mne.io.RawArray(data=I, info=info, verbose='ERROR')
        dummy_raw.set_eeg_reference(verbose='ERROR');

        # Applying inverse modelling to an identity matrix gives us the forward model matrix
        snr = 1.0  # use smaller SNR for raw data
        lambda2 = 1.0 / snr ** 2
        method = "MNE"  # use sLORETA method (could also be MNE or dSPM)
        stc = mne.minimum_norm.apply_inverse_raw(dummy_raw, inverse_operator, lambda2, method)
        return stc.data
开发者ID:nikolaims,项目名称:nfb,代码行数:19,代码来源:brain.py

示例4: test_preload_memmap

def test_preload_memmap():
    tmpdir = mkdtemp(dir="/Users/cjb/tmp")
    mmap_fname = opj(tmpdir, "raw_data.dat")

    # fname='ec_rest_before_tsss_mc_rsl.fif'
    data_path = sample.data_path(download=False)
    fname = data_path + "/MEG/sample/sample_audvis_raw.fif"

    raw = Raw(fname, preload=False)
    # """This function actually preloads the data"""
    # data_buffer = mmap_fname
    # raw._data = raw._read_segment(data_buffer=data_buffer)[0]
    # assert len(raw._data) == raw.info['nchan']
    # raw.preload = True
    # raw.close()
    raw.preload_data(data_buffer=mmap_fname)
    data_shape = raw._data.shape

    print("Contents of raw._data after reading from fif:")
    print(type(raw._data))
    print(raw._data[100][:5])

    del raw._data
    raw._data = np.memmap(mmap_fname, dtype="float64", mode="c", shape=data_shape)

    print("Contents of raw._data after RE-loading:")
    print(type(raw._data))
    print(raw._data[100][:5])

    raw.filter(None, 40)
    print("Contents of raw._data after filtering:")
    print(type(raw._data))
    print(raw._data[100][:5])

    # PROBLEM: Now the filtered data are IN MEMORY, but as a memmap
    # What if I'd like to continue from here using it as an ndarray?

    del raw._data

    rmtree(tmpdir, ignore_errors=True)
开发者ID:cjayb,项目名称:memory_profiling,代码行数:40,代码来源:mne_preload_raw.py

示例5: test_io_bem_surfaces

import os.path as op

# from numpy.testing import assert_array_almost_equal

import mne
from mne.datasets import sample

examples_folder = op.join(op.dirname(__file__), '..', '..', 'examples')
data_path = sample.data_path(examples_folder)
fname = op.join(data_path, 'subjects', 'sample', 'bem',
                                        'sample-5120-5120-5120-bem-sol.fif')


def test_io_bem_surfaces():
    """Testing reading of bem surfaces
    """
    surf = mne.read_bem_surfaces(fname, add_geom=False)
    surf = mne.read_bem_surfaces(fname, add_geom=True)
    print "Number of surfaces : %d" % len(surf)
开发者ID:emilyruzich,项目名称:mne-python,代码行数:19,代码来源:test_surface.py

示例6: print

import os.path as op

from mayavi import mlab

import mne
from mne.io import read_raw_fif, read_raw_ctf, read_raw_bti, read_raw_kit
from mne.datasets import sample, spm_face
from mne.viz import plot_trans

print(__doc__)

bti_path = op.abspath(op.dirname(mne.__file__)) + "/io/bti/tests/data/"
kit_path = op.abspath(op.dirname(mne.__file__)) + "/io/kit/tests/data/"
raws = dict(
    Neuromag=read_raw_fif(sample.data_path() + "/MEG/sample/sample_audvis_raw.fif"),
    CTF_275=read_raw_ctf(spm_face.data_path() + "/MEG/spm/SPM_CTF_MEG_example_faces1_3D.ds"),
    Magnes_3600wh=read_raw_bti(
        op.join(bti_path, "test_pdf_linux"), op.join(bti_path, "test_config_linux"), op.join(bti_path, "test_hs_linux")
    ),
    KIT=read_raw_kit(op.join(kit_path, "test.sqd")),
)

for system, raw in raws.items():
    # We don't have coil definitions for KIT refs, so exclude them
    ref_meg = False if system == "KIT" else True
    fig = plot_trans(
        raw.info, trans=None, dig=False, eeg_sensors=False, meg_sensors=True, coord_frame="meg", ref_meg=ref_meg
    )
    mlab.title(system)
开发者ID:mmagnuski,项目名称:mne-python,代码行数:29,代码来源:plot_meg_sensors.py

示例7: BSD

# -*- coding: utf-8 -*-
"""
============================
Plot an estimate of data SNR
============================

This estimates the SNR as a function of time for a set of data.
"""
# Author: Eric Larson <[email protected]>
#
# License: BSD (3-clause)

from os import path as op

from mne.datasets.sample import data_path
from mne.minimum_norm import read_inverse_operator
from mne import read_evokeds
from mne.viz import plot_snr_estimate

print(__doc__)

data_dir = op.join(data_path(), 'MEG', 'sample')
fname_inv = op.join(data_dir, 'sample_audvis-meg-oct-6-meg-inv.fif')
fname_evoked = op.join(data_dir, 'sample_audvis-ave.fif')

inv = read_inverse_operator(fname_inv)
evoked = read_evokeds(fname_evoked, baseline=(None, 0))[0]

plot_snr_estimate(evoked, inv)
开发者ID:EmanuelaLiaci,项目名称:mne-python,代码行数:29,代码来源:plot_snr_estimate.py

示例8:

from scipy import sparse
from nose.tools import assert_true, assert_raises
import copy

from mne.datasets import sample
from mne.label import read_label, label_sign_flip
from mne.event import read_events
from mne.epochs import Epochs
from mne.source_estimate import read_source_estimate
from mne import fiff, read_cov, read_forward_solution
from mne.minimum_norm.inverse import apply_inverse, read_inverse_operator, \
    apply_inverse_raw, apply_inverse_epochs, make_inverse_operator, \
    write_inverse_operator, compute_rank_inverse
from mne.utils import _TempDir

s_path = op.join(sample.data_path(), 'MEG', 'sample')
fname_inv = op.join(s_path, 'sample_audvis-meg-oct-6-meg-inv.fif')
fname_inv_fixed = op.join(s_path, 'sample_audvis-meg-oct-6-meg-fixed-inv.fif')
fname_inv_nodepth = op.join(s_path,
                           'sample_audvis-meg-oct-6-meg-nodepth-fixed-inv.fif')
fname_inv_diag = op.join(s_path,
                         'sample_audvis-meg-oct-6-meg-diagnoise-inv.fif')
fname_vol_inv = op.join(s_path, 'sample_audvis-meg-vol-7-meg-inv.fif')
fname_data = op.join(s_path, 'sample_audvis-ave.fif')
fname_cov = op.join(s_path, 'sample_audvis-cov.fif')
fname_fwd = op.join(s_path, 'sample_audvis-meg-oct-6-fwd.fif')
fname_raw = op.join(s_path, 'sample_audvis_filt-0-40_raw.fif')
fname_event = op.join(s_path, 'sample_audvis_filt-0-40_raw-eve.fif')
fname_label = op.join(s_path, 'labels', '%s.label')

label_lh = read_label(fname_label % 'Aud-lh')
开发者ID:mshamalainen,项目名称:mne-python,代码行数:31,代码来源:test_inverse.py

示例9: BSD

#
# License: BSD (3-clause)

import numpy as np
import pylab as pl

import mne
from mne.fiff.pick import pick_types_evoked, pick_types_forward
from mne.datasets import sample
from mne.time_frequency import iir_filter_raw, morlet
from mne.viz import plot_evoked, plot_sparse_source_estimates
from mne.simulation import generate_sparse_stc, generate_evoked

###############################################################################
# Load real data as templates
data_path = sample.data_path('/Users/sudregp/mne-python/examples/')

raw = mne.fiff.Raw(data_path + '/MEG/sample/sample_audvis_raw.fif')
proj = mne.read_proj(data_path + '/MEG/sample/sample_audvis_ecg_proj.fif')
raw.info['projs'] += proj
raw.info['bads'] = ['MEG 2443', 'EEG 053']  # mark bad channels

fwd_fname = data_path + '/MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif'
ave_fname = data_path + '/MEG/sample/sample_audvis-no-filter-ave.fif'
cov_fname = data_path + '/MEG/sample/sample_audvis-cov.fif'

fwd = mne.read_forward_solution(fwd_fname, force_fixed=True, surf_ori=True)
fwd = pick_types_forward(fwd, meg=True, eeg=True, exclude=raw.info['bads'])

cov = mne.read_cov(cov_fname)
开发者ID:gsudre,项目名称:research_code,代码行数:30,代码来源:plot_simulated_data.py

示例10: dec

    """Decorator to skip test if scikit-learn >= 0.12 is not available"""
    @wraps(function)
    def dec(*args, **kwargs):
        if not check_sklearn_version(min_version='0.12'):
            from nose.plugins.skip import SkipTest
            raise SkipTest('Test %s skipped, requires scikit-learn >= 0.12'
                           % function.__name__)
        ret = function(*args, **kwargs)
        return ret
    return dec


if not lacks_mayavi:
    mlab.options.backend = 'test'

data_dir = data_path()
subjects_dir = op.join(data_dir, 'subjects')
sample_src = read_source_spaces(op.join(data_dir, 'subjects', 'sample',
                                        'bem', 'sample-oct-6-src.fif'))
ecg_fname = op.join(data_dir, 'MEG', 'sample', 'sample_audvis_ecg_proj.fif')
evoked_fname = op.join(data_dir, 'MEG', 'sample', 'sample_audvis-ave.fif')
base_dir = op.join(op.dirname(__file__), '..', 'fiff', 'tests', 'data')
fname = op.join(base_dir, 'test-ave.fif')
raw_fname = op.join(base_dir, 'test_raw.fif')
cov_fname = op.join(base_dir, 'test-cov.fif')
event_name = op.join(base_dir, 'test-eve.fif')
event_id, tmin, tmax = 1, -0.2, 0.5
n_chan = 15

raw = fiff.Raw(raw_fname, preload=False)
events = read_events(event_name)
开发者ID:emanuele,项目名称:mne-python,代码行数:31,代码来源:test_viz.py

示例11:

# -*- coding: utf-8 -*-
"""
======================
Configuring MNE python
======================

This tutorial gives a short introduction to MNE configurations.
"""
import os.path as op

import mne
from mne.datasets.sample import data_path

fname = op.join(data_path(), 'MEG', 'sample', 'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(fname).crop(0, 10)
original_level = mne.get_config('MNE_LOGGING_LEVEL', 'INFO')

###############################################################################
# MNE-python stores configurations to a folder called `.mne` in the user's
# home directory, or to AppData directory on Windows. The path to the config
# file can be found out by calling :func:`mne.get_config_path`.
print(mne.get_config_path())

###############################################################################
# These configurations include information like sample data paths and plotter
# window sizes. Files inside this folder should never be modified manually.
# Let's see what the configurations contain.
print(mne.get_config())

###############################################################################
# We see fields like "MNE_DATASETS_SAMPLE_PATH". As the name suggests, this is
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:31,代码来源:plot_configuration.py

示例12: len

import mne
import numpy as np
import pylab as plt
from mne.datasets import sample

# create data
fs = 500
ch_names = ['Fp1','Fp2','F7','F3','Fz','F4','F8','Ft9','Fc5','Fc1','Fc2','Fc6','Ft10','T7','C3','Cz','C4','T8','Tp9',
              'Cp5','Cp1','Cp2','Cp6','Tp10','P7','P3','Pz','P4','P8','O1','Oz','O2']
info = mne.create_info(ch_names=ch_names, sfreq=fs, montage=mne.channels.read_montage(kind='standard_1005'), ch_types=['eeg' for ch in ch_names])
data = np.random.normal(loc=0, scale=0.00001, size=(5000, len(info["ch_names"])))
raw = mne.io.RawArray(data.T, info)
#raw.plot()
#plt.show()

# create cov matrix
noise_cov = mne.compute_raw_covariance(raw)
mne.viz.plot_cov(noise_cov, raw.info)

# forward solution
fname_fwd = sample.data_path() + '/MEG/sample/sample_audvis-meg-oct-6-fwd.fif'
fwd = mne.read_forward_solution(fname_fwd, surf_ori=True)

开发者ID:nikolaims,项目名称:nfb,代码行数:22,代码来源:victory.py

示例13: BSD

          :ref:`ch_morph`.
"""
# Author: Tommy Clausner <[email protected]>
#
# License: BSD (3-clause)
import os

import mne
from mne.datasets import sample

print(__doc__)

###############################################################################
# Setup paths

sample_dir_raw = sample.data_path()
sample_dir = os.path.join(sample_dir_raw, 'MEG', 'sample')
subjects_dir = os.path.join(sample_dir_raw, 'subjects')

fname_stc = os.path.join(sample_dir, 'sample_audvis-meg')

###############################################################################
# Load example data

# Read stc from file
stc = mne.read_source_estimate(fname_stc, subject='sample')

###############################################################################
# Setting up SourceMorph for SourceEstimate
# -----------------------------------------
#
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:31,代码来源:plot_morph_surface_stc.py

示例14: print

import os.path as op

from mayavi import mlab

import mne
from mne.io import read_raw_fif, read_raw_ctf, read_raw_bti, read_raw_kit
from mne.io import read_raw_artemis123
from mne.datasets import sample, spm_face, testing
from mne.viz import plot_alignment

print(__doc__)

bti_path = op.abspath(op.dirname(mne.__file__)) + '/io/bti/tests/data/'
kit_path = op.abspath(op.dirname(mne.__file__)) + '/io/kit/tests/data/'
raws = {
    'Neuromag': read_raw_fif(sample.data_path() +
                             '/MEG/sample/sample_audvis_raw.fif'),
    'CTF 275': read_raw_ctf(spm_face.data_path() +
                            '/MEG/spm/SPM_CTF_MEG_example_faces1_3D.ds'),
    'Magnes 3600wh': read_raw_bti(op.join(bti_path, 'test_pdf_linux'),
                                  op.join(bti_path, 'test_config_linux'),
                                  op.join(bti_path, 'test_hs_linux')),
    'KIT': read_raw_kit(op.join(kit_path, 'test.sqd')),
    'Artemis123': read_raw_artemis123(op.join(
        testing.data_path(), 'ARTEMIS123',
        'Artemis_Data_2017-04-14-10h-38m-59s_Phantom_1k_HPI_1s.bin')),
}

for system, raw in sorted(raws.items()):
    meg = ['helmet', 'sensors']
    # We don't have coil definitions for KIT refs, so exclude them
开发者ID:SherazKhan,项目名称:mne-python,代码行数:31,代码来源:plot_meg_sensors.py

示例15:

from nose.tools import assert_true
import nose
import copy

from mne.datasets import sample
from mne.label import read_label, label_sign_flip
from mne.event import read_events
from mne.epochs import Epochs
from mne.source_estimate import read_source_estimate
from mne import fiff, read_cov, read_forward_solution
from mne.minimum_norm.inverse import apply_inverse, read_inverse_operator, \
    apply_inverse_raw, apply_inverse_epochs, make_inverse_operator, \
    write_inverse_operator

examples_folder = op.join(op.dirname(__file__), '..', '..', '..', 'examples')
s_path = op.join(sample.data_path(examples_folder), 'MEG', 'sample')
fname_inv = op.join(s_path, 'sample_audvis-meg-oct-6-meg-inv.fif')
fname_inv_fixed = op.join(s_path, 'sample_audvis-meg-oct-6-meg-fixed-inv.fif')
fname_vol_inv = op.join(s_path, 'sample_audvis-meg-vol-7-meg-inv.fif')
fname_data = op.join(s_path, 'sample_audvis-ave.fif')
fname_cov = op.join(s_path, 'sample_audvis-cov.fif')
fname_fwd = op.join(s_path, 'sample_audvis-meg-oct-6-fwd.fif')
fname_raw = op.join(s_path, 'sample_audvis_filt-0-40_raw.fif')
fname_event = op.join(s_path, 'sample_audvis_filt-0-40_raw-eve.fif')
fname_label = op.join(s_path, 'labels', '%s.label')

inverse_operator = read_inverse_operator(fname_inv)
inverse_operator_fixed = read_inverse_operator(fname_inv_fixed)
inverse_operator_vol = read_inverse_operator(fname_vol_inv)
label_lh = read_label(fname_label % 'Aud-lh')
label_rh = read_label(fname_label % 'Aud-rh')
开发者ID:starzynski,项目名称:mne-python,代码行数:31,代码来源:test_inverse.py


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