コード例 #1
0
ファイル: test_utils.py プロジェクト: jeromedockes/nistats
def test_get_design_from_fslmat():
    fsl_mat_path = os.path.join(tst.tmpdir, 'fsl_mat.txt')
    matrix = np.ones((5, 5))
    with open(fsl_mat_path, 'w') as fsl_mat:
        fsl_mat.write('/Matrix\n')
        for row in matrix:
            for val in row:
                fsl_mat.write(str(val) + '\t')
            fsl_mat.write('\n')
    design_matrix = get_design_from_fslmat(fsl_mat_path)
    assert_true(design_matrix.shape == matrix.shape)
コード例 #2
0
def _make_design_matrix_for_bids_feature(data_dir,
                                         subject):  # pragma: no cover
    fsl_design_matrix_path = os.path.join(data_dir, 'derivatives', 'task',
                                          subject, 'stopsignal.feat',
                                          'design.mat')
    design_matrix = get_design_from_fslmat(fsl_design_matrix_path,
                                           column_names=None)

    design_columns = [
        'cond_%02d' % i for i in range(len(design_matrix.columns))
    ]
    design_columns[0] = 'Go'
    design_columns[4] = 'StopSuccess'
    design_matrix.columns = design_columns
    return design_matrix
コード例 #3
0
models, models_run_imgs, models_events, models_confounds = \
    first_level_models_from_bids(
        data_dir, task_label, space_label, smoothing_fwhm=5.0,
        derivatives_folder=derivatives_folder)

#############################################################################
# Access the model and model arguments of the subject and process events.
model, imgs, events, confounds = (models[0], models_run_imgs[0],
                                  models_events[0], models_confounds[0])
subject = 'sub-' + model.subject_label

import os
from nistats.utils import get_design_from_fslmat
fsl_design_matrix_path = os.path.join(data_dir, 'derivatives', 'task', subject,
                                      'stopsignal.feat', 'design.mat')
design_matrix = get_design_from_fslmat(fsl_design_matrix_path,
                                       column_names=None)

#############################################################################
# We identify the columns of the Go and StopSuccess conditions of the
# design matrix inferred from the FSL file, to use them later for contrast
# definition.
design_columns = ['cond_%02d' % i for i in range(len(design_matrix.columns))]
design_columns[0] = 'Go'
design_columns[4] = 'StopSuccess'
design_matrix.columns = design_columns

############################################################################
# First level model estimation (one subject)
# -------------------------------------------
# We fit the first level model for one subject.
model.fit(imgs, design_matrices=[design_matrix])
コード例 #4
0
ファイル: plot_bids_features.py プロジェクト: alpinho/nistats
models, models_run_imgs, models_events, models_confounds = \
    first_level_models_from_bids(
        data_dir, task_label, space_label, smoothing_fwhm=5.0,
        derivatives_folder=derivatives_folder)

#############################################################################
# Take model and model arguments of the subject and process events
model, imgs, events, confounds = (
    models[0], models_run_imgs[0], models_events[0], models_confounds[0])
subject = 'sub-' + model.subject_label

import os
from nistats.utils import get_design_from_fslmat
fsl_design_matrix_path = os.path.join(
    data_dir, 'derivatives', 'task', subject, 'stopsignal.feat', 'design.mat')
design_matrix = get_design_from_fslmat(
    fsl_design_matrix_path, column_names=None)

#############################################################################
# We identify the columns of the Go and StopSuccess conditions of the
# design matrix inferred from the fsl file, to use them later for contrast
# definition.
design_columns = ['cond_%02d' % i for i in range(len(design_matrix.columns))]
design_columns[0] = 'Go'
design_columns[4] = 'StopSuccess'
design_matrix.columns = design_columns

############################################################################
# First level model estimation (one subject)
# -------------------------------------------
# We fit the first level model for one subject.
model.fit(imgs, design_matrices=[design_matrix])