|
4 | 4 |
|
5 | 5 | import numpy as np
|
6 | 6 |
|
| 7 | +from nibabel.gifti import giftiio |
| 8 | + |
| 9 | +from .test_giftiio import (DATA_FILE1, DATA_FILE2, DATA_FILE3, DATA_FILE4, |
| 10 | + DATA_FILE5, DATA_FILE6) |
7 | 11 | from ..gifti import (GiftiImage, GiftiDataArray, GiftiLabel, GiftiLabelTable,
|
8 | 12 | GiftiMetaData)
|
9 | 13 | from ...nifti1 import data_type_codes, intent_codes
|
10 |
| - |
| 14 | +from ...testing import clear_and_catch_warnings |
11 | 15 | from numpy.testing import (assert_array_almost_equal,
|
12 | 16 | assert_array_equal)
|
13 | 17 | from nose.tools import (assert_true, assert_false, assert_equal, assert_raises)
|
14 |
| -from ...testing import clear_and_catch_warnings |
15 | 18 |
|
16 | 19 |
|
17 | 20 | def test_gifti_image():
|
@@ -77,11 +80,6 @@ def test_labeltable():
|
77 | 80 | img.labeltable = new_table
|
78 | 81 | assert_equal(len(img.labeltable.labels), 2)
|
79 | 82 |
|
80 |
| - # Try to set to non-table |
81 |
| - def assign_labeltable(val): |
82 |
| - img.labeltable = val |
83 |
| - assert_raises(ValueError, assign_labeltable, 'not-a-table') |
84 |
| - |
85 | 83 |
|
86 | 84 | def test_metadata():
|
87 | 85 | # Test deprecation
|
@@ -127,3 +125,41 @@ def assign_rgba(gl, val):
|
127 | 125 | gl4 = GiftiLabel()
|
128 | 126 | assert_equal(len(gl4.rgba), 4)
|
129 | 127 | assert_true(np.all([elem is None for elem in gl4.rgba]))
|
| 128 | + |
| 129 | + |
| 130 | +def test_print_summary(): |
| 131 | + for fil in [DATA_FILE1, DATA_FILE2, DATA_FILE3, DATA_FILE4, |
| 132 | + DATA_FILE5, DATA_FILE6]: |
| 133 | + gimg = giftiio.read(fil) |
| 134 | + gimg.print_summary() |
| 135 | + |
| 136 | + |
| 137 | +def test_gifti_coord(): |
| 138 | + from ..gifti import GiftiCoordSystem |
| 139 | + gcs = GiftiCoordSystem() |
| 140 | + assert_true(gcs.xform is not None) |
| 141 | + |
| 142 | + # Smoke test |
| 143 | + gcs.xform = None |
| 144 | + gcs.print_summary() |
| 145 | + gcs.to_xml() |
| 146 | + |
| 147 | + |
| 148 | +def test_gifti_image(): |
| 149 | + img = GiftiImage() |
| 150 | + assert_true(img.darrays is not None) |
| 151 | + assert_true(img.meta is not None) |
| 152 | + assert_true(img.labeltable is not None) |
| 153 | + |
| 154 | + # Try to set a non-data-array |
| 155 | + assert_raises(TypeError, img.add_gifti_data_array, 'not-a-data-array') |
| 156 | + |
| 157 | + # Try to set to non-table |
| 158 | + def assign_labeltable(val): |
| 159 | + img.labeltable = val |
| 160 | + assert_raises(TypeError, assign_labeltable, 'not-a-table') |
| 161 | + |
| 162 | + # Try to set to non-table |
| 163 | + def assign_metadata(val): |
| 164 | + img.meta = val |
| 165 | + assert_raises(TypeError, assign_metadata, 'not-a-meta') |
0 commit comments