コード例 #1
0
ファイル: test_datasets.py プロジェクト: ja-che/nistats
def test_fetch_spm_multimodal():
    data_dir = os.path.join(tst.tmpdir, 'spm_multimodal_fmri')
    os.mkdir(data_dir)
    subject_dir = os.path.join(data_dir, 'sub001')
    os.mkdir(subject_dir)
    os.mkdir(os.path.join(subject_dir, 'fMRI'))
    os.mkdir(os.path.join(subject_dir, 'sMRI'))
    open(os.path.join(subject_dir, 'sMRI', 'smri.img'), 'a').close()
    for session in [0, 1]:
        open(
            os.path.join(subject_dir, 'fMRI',
                         'trials_ses%i.mat' % (session + 1)), 'a').close()
        dir_ = os.path.join(subject_dir, 'fMRI', 'Session%d' % (session + 1))
        os.mkdir(dir_)
        for i in range(390):
            open(
                os.path.join(dir_,
                             'fMETHODS-000%i-%i-01.img' % (session + 5, i)),
                'a').close()

    dataset = datasets.fetch_spm_multimodal_fmri(data_dir=tst.tmpdir)
    assert_true(isinstance(dataset.anat, _basestring))
    assert_true(isinstance(dataset.func1[0], _basestring))
    assert_equal(len(dataset.func1), 390)
    assert_true(isinstance(dataset.func2[0], _basestring))
    assert_equal(len(dataset.func2), 390)
    assert_equal(dataset.slice_order, 'descending')
    assert_true(dataset.trials_ses1, _basestring)
    assert_true(dataset.trials_ses2, _basestring)
コード例 #2
0
ファイル: test_datasets.py プロジェクト: Ziaeemehr/nistats
def test_fetch_spm_multimodal(request_mocker, tmp_path):
    data_dir = str(tmp_path / 'spm_multimodal_fmri')
    os.mkdir(data_dir)
    subject_dir = os.path.join(data_dir, 'sub001')
    os.mkdir(subject_dir)
    os.mkdir(os.path.join(subject_dir, 'fMRI'))
    os.mkdir(os.path.join(subject_dir, 'sMRI'))
    open(os.path.join(subject_dir, 'sMRI', 'smri.img'), 'a').close()
    for session in [0, 1]:
        open(os.path.join(subject_dir, 'fMRI',
                          'trials_ses%i.mat' % (session + 1)), 'a').close()
        dir_ = os.path.join(subject_dir, 'fMRI', 'Session%d' % (session + 1))
        os.mkdir(dir_)
        for i in range(390):
            open(os.path.join(dir_, 'fMETHODS-000%i-%i-01.img' %
                              (session + 5, i)), 'a').close()

    dataset = datasets.fetch_spm_multimodal_fmri(data_dir=str(tmp_path))
    assert isinstance(dataset.anat, _basestring)
    assert isinstance(dataset.func1[0], _basestring)
    assert len(dataset.func1) == 390
    assert isinstance(dataset.func2[0], _basestring)
    assert len(dataset.func2) == 390
    assert dataset.slice_order == 'descending'
    assert isinstance(dataset.trials_ses1, _basestring)
    assert isinstance(dataset.trials_ses2, _basestring)
コード例 #3
0
ファイル: test_datasets.py プロジェクト: aabadie/nistats
def test_fetch_spm_multimodal():
    dataset = datasets.fetch_spm_multimodal_fmri(data_dir=tmpdir)
    assert_true(isinstance(dataset.anat, _basestring))
    assert_true(isinstance(dataset.func1[0], _basestring))
    assert_equal(len(dataset.func1), 390)
    assert_true(isinstance(dataset.func2[0], _basestring))
    assert_equal(len(dataset.func2), 390)
    assert_equal(dataset.slice_order, "descending")
    assert_true(dataset.trials_ses1, _basestring)
    assert_true(dataset.trials_ses2, _basestring)
コード例 #4
0
ファイル: test_datasets.py プロジェクト: shanyu329/nistats
def test_fetch_spm_multimodal():
    dataset = datasets.fetch_spm_multimodal_fmri(data_dir=tmpdir)
    assert_true(isinstance(dataset.anat, _basestring))
    assert_true(isinstance(dataset.func1[0], _basestring))
    assert_equal(len(dataset.func1), 390)
    assert_true(isinstance(dataset.func2[0], _basestring))
    assert_equal(len(dataset.func2), 390)
    assert_equal(dataset.slice_order, 'descending')
    assert_true(dataset.trials_ses1, _basestring)
    assert_true(dataset.trials_ses2, _basestring)
コード例 #5
0
Henson, R.N., Goshen-Gottstein, Y., Ganel, T., Otten, L.J., Quayle, A.,
Rugg, M.D. Electrophysiological and haemodynamic correlates of face
perception, recognition and priming. Cereb Cortex. 2003 Jul;13(7):793-805.
http://www.dx.doi.org/10.1093/cercor/13.7.793

This example takes a lot of time because the input are lists of 3D images
sampled in different position (encoded by different) affine functions.

"""

print(__doc__)

#########################################################################
# Fetch spm multimodal_faces data
from nistats.datasets import fetch_spm_multimodal_fmri
subject_data = fetch_spm_multimodal_fmri()

#########################################################################
# Timing and design matrix parameter specification
tr = 2.  # repetition time, in seconds
slice_time_ref = 0.  # we will sample the design matrix at the beggining of each acquisition
drift_model = 'Cosine'  # We use a discrete cosin transform to model signal drifts.
period_cut = 128.  # The cutoff for the drift model is 1/128 Hz.
hrf_model = 'spm + derivative'  # The hemodunamic response finction is the SPM canonical one

#########################################################################
# Resample the images.
#
# This is achieved by the concat_imgs function of Nilearn.
from nilearn.image import concat_imgs, resample_img, mean_img
fmri_img = [
コード例 #6
0
Rugg, M.D. Electrophysiological and haemodynamic correlates of face
perception, recognition and priming. Cereb Cortex. 2003 Jul;13(7):793-805.
http://www.dx.doi.org/10.1093/cercor/13.7.793

This example takes a lot of time because the input are lists of 3D images
sampled in different position (encoded by different) affine functions.

"""

print(__doc__)


#########################################################################
# Fetch spm multimodal_faces data
from nistats.datasets import fetch_spm_multimodal_fmri
subject_data = fetch_spm_multimodal_fmri()

#########################################################################
# Timing and design matrix parameter specification
tr = 2.  # repetition time, in seconds
slice_time_ref = 0.  # we will sample the design matrix at the beggining of each acquisition
drift_model = 'Cosine'  # We use a discrete cosin transform to model signal drifts.
period_cut = 128.  # The cutoff for the drift model is 1/128 Hz.
hrf_model = 'spm + derivative'  # The hemodunamic response finction is the SPM canonical one

#########################################################################
# Resample the images.
#
# This is achieved by the concat_imgs function of Nilearn.
from nilearn.image import concat_imgs, resample_img, mean_img
fmri_img = [concat_imgs(subject_data.func1, auto_resample=True),