2
from os.path import join as pjoin
4
from nose.tools import assert_true
6
from numpy.testing import assert_equal
8
from .. import read_geometry, read_morph_data, read_annot, read_label
11
have_freesurfer = True
12
if 'SUBJECTS_DIR' not in os.environ:
13
# Test suite relies on the definition of SUBJECTS_DIR
14
have_freesurfer = False
16
freesurfer_test = np.testing.dec.skipif(not have_freesurfer,
17
'SUBJECTS_DIR not set')
20
subj_dir = os.environ["SUBJECTS_DIR"]
21
subject_id = 'fsaverage'
22
data_path = pjoin(subj_dir, subject_id)
27
"""Test IO of .surf"""
28
surf_path = pjoin(data_path, "surf", "%s.%s" % ("lh", "inflated"))
29
coords, faces = read_geometry(surf_path)
30
assert_equal(0, faces.min())
31
assert_equal(coords.shape[0], faces.max() + 1)
33
# Test quad with sphere
34
surf_path = pjoin(data_path, "surf", "%s.%s" % ("lh", "sphere"))
35
coords, faces = read_geometry(surf_path)
36
assert_equal(0, faces.min())
37
assert_equal(coords.shape[0], faces.max() + 1)
41
def test_morph_data():
42
"""Test IO of morphometry data file (eg. curvature)."""
43
curv_path = pjoin(data_path, "surf", "%s.%s" % ("lh", "curv"))
44
curv = read_morph_data(curv_path)
45
assert_true(-1.0 < curv.min() < 0)
46
assert_true(0 < curv.max() < 1.0)
51
"""Test IO of .annot"""
52
annots = ['aparc', 'aparc.a2005s']
54
annot_path = pjoin(data_path, "label", "%s.%s.annot" % ("lh", a))
55
labels, ctab, names = read_annot(annot_path)
56
assert_true(labels.shape == (163842, ))
57
assert_true(ctab.shape == (len(names), 5))
62
"""Test IO of .label"""
63
label_path = pjoin(data_path, "label", "lh.BA1.label")
64
label = read_label(label_path)
66
assert_true(np.all(label > 0))