@@ -54,6 +54,7 @@ def distinguishable_colors(ncolors, backgrounds=[[0,0,0],[1,1,1]],
54
54
Examples
55
55
--------
56
56
>>> from mindboggle.mio.colors import distinguishable_colors
57
+ >>> import numpy as np
57
58
>>> ncolors = 31
58
59
>>> backgrounds = [[0,0,0],[1,1,1]]
59
60
>>> save_csv = False
@@ -218,6 +219,7 @@ def label_adjacency_matrix(label_file, ignore_values=[-1, 999], add_value=0,
218
219
--------
219
220
>>> from mindboggle.mio.colors import label_adjacency_matrix
220
221
>>> from mindboggle.mio.fetch_data import prep_tests
222
+ >>> import numpy as np
221
223
>>> urls, fetch_data = prep_tests()
222
224
>>> ignore_values = [-1, 0]
223
225
>>> add_value = 0
@@ -402,6 +404,7 @@ def group_colors(colormap, colormap_name, description='', adjacency_matrix=[],
402
404
--------
403
405
>>> # Get colormap:
404
406
>>> from mindboggle.mio.colors import distinguishable_colors
407
+ >>> import numpy as np
405
408
>>> colormap = distinguishable_colors(ncolors=31,
406
409
... backgrounds=[[0,0,0],[1,1,1]],
407
410
... save_csv=False, plot_colormap=False, verbose=False)
@@ -432,29 +435,29 @@ def group_colors(colormap, colormap_name, description='', adjacency_matrix=[],
432
435
>>> colors = group_colors(colormap, colormap_name, description,
433
436
... adjacency_matrix, IDs, names, groups,
434
437
... save_text_files, plot_colors, plot_graphs, out_dir, verbose)
435
- >>> colors[0]
436
- [0.7586206896551724, 0.20689655172413793, 0.0]
437
- >>> colors[1]
438
- [0.48275862068965514, 0.4482758620689655, 0.48275862068965514]
439
- >>> colors[2]
440
- [0.3448275862068966, 0.3103448275862069, 0.034482758620689655]
441
- >>> colors[-1]
442
- [0.7931034482758621, 0.9655172413793103, 0.7931034482758621]
438
+ >>> np.allclose( colors[0], [0.7586206896551724, 0.20689655172413793, 0.0])
439
+ True
440
+ >>> np.allclose( colors[1], [0.48275862068965514, 0.4482758620689655, 0.48275862068965514])
441
+ True
442
+ >>> np.allclose( colors[2], [0.3448275862068966, 0.3103448275862069, 0.034482758620689655])
443
+ True
444
+ >>> np.allclose( colors[-1], [0.7931034482758621, 0.9655172413793103, 0.7931034482758621])
445
+ True
443
446
444
447
No groups / subgraphs:
445
448
446
449
>>> groups = []
447
450
>>> colors = group_colors(colormap, colormap_name, description,
448
451
... adjacency_matrix, IDs, names, groups,
449
452
... save_text_files, plot_colors, plot_graphs, out_dir, verbose)
450
- >>> colors[0]
451
- [0.5172413793103449, 0.8275862068965517, 1.0]
452
- >>> colors[1]
453
- [0.13793103448275862, 0.0, 0.24137931034482757]
454
- >>> colors[2]
455
- [0.3793103448275862, 0.27586206896551724, 0.48275862068965514]
456
- >>> colors[-1]
457
- [0.6206896551724138, 0.48275862068965514, 0.3448275862068966]
453
+ >>> np.allclose( colors[0], [0.5172413793103449, 0.8275862068965517, 1.0])
454
+ True
455
+ >>> np.allclose( colors[1], [0.13793103448275862, 0.0, 0.24137931034482757])
456
+ True
457
+ >>> np.allclose( colors[2], [0.3793103448275862, 0.27586206896551724, 0.48275862068965514])
458
+ True
459
+ >>> np.allclose( colors[-1], [0.6206896551724138, 0.48275862068965514, 0.3448275862068966])
460
+ True
458
461
459
462
"""
460
463
import os
@@ -834,6 +837,7 @@ def write_json_colormap(colormap, label_numbers, label_names=[],
834
837
--------
835
838
>>> from mindboggle.mio.colors import write_xml_colormap
836
839
>>> from mindboggle.mio.labels import DKTprotocol
840
+ >>> import numpy as np
837
841
>>> dkt = DKTprotocol()
838
842
>>> colormap = dkt.colormap_normalized
839
843
>>> colormap = [[x[2], x[3], x[4]] for x in colormap]
@@ -842,8 +846,8 @@ def write_json_colormap(colormap, label_numbers, label_names=[],
842
846
>>> colormap_file = ''
843
847
>>> colormap_name = "DKT31colormap"
844
848
>>> description = "Colormap for DKT31 human brain cortical labels"
845
- >>> colormap[0]
846
- [0.803921568627451, 0.24313725490196078, 0.3058823529411765]
849
+ >>> np.allclose( colormap[0], [0.803921568627451, 0.24313725490196078, 0.3058823529411765])
850
+ True
847
851
>>> write_json_colormap(colormap, label_numbers, label_names,
848
852
... colormap_file, colormap_name, description)
849
853
"""
@@ -895,14 +899,15 @@ def write_xml_colormap(colormap, label_numbers, colormap_file='',
895
899
--------
896
900
>>> from mindboggle.mio.colors import write_xml_colormap
897
901
>>> from mindboggle.mio.labels import DKTprotocol
902
+ >>> import numpy as np
898
903
>>> dkt = DKTprotocol()
899
904
>>> colormap = dkt.colormap_normalized
900
905
>>> colormap = [[x[2], x[3], x[4]] for x in colormap]
901
906
>>> label_numbers = dkt.label_numbers
902
907
>>> colormap_file = ''
903
908
>>> colormap_name = 'DKT31colormap'
904
- >>> colormap[0]
905
- [0.803921568627451, 0.24313725490196078, 0.3058823529411765]
909
+ >>> np.allclose( colormap[0], [0.803921568627451, 0.24313725490196078, 0.3058823529411765])
910
+ True
906
911
>>> write_xml_colormap(colormap, label_numbers, colormap_file,
907
912
... colormap_name)
908
913
"""
0 commit comments