@@ -219,6 +219,19 @@ def _check_name(self, attribute, value):
219219 'space identifier "%s" is invalid.\n Valid '
220220 'identifiers are: %s' % (value , ', ' .join (valid )))
221221
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+
222235 @classmethod
223236 def from_string (cls , value ):
224237 """
@@ -473,18 +486,14 @@ def __str__(self):
473486 Spatial References: <none>.
474487
475488 >>> print(SpatialReferences(['MNI152NLin2009cAsym']))
476- Spatial References:
477- - Reference(space='MNI152NLin2009cAsym', spec={})
489+ Spatial References: MNI152NLin2009cAsym
478490
479491 >>> 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
483493
484494 """
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
488497
489498 @property
490499 def references (self ):
0 commit comments