本文整理汇总了Python中nilearn.datasets.fetch_adhd函数的典型用法代码示例。如果您正苦于以下问题:Python fetch_adhd函数的具体用法?Python fetch_adhd怎么用?Python fetch_adhd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fetch_adhd函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fetch_adhd
def test_fetch_adhd():
local_url = "file://" + datadir
sub1 = [3902469, 7774305, 3699991]
sub2 = [2014113, 4275075, 1019436,
3154996, 3884955, 27034,
4134561, 27018, 6115230,
27037, 8409791, 27011]
sub3 = [3007585, 8697774, 9750701,
10064, 21019, 10042,
10128, 2497695, 4164316,
1552181, 4046678, 23012]
sub4 = [1679142, 1206380, 23008,
4016887, 1418396, 2950754,
3994098, 3520880, 1517058,
9744150, 1562298, 3205761, 3624598]
subs = np.asarray(sub1 + sub2 + sub3 + sub4)
subs = subs.view(dtype=[('Subject', '<i8')])
file_mock.add_csv('ADHD200_40subs_motion_parameters_and_phenotypics.csv',
subs)
adhd = datasets.fetch_adhd(data_dir=tmpdir, url=local_url,
n_subjects=12, verbose=0)
assert_equal(len(adhd.func), 12)
assert_equal(len(adhd.confounds), 12)
assert_equal(len(url_request.urls), 13) # Subjects + phenotypic
示例2: run_mini_pipeline
def run_mini_pipeline():
atlas = datasets.fetch_atlas_msdl()
atlas_img = atlas['maps']
labels = pd.read_csv(atlas['labels'])['name']
masker = NiftiMapsMasker(maps_img=atlas_img, standardize=True,
memory='/tmp/nilearn', verbose=0)
data = datasets.fetch_adhd(number_subjects)
figures_folder = '../figures/'
count=0
for func_file, confound_file in zip(data.func, data.confounds):
# fit the data to the atlas mask, regress out confounds
time_series = masker.fit_transform(func_file, confounds=confound_file)
correlation = np.corrcoef(time_series.T)
#plotting starts here
plt.figure(figsize=(10, 10))
plt.imshow(correlation, interpolation="nearest")
x_ticks = plt.xticks(range(len(labels)), labels, rotation=90)
y_ticks = plt.yticks(range(len(labels)), labels)
corr_file = figures_folder+'subject_number_' + str(count) + '_correlation.pdf'
plt.savefig(corr_file)
atlas_region_coords = [plotting.find_xyz_cut_coords(img) for img in image.iter_img(atlas_img)]
threshold = 0.6
plotting.plot_connectome(correlation, atlas_region_coords, edge_threshold=threshold)
connectome_file = figures_folder+'subject_number_' + str(count) + '_connectome.pdf'
plt.savefig(connectome_file)
#graph setup
#binarize correlation matrix
correlation[correlation<threshold] = 0
correlation[correlation != 0] = 1
graph = nx.from_numpy_matrix(correlation)
partition=louvain.best_partition(graph)
values = [partition.get(node) for node in graph.nodes()]
plt.figure()
nx.draw_spring(graph, cmap = plt.get_cmap('jet'), node_color = values, node_size=30, with_labels=True)
graph_file = figures_folder+'subject_number_' + str(count) + '_community.pdf'
plt.savefig(graph_file)
count += 1
plt.close('all')
示例3: run_canica
def run_canica(params):
"""CanICA
Perform Canonical Independent Component Analysis.
Parameters
----------
n_components: (20) number of components
smoothing_fwhm: (6.) smoothing fwhm
threshold: (3.) specify threshold
verbose: (['10', '0', '10']) select verbosity level
input_folder: (folder) select input folder
output_folder: (folder) define ouput folder
References
----------
* G. Varoquaux et al. "A group model for stable multi-subject ICA on
fMRI datasets", NeuroImage Vol 51 (2010), p. 288-299
* G. Varoquaux et al. "ICA-based sparse features recovery from fMRI
datasets", IEEE ISBI 2010, p. 1177
"""
dataset = datasets.fetch_adhd()
func_files = dataset.func
output_dir = osp.abspath(params.pop('output_folder'))
prepare_report_directory(output_dir)
run(func_files, params, output_dir)
json.dump(params, open(osp.join(output_dir, 'params.json'), 'w'))
img_src_filenames = [osp.join(output_dir, 'images', fname) for fname in
os.listdir(osp.join(output_dir, 'images'))
if fname.startswith('IC_')]
report = generate_report(params, img_src_filenames)
reportindex = osp.abspath(osp.join(output_dir, 'index.html'))
report.save_html(reportindex)
return ('file', 'file://{}'.format(reportindex))
示例4: print
plt.title("%s / covariance" % title)
# Display precision matrix
plt.figure()
plt.imshow(prec, interpolation="nearest",
vmin=-span, vmax=span,
cmap=plotting.cm.bwr)
plt.colorbar()
plt.title("%s / precision" % title)
# Fetching datasets ###########################################################
print("-- Fetching datasets ...")
from nilearn import datasets
msdl_atlas_dataset = datasets.fetch_msdl_atlas()
adhd_dataset = datasets.fetch_adhd(n_subjects=1)
# Extracting region signals ###################################################
import nilearn.image
import nilearn.input_data
from sklearn.externals.joblib import Memory
mem = Memory('nilearn_cache')
masker = nilearn.input_data.NiftiMapsMasker(
msdl_atlas_dataset.maps, resampling_target="maps", detrend=True,
low_pass=None, high_pass=0.01, t_r=2.5, standardize=True,
memory=mem, memory_level=1, verbose=2)
masker.fit()
示例5: print
"""
####################################################################
# Load atlases
# -------------
from nilearn import datasets
yeo = datasets.fetch_atlas_yeo_2011()
print('Yeo atlas nifti image (3D) with 17 parcels and liberal mask is located '
'at: %s' % yeo['thick_17'])
#########################################################################
# Load functional data
# --------------------
data = datasets.fetch_adhd(n_subjects=10)
print('Functional nifti images (4D, e.g., one subject) are located at : %r'
% data['func'][0])
print('Counfound csv files (of same subject) are located at : %r'
% data['confounds'][0])
##########################################################################
# Extract coordinates on Yeo atlas - parcellations
# ------------------------------------------------
from nilearn.input_data import NiftiLabelsMasker
from nilearn.connectome import ConnectivityMeasure
# ConenctivityMeasure from Nilearn uses simple 'correlation' to compute
# connectivity matrices for all subjects in a list
connectome_measure = ConnectivityMeasure(kind='correlation')
示例6:
* G. Varoquaux et al. "A group model for stable multi-subject ICA on
fMRI datasets", NeuroImage Vol 51 (2010), p. 288-299
* G. Varoquaux et al. "ICA-based sparse features recovery from fMRI
datasets", IEEE ISBI 2010, p. 1177
Pre-prints for both papers are available on hal
(http://hal.archives-ouvertes.fr)
"""
import numpy as np
### Load ADHD rest dataset ####################################################
from nilearn import datasets
# Here we use a limited number of subjects to get faster-running code. For
# better results, simply increase the number.
dataset = datasets.fetch_adhd()
func_files = dataset.func[:5]
### Preprocess ################################################################
from nilearn import io
# This is a multi-subject method, thus we need to use the
# MultiNiftiMasker, rather than the NiftiMasker
# We specify the target_affine to downsample to 3mm isotropic
# resolution
masker = io.MultiNiftiMasker(smoothing_fwhm=6,
target_affine=np.diag((3, 3, 3)),
memory="nilearn_cache", memory_level=1,
verbose=True)
data_masked = masker.fit_transform(func_files)
示例7: interest
matrix = matrix.copy() # avoid side effects
# Set diagonal to zero, for better visualization
np.fill_diagonal(matrix, 0)
vmax = np.max(np.abs(matrix))
title = '{0}, subject {1}'.format(matrix_kind, n_subject)
plotting.plot_matrix(matrix, vmin=-vmax, vmax=vmax, cmap='RdBu_r',
title=title, figure=fig, colorbar=False)
###############################################################################
# Load ADHD dataset and MSDL atlas
# --------------------------------
# We study only 20 subjects from the ADHD dataset, to save computation time.
from nilearn import datasets
adhd_data = datasets.fetch_adhd(n_subjects=20)
###############################################################################
# We use probabilistic regions of interest (ROIs) from the MSDL atlas.
msdl_data = datasets.fetch_atlas_msdl()
msdl_coords = msdl_data.region_coords
n_regions = len(msdl_coords)
print('MSDL has {0} ROIs, part of the following networks :\n{1}.'.format(
n_regions, msdl_data.networks))
###############################################################################
# Region signals extraction
# -------------------------
# To extract regions time series, we instantiate a
# :class:`nilearn.input_data.NiftiMapsMasker` object and pass the atlas the
# file name to it, as well as filtering band-width and detrending option.