@@ -209,7 +209,7 @@ def test_annot():
209
209
assert_equal (names , names2 )
210
210
211
211
212
- def test_annot_readback ():
212
+ def test_read_write_annot ():
213
213
214
214
# This annot file will store a LUT for a mesh made of 10 vertices, with
215
215
# 3 colours in the LUT.
@@ -245,9 +245,31 @@ def test_annot_readback():
245
245
annot_path = 'c.annot'
246
246
247
247
with InTemporaryDirectory ():
248
- write_annot (annot_path , labels , rgbal , names )
248
+ write_annot (annot_path , labels , rgbal , names , fill_ctab = False )
249
249
labels2 , rgbal2 , names2 = read_annot (annot_path )
250
250
assert np .all (np .isclose (rgbal2 , rgbal ))
251
+ assert np .all (np .isclose (labels2 , labels ))
252
+ assert names2 == names
253
+
254
+
255
+ def test_write_annot_fill_ctab ():
256
+
257
+ nvertices = 10
258
+ nlabels = 3
259
+ names = ['label {}' .format (l ) for l in range (1 , nlabels + 1 )]
260
+ labels = list (range (nlabels )) + \
261
+ list (np .random .randint (0 , nlabels , nvertices - nlabels ))
262
+ labels = np .array (labels , dtype = np .int32 )
263
+ np .random .shuffle (labels )
264
+ rgbal = np .random .randint (0 , 255 , (nlabels , 4 ), dtype = np .int32 )
265
+ annot_path = 'c.annot'
266
+
267
+ with InTemporaryDirectory ():
268
+ write_annot (annot_path , labels , rgbal , names , fill_ctab = True )
269
+ labels2 , rgbal2 , names2 = read_annot (annot_path )
270
+ assert np .all (np .isclose (rgbal2 [:, :4 ], rgbal ))
271
+ assert np .all (np .isclose (labels2 , labels ))
272
+ assert names2 == names
251
273
252
274
253
275
@freesurfer_test
0 commit comments