@author: [email protected]
"""
import os, glob
import numpy as np
import matplotlib.pyplot as plt
from nilearn.plotting import plot_stat_map, plot_roi
from nilearn.image import index_img
from fetch_data import fetch_adni_masks, array_to_niis, array_to_nii
from scipy.ndimage import label
from matplotlib import cm
import nibabel as nib
from fetch_data import set_cache_base_dir
from joblib import Parallel, delayed

base_dir = os.path.join(set_cache_base_dir(), 'decomposition')
mask = fetch_adni_masks()['mask_petmr']
mask_shape = nib.load(mask).shape
mask_affine = nib.load(mask).get_affine()
np_files = os.listdir(base_dir)


def extract_region_i(maps, i):
    """ Extract ROIs and plot
    """
    m = maps[i, ...]
    th_value = np.percentile(m, 100. - (100. / 42.))
    data = np.absolute(array_to_nii(m, mask).get_data())
    data[data <= th_value] = 0
    data[data > th_value] = 1
    data_lab = label(data)[0]
Esempio n. 2
0
"""

import os, sys
import numpy as np
from fetch_data import fetch_adni_baseline_rs_fmri, fetch_adni_masks, \
                        fetch_adni_longitudinal_rs_fmri_DARTEL, set_cache_base_dir
from base_connectivity_classifier import ConnectivityClassifier

#sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
#sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)

CACHE_DIR = set_cache_base_dir()

#dataset = fetch_adni_baseline_rs_fmri()
dataset = fetch_adni_longitudinal_rs_fmri_DARTEL()
mask = fetch_adni_masks()['mask_fmri']

all_groups = [['AD', 'MCI'], ['AD', 'Normal'], ['MCI', 'Normal']]

atlas_names = [
    'msdl', 'canica141', 'canica', 'mayo', 'harvard_oxford', 'juelich',
    'tvmsdl'
]

classifier_names = ['ridge', 'svc_l1', 'svc_l2', 'logreg_l1', 'logreg_l2']

conn_names = ['corr', 'correlation', 'tangent', 'gl', 'lw', 'oas', 'scov']

###
atlas_names = ['mayo']  #, 'msdl', 'canica']
classifier_names = ['svc_l2', 'logreg_l2']