7
7
import nibabel as nib
8
8
from nibabel .externals .six import string_types
9
9
from nibabel .gifti import (GiftiImage , GiftiDataArray , GiftiLabel ,
10
- GiftiLabelTable , GiftiMetaData )
10
+ GiftiLabelTable , GiftiMetaData , GiftiNVPairs )
11
11
from nibabel .gifti .gifti import data_tag
12
12
from nibabel .nifti1 import data_type_codes
13
13
@@ -34,15 +34,24 @@ def test_gifti_image():
34
34
gi = GiftiImage ()
35
35
assert_equal (gi .numDA , 0 )
36
36
37
+ # Test from numpy numeric array
37
38
data = np .random .random ((5 ,))
38
39
da = GiftiDataArray .from_array (data )
39
40
gi .add_gifti_data_array (da )
40
41
assert_equal (gi .numDA , 1 )
41
42
assert_array_equal (gi .darrays [0 ].data , data )
42
43
44
+ # Test removing
43
45
gi .remove_gifti_data_array (0 )
44
46
assert_equal (gi .numDA , 0 )
45
47
48
+ # Test from string
49
+ da = GiftiDataArray .from_array ('zzzzz' )
50
+ gi .add_gifti_data_array (da )
51
+ assert_equal (gi .numDA , 1 )
52
+ assert_array_equal (gi .darrays [0 ].data , data )
53
+
54
+
46
55
# Remove from empty
47
56
gi = GiftiImage ()
48
57
gi .remove_gifti_data_array_by_intent (0 )
@@ -108,6 +117,13 @@ def test_metadata():
108
117
assert_equal (len (w ), 1 )
109
118
110
119
120
+ def test_metadata ():
121
+ nvpair = GiftiNVPairs ('key' , 'value' )
122
+ da = GiftiMetaData (nvpair = nvpair )
123
+ assert_equal (da .data [0 ].name , 'key' )
124
+ assert_equal (da .data [0 ].value , 'value' )
125
+
126
+
111
127
def test_gifti_label_rgba ():
112
128
rgba = np .random .rand (4 )
113
129
kwargs = dict (zip (['red' , 'green' , 'blue' , 'alpha' ], rgba ))
0 commit comments