'IN29', 'IN30', 'IN31', 'IN32', 'IN33', 'IN34', 'IN35', 'IN38', 'IN39',
        'IN40', 'IN41', 'IN42', 'IN43', 'IN45', 'IN46'
    ]

    num_subj = len(subj_list)

    run_number_dict = {
        'move': [3, 5],
        'plan': [3, 4],
        'color': [3, 4],
    }

    runs = run_number_dict[label]

    # load mask file
    mask_img = get_full_mask(data_dir)

    for subj in subj_list:
        print('starting run %s, %s label' % (subj, label))

        for run in runs:
            # load behavioral data
            labels = get_behavior_data(behav_dir,
                                       subj,
                                       run,
                                       label,
                                       stratified_group=True)

            # load fmri file
            img = load_fmri_image(data_dir, subj, run, labels)
    estimator = LinearDiscriminantAnalysis()

    # target, index, run info initialize (in feedback condition)
    info_df = pd.read_csv(
        '/clmnlab/GL/fmri_data/MVPA/behaviors/targetID_fb_GL.tsv',
        delimiter='\t')
    chance_level = 1 / 4

    info_df = info_df[info_df.run.isin(runs)
                      & (info_df.feedback == feedback_on)]
    targets = np.array(info_df['target'])
    indexes = list(info_df['trial'] - 1)
    group = list(info_df['run'])

    # load mask
    mask_img = mtk.get_full_mask('/clmnlab/GL/fmri_data/masks/',
                                 'full_mask.group.nii.gz')

    for subj in subj_list:
        # load t-value fMRI images
        img_list = [
            mtk.load_5d_fmri_image(data_dir + '%s/stats/tvals.%s.r%02d.nii' %
                                   (subj, subj, run)) for run in runs
        ]

        # check image size
        for img in img_list:
            assert img.shape == (96, 114, 96, 145)

        # indexing image
        imgs = nilearn.image.concat_imgs(img_list)
        imgs = nilearn.image.index_img(imgs, indexes)
        'IN35', 'IN38', 'IN39', 'IN40', 'IN41', 'IN42',
        'IN43', 'IN45', 'IN46'
    ]

    num_subj = len(subj_list)

    run_number_dict = {
        'move': [3, 5],
        'plan': [3, 4],
        'color': [3, 4],
    }

    runs = run_number_dict[label]

    # load mask file
    mask_img = mtk.get_full_mask(mask_dir)

    for subj in subj_list:
        print('starting run %s, %s label' % (subj, label))

        labels = [
            mtk.get_behavior_data(behav_dir, subj, run, label)
            for run in runs
        ]

        imgs = [
            nilearn.image.index_img(
                mtk.load_5d_fmri_image(data_dir + 'tvalsLSA.%s.r0%d.nii.gz' % (subj, run)),
                label['order'] - 1)
            for label, run in zip(labels, runs)
        ]
    run_number_dict = {
        'move': [3, 5],
        'plan': [3, 4],
        'color': [3, 4],
    }

    if estimator_name == 'svc':
        estimator = LinearSVC()
    elif estimator_name == 'scaled-svc':
        estimator = Pipeline([('scale', StandardScaler()),
                              ('svc', LinearSVC())])

    roi_labels, roi_masks = mtk.load_rois(mask_dir + '*.nii.gz')

    mask_img = mtk.get_full_mask('/clmnlab/IN/MVPA/LSS_betas/data/')

    num_subj = len(subj_list)
    runs = run_number_dict[label]

    img_data = initial_images()

    prefix = '%s_%s' % (label, estimator_name)

    with open(stats_dir + '%s_roi_accuracies.tsv' % prefix, 'w') as file:
        file.write(('%s\t' * (num_subj + 1) + '%s\n') %
                   ('aal_label', 'mask_size', *subj_list))

    for mask_name, mask in zip(roi_labels, roi_masks):
        scores = perform_analysis()
Ejemplo n.º 5
0
        'GA15', 'GA18', 'GA19', 'GA20', 'GA21', 'GA23', 'GA26', 'GA27', 'GA28',
        'GB01', 'GB02', 'GB05', 'GB07', 'GB08', 'GB11', 'GB12', 'GB13', 'GB14',
        'GB15', 'GB18', 'GB19', 'GB20', 'GB21', 'GB23', 'GB26', 'GB27', 'GB28'
    ]

    num_subj = len(subj_list)
    runs = [1, 2, 3, 4, 5, 6, 7]
    group = [(i // 12) + 1 for i in range(96)]

    # estimator initialize
    if estimator_name == 'lda':
        estimator = LinearDiscriminantAnalysis()
    else:
        raise ValueError('!! %s is unknown estimator name' % estimator_name)

    mask_img = get_full_mask('/clmnlab/GA/MVPA/fullmask_GAGB/',
                             'full_mask.GAGB01to19.nii.gz')

    for subj in subj_list:
        print('starting run %s' % subj)

        for run in runs:
            img = load_5d_fmri_image(data_dir + 'tvals.%s.r%02d.nii.gz' %
                                     (subj, run))
            img = average_N_in_4d_image(img, n=10)
            img = nilearn.image.index_img(img, range(1, 97))

            X = img
            y, chance_level = get_label_list_and_chance_level()

            searchlight_img = run_searchlight(mask_img,
                                              X,