本文整理汇总了Python中nilearn.datasets.fetch_haxby_simple函数的典型用法代码示例。如果您正苦于以下问题:Python fetch_haxby_simple函数的具体用法?Python fetch_haxby_simple怎么用?Python fetch_haxby_simple使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fetch_haxby_simple函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fetch_haxby_simple
def test_fetch_haxby_simple():
local_url = "file://" + os.path.join(datadir, "pymvpa-exampledata.tar.bz2")
haxby = datasets.fetch_haxby_simple(data_dir=tmpdir, url=local_url,
verbose=0)
datasetdir = os.path.join(tmpdir, 'haxby2001_simple', 'pymvpa-exampledata')
for key, file in [
('session_target', 'attributes.txt'),
('func', 'bold.nii.gz'),
('mask', 'mask.nii.gz'),
('conditions_target', 'attributes_literal.txt')]:
assert_equal(haxby[key], os.path.join(datasetdir, file))
assert_true(os.path.exists(os.path.join(datasetdir, file)))
示例2:
"""
The haxby dataset: different multi-class strategies
=======================================================
We compare one vs all and one vs one multi-class strategies: the overall
cross-validated accuracy and the confusion matrix.
"""
# Import matplotlib for plotting
from matplotlib import pyplot as plt
### Load Haxby dataset ########################################################
from nilearn import datasets
import numpy as np
dataset_files = datasets.fetch_haxby_simple()
# fmri_data and mask are copied to break any reference to the original object
y, session = np.loadtxt(dataset_files.session_target).astype("int").T
conditions = np.recfromtxt(dataset_files.conditions_target)['f0']
# Remove the rest condition, it is not very interesting
non_rest = conditions != 'rest'
conditions = conditions[non_rest]
y = y[non_rest]
session = session[non_rest]
# Get the labels of the numerical conditions represented by the vector y
unique_conditions, order = np.unique(conditions, return_index=True)
# Sort the conditions by the order of appearance
unique_conditions = unique_conditions[np.argsort(order)]
示例3: image
[2] Anderson, M. J. & Robinson, J. (2001).
Permutation tests for linear models.
Australian & New Zealand Journal of Statistics, 43(1), 75-88.
(http://avesbiodiv.mncn.csic.es/estadistica/permut2.pdf)
"""
# Author: Virgile Fritsch, <[email protected]>, Feb. 2014
import numpy as np
from scipy import linalg
from nilearn import datasets
from nilearn.input_data import NiftiMasker
from nilearn.mass_univariate import permuted_ols
### Load Haxby dataset ########################################################
haxby_dataset = datasets.fetch_haxby_simple()
# print basic information on the dataset
print('Mask nifti image (3D) is located at: %s' % haxby_dataset.mask)
print('Functional nifti image (4D) is located at: %s' % haxby_dataset.func[0])
### Mask data #################################################################
mask_filename = haxby_dataset.mask
nifti_masker = NiftiMasker(
mask_img=mask_filename,
memory='nilearn_cache', memory_level=1) # cache options
func_filename = haxby_dataset.func[0]
fmri_masked = nifti_masker.fit_transform(func_filename)
### Restrict to faces and houses ##############################################
conditions_encoded, sessions = np.loadtxt(