@@ -219,6 +219,19 @@ def _check_name(self, attribute, value):
219
219
'space identifier "%s" is invalid.\n Valid '
220
220
'identifiers are: %s' % (value , ', ' .join (valid )))
221
221
222
+ def __str__ (self ):
223
+ """
224
+ Format this reference.
225
+
226
+ Examples
227
+ --------
228
+ >>> str(Reference(space='MNIPediatricAsym', spec={'cohort': 2, 'res': 1}))
229
+ 'MNIPediatricAsym:cohort-2:res-1'
230
+
231
+ """
232
+ return ':' .join ([self .space ] + [
233
+ '-' .join ((k , str (v ))) for k , v in sorted (self .spec .items ())])
234
+
222
235
@classmethod
223
236
def from_string (cls , value ):
224
237
"""
@@ -473,18 +486,14 @@ def __str__(self):
473
486
Spatial References: <none>.
474
487
475
488
>>> print(SpatialReferences(['MNI152NLin2009cAsym']))
476
- Spatial References:
477
- - Reference(space='MNI152NLin2009cAsym', spec={})
489
+ Spatial References: MNI152NLin2009cAsym
478
490
479
491
>>> print(SpatialReferences(['MNI152NLin2009cAsym', 'fsaverage5']))
480
- Spatial References:
481
- - Reference(space='MNI152NLin2009cAsym', spec={})
482
- - Reference(space='fsaverage', spec={'den': '10k'})
492
+ Spatial References: MNI152NLin2009cAsym, fsaverage:den-10k
483
493
484
494
"""
485
- spaces = '\n - ' .join (['' ] + [str (s ) for s in self .references ]) \
486
- if self .references else ' <none>.'
487
- return 'Spatial References:%s' % spaces
495
+ spaces = ', ' .join ([str (s ) for s in self .references ]) or '<none>.'
496
+ return 'Spatial References: %s' % spaces
488
497
489
498
@property
490
499
def references (self ):
0 commit comments