示例#1
0
def test_fail_fetch_harvard_oxford():
    # specify non-existing atlas item
    assert_raises_regex(ValueError, 'Invalid atlas name',
                        datasets.fetch_harvard_oxford, 'not_inside')

    # specify existing atlas item
    target_atlas = 'cort-maxprob-thr0-1mm'
    target_atlas_fname = 'HarvardOxford-' + target_atlas + '.nii.gz'

    HO_dir = os.path.join(get_tmpdir(), 'harvard_oxford')
    os.mkdir(HO_dir)
    nifti_dir = os.path.join(HO_dir, 'HarvardOxford')
    os.mkdir(nifti_dir)

    target_atlas_nii = os.path.join(nifti_dir, target_atlas_fname)
    datasets.load_mni152_template().to_filename(target_atlas_nii)

    dummy = open(os.path.join(HO_dir, 'HarvardOxford-Cortical.xml'), 'w')
    dummy.write("<?xml version='1.0' encoding='us-ascii'?> "
                "<metadata>"
                "</metadata>")
    dummy.close()

    out_nii, arr = datasets.fetch_harvard_oxford(target_atlas, data_dir=get_tmpdir())

    assert_true(isinstance(nibabel.load(out_nii), nibabel.Nifti1Image))
    assert_true(isinstance(arr, np.ndarray))
    assert_true(len(arr) > 0)
示例#2
0
def test_load_mni152_template():
    # All subjects
    template_nii = datasets.load_mni152_template()
    assert_equal(template_nii.shape, (91, 109, 91))
    assert_equal(template_nii.get_header().get_zooms(), (2.0, 2.0, 2.0))