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


Python datasets.fetch_adhd函数代码示例

本文整理汇总了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
开发者ID:amadeuskanaan,项目名称:nilearn,代码行数:26,代码来源:test_datasets.py

示例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')
开发者ID:flrgsr,项目名称:Mini-Pipeline-Community,代码行数:54,代码来源:nilearn_pipeline.py

示例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))
开发者ID:ajrichardson,项目名称:nilearn_ui,代码行数:41,代码来源:run_canica.py

示例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()
开发者ID:andreas-koukorinis,项目名称:gaelvaroquaux.github.io,代码行数:30,代码来源:plot_adhd_covariance.py

示例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')
开发者ID:bthirion,项目名称:nilearn,代码行数:30,代码来源:plot_atlas_comparison.py

示例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)
开发者ID:VincentFrouin,项目名称:nilearn,代码行数:30,代码来源:plot_old_canica_resting_state.py

示例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.
开发者ID:bthirion,项目名称:nilearn,代码行数:31,代码来源:plot_group_level_connectivity.py


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