Package mvpa :: Package tests :: Module test_atlases
[hide private]
[frames] | no frames]

Source Code for Module mvpa.tests.test_atlases

 1  #emacs: -*- mode: python-mode; py-indent-offset: 4; indent-tabs-mode: nil -*- 
 2  #ex: set sts=4 ts=4 sw=4 et: 
 3  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 
 4  # 
 5  #   See COPYING file distributed along with the PyMVPA package for the 
 6  #   copyright and license terms. 
 7  # 
 8  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 
 9  """Unit tests for PyMVPA atlases""" 
10   
11  import unittest 
12   
13  from mvpa.base import externals, warning 
14  if externals.exists('nifti', raiseException=True): 
15      from mvpa.atlases import * 
16  else: 
17      raise RuntimeError, "Don't run me if no nifti is present" 
18   
19 -class AtlasesTests(unittest.TestCase):
20 """Basic tests for support of atlases such as the ones 21 shipped with FSL 22 """
23 - def testTransformations(self):
24 """TODO""" 25 pass
26
27 - def testAtlases(self):
28 """Basic testing of atlases""" 29 30 tested = 0 31 for name in KNOWN_ATLASES.keys(): 32 #filename = KNOWN_ATLASES[name] % {'name': name} 33 try: 34 atlas = Atlas(name=name) 35 tested += 1 36 except IOError: 37 # so we just don't have it 38 continue 39 #print isinstance(atlas.atlas, objectify.ObjectifiedElement) 40 #print atlas.header.images.imagefile.get('offset') 41 #print atlas.labelVoxel( (0, -7, 20) ) 42 #print atlas[ 0, 0, 0 ] 43 coord = (-63, -12, 22) 44 45 # Atlas must have at least 1 level and that one must 46 # have some labels 47 self.failUnless(len(atlas.levels_dict[0].labels) > 0) 48 49 for res in [ atlas[coord], 50 atlas.labelPoint(coord) ]: 51 self.failUnless(res.get('coord_queried', None) == coord, 52 '%s: Comparison failed. Got %s and %s' 53 % (name, res.get('coord_queried', None), coord)) 54 self.failUnless('labels' in res) 55 # all atlases so far are based on voxels 56 self.failUnless('voxel_queried' in res) 57 58 # test explicit level specification via slice, although bogus here 59 # XXX levels in queries should be deprecated -- too much of 60 # performance hit 61 res0 = atlas[coord, range(atlas.Nlevels)] 62 self.failUnless(res0 == res) 63 64 #print atlas[ 0, -7, 20, [1,2,3] ] 65 #print atlas[ (0, -7, 20), 1:2 ] 66 #print atlas[ (0, -7, 20) ] 67 #print atlas[ (0, -7, 20), : ] 68 # print atlas.getLabels(0) 69 if not tested: 70 warning("No atlases were found -- thus no testing was done")
71
72 -def suite():
73 return unittest.makeSuite(AtlasesTests)
74 75 76 if __name__ == '__main__': 77 import runner 78