@@ -95,6 +95,9 @@ class GiftiLabelTable(xml.XmlSerializable):
95
95
def __init__ (self ):
96
96
self .labels = []
97
97
98
+ def __repr__ (self ):
99
+ return f"<GiftiLabelTable { self .labels !r} >"
100
+
98
101
def get_labels_as_dict (self ):
99
102
self .labels_as_dict = {}
100
103
for ele in self .labels :
@@ -153,6 +156,13 @@ def __init__(self, key=0, red=None, green=None, blue=None, alpha=None):
153
156
self .blue = blue
154
157
self .alpha = alpha
155
158
159
+ def __repr__ (self ):
160
+ chars = 255 * np .array (
161
+ [self .red or 0 , self .green or 0 , self .blue or 0 , self .alpha or 0 ]
162
+ )
163
+ r , g , b , a = chars .astype ('u1' )
164
+ return f'<GiftiLabel { self .key } ="#{ r :02x} { g :02x} { b :02x} { a :02x} ">'
165
+
156
166
@deprecate_with_version (
157
167
'get_rgba method deprecated. '
158
168
"Use the rgba property instead." ,
@@ -235,6 +245,11 @@ def __init__(self, dataspace=0, xformspace=0, xform=None):
235
245
else :
236
246
self .xform = xform
237
247
248
+ def __repr__ (self ):
249
+ src = xform_codes .label [self .dataspace ]
250
+ dst = xform_codes .label [self .xformspace ]
251
+ return f"<GiftiCoordSystem { src } -to-{ dst } >"
252
+
238
253
def _to_xml_element (self ):
239
254
coord_xform = xml .Element ('CoordinateSystemTransformMatrix' )
240
255
if self .xform is not None :
@@ -375,6 +390,9 @@ def __init__(self,
375
390
self .ext_offset = ext_offset
376
391
self .dims = [] if self .data is None else list (self .data .shape )
377
392
393
+ def __repr__ (self ):
394
+ return f"<GiftiDataArray { intent_codes .label [self .intent ]} { self .dims } >"
395
+
378
396
@property
379
397
def num_dim (self ):
380
398
return len (self .dims )
0 commit comments