This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from os.path import join | |
from sklearn.utils import Bunch | |
from nilearn import datasets | |
from nilearn.datasets.utils import _get_dataset_dir, _fetch_files | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Download atlas with this link https://neurovault.org/images/23262/ | |
import numpy as np | |
import nibabel | |
from nilearn import image | |
labels_data = nibabel.load('aparcaseg.nii.gz').get_fdata() | |
unique_labels = np.unique(labels_data) | |
# Append each image to concat in 4th dimension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Merge two atlases, cortical and sub-cortical atlases dispatched from | |
Harvard Oxford | |
""" | |
import numpy as np | |
from nilearn import datasets | |
cortical = datasets.fetch_atlas_harvard_oxford( | |
atlas_name='cort-maxprob-thr25-2mm', symmetric_split=True) | |
sub_cortical = datasets.fetch_atlas_harvard_oxford( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Utilities developed based on Nilearn | |
""" | |
import collections | |
import warnings | |
import numpy as np | |
import pandas as pd | |
from sklearn.datasets.base import Bunch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""Processing pipeline example for resting state fMRI datasets | |
""" | |
import os | |
import numpy as np | |
import pandas as pd | |
from sklearn.neighbors import KNeighborsClassifier | |
from sklearn.naive_bayes import GaussianNB | |
from sklearn.ensemble import RandomForestClassifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from nilearn import masking | |
from nilearn import signal, _utils | |
from nilearn.image import high_variance_confounds, resample_img, new_img_like | |
from nilearn._utils.compat import get_affine | |
from nilearn._utils.niimg_conversions import _check_same_fov | |
def compute_confounds(imgs, mask_img, n_confounds=5, get_randomized_svd=False, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Plot Brain rois per each atlas across datasets | |
""" | |
########################################################################### | |
# Brain ROIs path | |
import os | |
rois_path = 'BrainROIs' | |
dataset_paths = dict() | |
dataset_names = ['ADNI'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Small example with issue #1522 in Nilearn | |
""" | |
from nilearn import datasets | |
# Functional data - 2 subjects | |
adhd = datasets.fetch_adhd(n_subjects=2) | |
# Harvard Oxford atlas | |
atlas_data = datasets.fetch_atlas_harvard_oxford(atlas_name='cort-maxprob-thr25-2mm') | |
labels_img = atlas_data.maps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nilearn import datasets | |
# AAL | |
aal = datasets.fetch_atlas_aal() | |
atlas_img = aal.maps | |
# Structural data | |
dataset_files = datasets.fetch_oasis_vbm(n_subjects=5) | |
# Grab each ROI | |
rois = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Functions to plot connectivity matrices, either as a square or circular. | |
""" | |
import numbers | |
import collections | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from nilearn._utils.compat import _basestring |