def get_nilearn_adhd_data(n_subjects, nilearn_download_dir): # Load the functional datasets datasets.get_data_dirs(data_dir=nilearn_download_dir) adhd_data = datasets.fetch_adhd(n_subjects=n_subjects, data_dir=nilearn_download_dir) msdl_data = datasets.fetch_atlas_msdl(data_dir=nilearn_download_dir) masker = input_data.NiftiMapsMasker(msdl_data.maps, resampling_target="data", t_r=2.5, detrend=True, low_pass=.1, high_pass=.01, memory='nilearn_cache', memory_level=1) pooled_subjects = [] adhd_labels = [] # 1 if ADHD, 0 if control age = [] for func_file, confound_file, phenotypic in zip(adhd_data.func, adhd_data.confounds, adhd_data.phenotypic): time_series = masker.fit_transform(func_file, confounds=confound_file) pooled_subjects.append(time_series) adhd_labels.append(phenotypic['adhd']) age.append(phenotypic['age']) correlation_measure = ConnectivityMeasure(kind='correlation') corr_mat = correlation_measure.fit_transform(pooled_subjects) print('Correlations are stacked in an array of shape {0}'.format( corr_mat.shape)) beh = np.zeros((n_subjects, 2)) beh[:, 0] = adhd_labels beh[:, 1] = age return corr_mat, beh
Also, see :func:`nilearn.datasets.fetch_neurovault_motor_task` for details about the plotting data and associated meta-data. """ ############################################################################### # Retrieve the data # ------------------ # # Nilearn comes with set of functions that download public data from Internet # # Let us first see where the data will be downloaded and stored on our disk: # from nilearn import datasets print('Datasets shipped with nilearn are stored in: %r' % datasets.get_data_dirs()) ############################################################################### # Let us now retrieve a motor task contrast map # corresponding to a group one-sample t-test motor_images = datasets.fetch_neurovault_motor_task() stat_img = motor_images.images[0] # stat_img is just the name of the file that we downloaded stat_img ############################################################################### # Demo glass brain plotting # -------------------------- # # By default, :func:`~nilearn.plotting.plot_glass_brain` uses a display mode
""" 3D and 4D niimgs: handling and visualizing ========================================== Here we discover how to work with 3D and 4D niimgs. """ ############################################################################### # Downloading tutorial datasets from Internet # -------------------------------------------- # # Nilearn comes with functions that download public data from Internet # # Let's first check where the data is downloaded on our disk: from nilearn import datasets print('Datasets are stored in: %r' % datasets.get_data_dirs()) ############################################################################### # Let's now retrieve a motor contrast from a Neurovault repository motor_images = datasets.fetch_neurovault_motor_task() print(motor_images.images) ############################################################################### # motor_images is a list of filenames. We need to take the first one tmap_filename = motor_images.images[0] ############################################################################### # Visualizing a 3D file # ---------------------- # # The file contains a 3D volume, we can easily visualize it as a
""" 3D and 4D niimgs: handling and visualizing ========================================== Here we discover how to work with 3D and 4D niimgs. """ ############################################################################### # Downloading tutorial datasets from Internet # -------------------------------------------- # # Nilearn comes with functions that download public data from Internet # # Let's first check where the data is downloaded on our disk: from nilearn import datasets print('Datasets are stored in: %r' % datasets.get_data_dirs()) ############################################################################### # Let's now retrieve a motor contrast from a localizer experiment tmap_filenames = datasets.fetch_localizer_button_task()['tmaps'] print(tmap_filenames) ############################################################################### # tmap_filenames is a list of filenames. We need to take the first one tmap_filename = tmap_filenames[0] ############################################################################### # Visualizing a 3D file # ---------------------- #
plt.savefig('/Users/pinheirochagas/Desktop/chan_dist.png') plt.savefig('/Users/pinheirochagas/Desktop/connectivity_plot_memoria_ies.png') from nilearn import datasets print('Datasets shipped with nilearn are stored in: %r' % datasets.get_data_dirs()) motor_images = datasets.fetch_neurovault_motor_task() stat_img = motor_images.images[0] from nilearn import plotting
Also, see :func:`nilearn.datasets.fetch_neurovault_motor_task` for details about the plotting data and associated meta-data. """ ############################################################################### # Retrieve the data # ------------------ # # Nilearn comes with set of functions that download public data from Internet # # Let us first see where the data will be downloded and stored on our disk: # from nilearn import datasets print('Datasets shipped with nilearn are stored in: %r' % datasets.get_data_dirs()) ############################################################################### # Let us now retrieve a motor task contrast map # corresponding to a group one-sample t-test motor_images = datasets.fetch_neurovault_motor_task() stat_img = motor_images.images[0] # stat_img is just the name of the file that we downloded print(stat_img) ############################################################################### # Demo glass brain plotting # -------------------------- from nilearn import plotting