Changeset 162

Show
Ignore:
Timestamp:
05/06/08 17:19:16 (8 months ago)
Author:
brizzi
Message:

Codejam2 version

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/packaged_tools/NeuroTools/HDF5Tools/HDF5Factory/__init__.py

    r136 r162  
    1 __path__.append('/home/thierry/Django_Project/UnicDatabase_fromsvn/NeuroTools/HDF5Tools') 
     1__path__.append('/home/thierry/NeuroTools_Project/NeuroTools/HDF5Tools') 
    22__all__ = ['highlevel', 'generator', 'navigator', 'structure', 'randomizer'] 
    33 
  • branches/packaged_tools/NeuroTools/HDF5Tools/HDF5Factory/generator.py

    r136 r162  
    231231        return node.retrieve(url, format) 
    232232     
    233     def createMovie(self, url, where, name, interlace = "INTERLACE_PIXEL",title = '', tags=None, createparents=False, overwrite = False) : 
     233    def createMovie(self, url, where, name, interlace = "INTERLACE_PIXEL",title = '', frame_duration = None, tags=None, createparents=False, overwrite = False) : 
    234234        
    235235        if overwrite : 
    236236            self._overwrite(where, name) 
    237237        parentNode = self._getOrCreatePath(where, createparents) 
    238         return h5movie.H5Movie(parentNode, name, url=url, interlace = interlace, title = title, tags=tags, _open = True) 
     238        return h5movie.H5Movie(parentNode, name, url=url, interlace = interlace, title = title, frame_duration=frame_duration, tags=tags, _open = True) 
    239239     
    240240    def createVLMovie(self, url, where, name, interlace = "INTERLACE_PIXEL",title = '', createparents=False, overwrite = False) : 
  • branches/packaged_tools/NeuroTools/HDF5Tools/HDF5Factory/highlevel.py

    r136 r162  
    137137        elif isinstance(obj, SpikeList) : 
    138138            object = self.createSpikeList(obj, where, name, tags=tags, title=title, createparents = createparents, overwrite=overwrite) 
    139         # 
     139        #detect if it is the url of a image file or movie directory 
    140140        elif isinstance(obj, str) and (len(obj.split('//')) > 1) : 
    141141            if os.path.isfile(obj.split('//')[-1]) : 
     
    143143            elif os.path.isdir(obj.split('//')[-1]) : 
    144144                object = self.createMovie(obj, where, name, title=title, createparents = createparents, overwrite=overwrite) 
     145        #detect if it is a numpy array or convert a python regular array into numpy array 
    145146        elif isinstance(obj, ndarray) | isinstance(obj, list) | isinstance(obj, tuple) : 
    146147            if isinstance(obj, list) | isinstance(obj, tuple) : 
  • branches/packaged_tools/NeuroTools/HDF5Tools/HDF5Objects/__init__.py

    r136 r162  
    1 __path__.append('/home/thierry/Django_Project/UnicDatabase_fromsvn/NeuroTools/HDF5Tools') 
     1__path__.append('/home/thierry/NeuroTools_Project/NeuroTools/HDF5Tools') 
    22__all__ = ['h5spiketrain', 'h5spikelist', 'h5serializer', 'h5image', 'h5movie'] 
  • branches/packaged_tools/NeuroTools/HDF5Tools/HDF5Objects/h5movie.py

    r136 r162  
    162162        return images 
    163163     
    164     def append(self, images_list, interlace=None, subclass=None, components=None, tags = None, _open = False) : 
     164    def append(self, images_list, interlace=None, subclass=None, components=None, frame_duration = None, tags = None, _open = False) : 
    165165        #look if images is an url or a list of url 
    166166        if isinstance(images_list, str) : 
     
    193193                self._v_attrs.MOVIE_DISPLAY_ORIGIN = 'UL' 
    194194                self._v_attrs.MOVIE_COLORMODEL = image.mode 
     195                self._v_attrs.MOVIE_FRAME_DURATION = frame_duration 
    195196                if components in [2, 4] :  
    196197                    self._v_attrs.MOVIE_TRANSPARENCY = components - 1 
     
    206207            cnt += 1    
    207208     
    208     def __init__(self, parentNode, name, url = None, interlace = 'INTERLACE_PIXEL', tags=None, im_per_sec = 50, title = '', _log = True,  _open = False) : 
     209    def __init__(self, parentNode, name, url = None, interlace = 'INTERLACE_PIXEL', tags=None, frame_duration = None, title = '', _log = True,  _open = False) : 
    209210        if _open == True : 
    210211            assert interlace in ['INTERLACE_PIXEL', 'INTERLACE_PLANE'], "interlace must be 'INTERLACE_PIXEL' or 'INTERLACE_PLANE'" 
     
    229230                                                        filters=filters_default, 
    230231                                                        _log=_log) 
    231             self.append(images, interlace=interlace, subclass=subclass, components=components, tags=tags, _open=_open) 
     232            self.append(images, interlace=interlace, subclass=subclass, components=components, frame_duration = frame_duration, tags=tags, _open=_open) 
    232233        else : 
    233234            super(H5Movie, self).__init__(parentNode = parentNode, name = name) 
  • branches/packaged_tools/NeuroTools/HDF5Tools/__init__.py

    r136 r162  
    1 __path__.append('/home/thierry/Django_Project/UnicDatabase_fromsvn/NeuroTools') 
     1__path__.append('/home/thierry/NeuroTools_Project/NeuroTools') 
    22__all__ = ['HDF5Objects', 'HDF5Factory'] 
    33 
  • branches/packaged_tools/NeuroTools/HDF5Tools/h5objects_tests.py

    r136 r162  
    11import sys 
    2 sys.path.append('/home/thierry/Django_Project/UnicDatabase_fromsvn') 
     2sys.path.append('/home/thierry/NeuroTools_Project') 
    33from NeuroTools.HDF5Tools.HDF5Factory.highlevel import openH5File, HDF5File 
    44from NeuroTools.PIL import Image 
     
    77import unittest 
    88from numpy import array 
     9import os 
    910 
    1011class base_object(object) : 
     
    160161    """Base class for the ImagePixelPersistanceTestCase and ImagePlanePersitanceTestCase.""" 
    161162    def test_image(self) : 
    162         node = self.h5image 
    163         width = self.image.size[0] 
    164         self.assert_(width == node.shape[self.arg['width']], 'widths are not equal') 
    165         height = self.image.size[1] 
    166         self.assert_(height == node.shape[self.arg['height']], 'heights are not equal') 
    167         components = node.shape[self.arg['components']] 
    168         data = list(self.image.getdata()) 
    169         node_data = node.read() 
    170         self.assert_(components == len(data[0]), 'components are not equal') 
    171         self.assert_(node._v_attrs.IMAGE_INTERLACE_MODE == self.arg['interlace'], "interlace mode must be INTERLACE_PIXEL.") 
    172         self.assert_(node._v_attrs.IMAGE_COLORMODEL == self.image.mode, "color models are diffrent.") 
    173         self.assert_(node._v_attrs.IMAGE_DISPLAY_ORIGIN == 'UL', 'display origin must be UL.') 
    174         self.assert_(node._v_attrs.IMAGE_MINMAXRANGE == list(self.image.getextrema()), 'extrema are diffrent.') 
    175         if 'IMAGE_TRANSPARENCY' in node._v_attrs._f_list() :  
    176             self.assert_(node._v_attrs.IMAGE_TRANSPARENCY == components - 1, 'problem with alpha layer.') 
    177             self.assert_(node._v_attrs.IMAGE_TRANSPARENCY in [1,3], 'alpha layer only exists when number of components is 2 or 4.') 
    178         if self.image.mode == 'RGB' : 
    179             subclass = 'IMAGE_TRUECOLOR' 
    180         elif self.image.mode in ['1', 'L', 'LA'] : 
    181             subclass = 'IMAGE_GRAYSCALE' 
    182         elif self.image.mode in ['RGBA', 'CMY', 'CMYK', 'YCbCr', 'YUV', 'HSV'] : 
    183             subclass = 'IMAGE_BITMAP' 
    184         assert subclass == node._v_attrs.IMAGE_SUBCLASS 
    185         for tag in self.tags : 
    186             attr = getattr(node._v_attrs, tag) 
    187             self.assert_(self.tags[tag] == attr) 
    188         for h in range(height) : 
    189             for w in range(width) : 
    190                 c = 0 
    191                 pixel = data[h*width + w] 
    192                 for color in pixel : 
    193                     if self.arg['order'] == 'hwc' : 
    194                         self.assert_(node_data[h, w, c] == color, "pixel components are not equal") 
    195                     elif self.arg['order'] == 'chw' : 
    196                         self.assert_(node_data[c, h, w] == color, "pixel components are not equal") 
    197                     c += 1 
     163        cnt = 0 
     164        for h5image in self.h5images : 
     165            im = self.images[cnt] 
     166            node = h5image 
     167            width = im.size[0] 
     168            self.assert_(width == node.shape[self.arg['width']], 'widths are not equal') 
     169            height = im.size[1] 
     170            self.assert_(height == node.shape[self.arg['height']], 'heights are not equal') 
     171            components = node.shape[self.arg['components']] 
     172            data = list(im.getdata()) 
     173            node_data = node.read() 
     174            self.assert_(components == len(data[0]), 'components are not equal') 
     175            self.assert_(node._v_attrs.IMAGE_INTERLACE_MODE == self.arg['interlace'], "interlace mode must be INTERLACE_PIXEL.") 
     176            self.assert_(node._v_attrs.IMAGE_COLORMODEL == im.mode, "color models are diffrent.") 
     177            self.assert_(node._v_attrs.IMAGE_DISPLAY_ORIGIN == 'UL', 'display origin must be UL.') 
     178            self.assert_(node._v_attrs.IMAGE_MINMAXRANGE == list(im.getextrema()), 'extrema are diffrent.') 
     179            if 'IMAGE_TRANSPARENCY' in node._v_attrs._f_list() :  
     180                self.assert_(node._v_attrs.IMAGE_TRANSPARENCY == components - 1, 'problem with alpha layer.') 
     181                self.assert_(node._v_attrs.IMAGE_TRANSPARENCY in [1,3], 'alpha layer only exists when number of components is 2 or 4.') 
     182            if im.mode == 'RGB' : 
     183                subclass = 'IMAGE_TRUECOLOR' 
     184            elif im.mode in ['1', 'L', 'LA'] : 
     185                subclass = 'IMAGE_GRAYSCALE' 
     186            elif im.mode in ['RGBA', 'CMY', 'CMYK', 'YCbCr', 'YUV', 'HSV'] : 
     187                subclass = 'IMAGE_BITMAP' 
     188            assert subclass == node._v_attrs.IMAGE_SUBCLASS 
     189            for tag in self.tags : 
     190                attr = getattr(node._v_attrs, tag) 
     191                self.assert_(self.tags[tag] == attr) 
     192            for h in range(height) : 
     193                for w in range(width) : 
     194                    c = 0 
     195                    pixel = data[h*width + w] 
     196                    for color in pixel : 
     197                        if self.arg['order'] == 'hwc' : 
     198                            self.assert_(node_data[h, w, c] == color, "pixel components are not equal") 
     199                        elif self.arg['order'] == 'chw' : 
     200                            self.assert_(node_data[c, h, w] == color, "pixel components are not equal") 
     201                        c += 1 
     202            cnt += 1 
    198203     
    199204    def tearDown(self): 
     
    218223 
    219224    def setUp(self): 
    220         self.image = Image.open('/tmp/image.jpg') 
    221         self.image.load() 
     225        path = '/home/thierry/NeuroTools_Project/NeuroTools/Tests/Images' 
     226        self.paths = [os.path.join(path,f) for f in os.listdir(path) if os.path.isfile(os.path.join(path,f))] 
     227        self.images = [Image.open(im) for im in self.paths] 
    222228        self.tags = {'testcase' : 'PersistanceTestCase', 'kind' : 'image pixel test'} 
    223229        self.h5file = openH5File('file:///tmp/persistance_test.h5', 'w') 
    224         self.h5image = self.h5file.createImage('file:///tmp/image.jpg', '/', 'Image_Pixel', title='Image Test Pixel', interlace = 'INTERLACE_PIXEL', tags = self.tags) 
     230        id = 0 
     231        self.h5images = [] 
     232        for im in self.paths : 
     233            self.h5images.append(self.h5file.createImage('file://%s'%(im), '/', im.split('/')[-1].replace('.', '_'), title='Image Test Pixel', interlace = 'INTERLACE_PIXEL', tags = self.tags)) 
    225234        self.arg = {'width' : 1,'height' : 0,'components' : 2, 'order' : 'hwc', 'interlace':'INTERLACE_PIXEL'} 
    226235     
    227     def test_image_pixel(self) : 
    228         super(ImagePixelPersistanceTestCase, self).test_image() 
     236##    def test_image_pixel(self) : 
     237##        super(ImagePixelPersistanceTestCase, self).test_image() 
    229238     
    230239class ImagePlanePersistanceTestCase(ImagePersistanceTestCase) : 
     
    246255 
    247256    def setUp(self): 
    248         self.image = Image.open('/tmp/image.jpg') 
    249         self.image.load() 
    250         self.tags = {'testcase' : 'PersistanceTestCase', 'kind' : 'image plane test'} 
     257        path = '/home/thierry/NeuroTools_Project/NeuroTools/Tests/Images' 
     258        self.paths = [os.path.join(path,f) for f in os.listdir(path) if os.path.isfile(os.path.join(path,f))] 
     259        self.images = [Image.open(im) for im in self.paths] 
     260        self.tags = {'testcase' : 'PersistanceTestCase', 'kind' : 'image pixel test'} 
    251261        self.h5file = openH5File('file:///tmp/persistance_test.h5', 'w') 
    252         self.h5image = self.h5file.createImage('file:///tmp/image.jpg', '/', 'Image_Plane', title='Image Test Plane', interlace = 'INTERLACE_PLANE', tags = self.tags) 
    253         self.arg = {'width' : 2,'height' : 1,'components' : 0,'order':'chw', 'interlace' : 'INTERLACE_PLANE'} 
    254      
    255     def test_image_plane(self) : 
    256         super(ImagePlanePersistanceTestCase, self).test_image() 
     262        id = 0 
     263        self.h5images = [] 
     264        for im in self.paths : 
     265            self.h5images.append(self.h5file.createImage('file://%s'%(im), '/', im.split('/')[-1].replace('.', '_'), title='Image Test Plane', interlace = 'INTERLACE_PLANE', tags = self.tags)) 
     266        self.arg = {'width' : 2,'height' : 1,'components' : 0, 'order' : 'chw', 'interlace':'INTERLACE_PLANE'} 
     267     
     268##    def test_image_plane(self) : 
     269##        super(ImagePlanePersistanceTestCase, self).test_image() 
    257270 
    258271class MoviePersistanceTestCase(unittest.TestCase) : 
     
    323336 
    324337    def setUp(self): 
    325         self.url = 'file:///tmp/movie
     338        self.url = 'file:///home/thierry/NeuroTools_Project/NeuroTools/Tests/Movies/moving_gbar
    326339        self.tags = {'testcase' : 'PersistanceTestCase', 'kind' : 'movie pixel test'} 
    327340        self.h5file = openH5File('file:///tmp/persistance_test.h5', 'w') 
     
    329342        self.arg = {'width' : 2,'height' : 1,'components' : 3,'order':'hwc', 'interlace' : 'INTERLACE_PIXEL'} 
    330343     
    331     def test_movie_pixel(self) : 
    332         super(MoviePixelPersistanceTestCase, self).test_movie() 
     344##    def test_movie_pixel(self) : 
     345##        super(MoviePixelPersistanceTestCase, self).test_movie() 
    333346     
    334347class MoviePlanePersistanceTestCase(MoviePersistanceTestCase) : 
     
    337350 
    338351    def setUp(self): 
    339         self.url = 'file:///tmp/movie
     352        self.url = 'file:///home/thierry/NeuroTools_Project/NeuroTools/Tests/Movies/moving_gbar
    340353        self.tags = {'testcase' : 'PersistanceTestCase', 'kind' : 'movie plane test'} 
    341354        self.h5file = openH5File('file:///tmp/persistance_test.h5', 'w') 
     
    343356        self.arg = {'width' : 3,'height' : 2,'components' : 1,'order':'chw', 'interlace' : 'INTERLACE_PLANE'} 
    344357     
    345     def test_movie_plane(self) : 
    346         super(MoviePlanePersistanceTestCase, self).test_movie() 
     358##    def test_movie_plane(self) : 
     359##        super(MoviePlanePersistanceTestCase, self).test_movie() 
    347360 
    348361class SpikeTrainInitializationTestCase(unittest.TestCase) : 
     
    430443    """Verify that a image file could be initialiazed from a hdf5 image in interlace pixel mode : 
    431444     
    432         1 - Initialize a PIL image from file 
    433         2 - create a hdf5 file that will store the hdf5 object corresponding to the image in interlace pixel mode 
    434         3 - create the hdf5 image object from the PIL image 
    435         4 - create a new image from the hdf5 object 
     445        1 - Initialize PIL images from file 
     446        2 - create a hdf5 file that will store the hdf5 objects corresponding to the images in interlace pixel mode 
     447        3 - create the hdf5 images object from the PIL images 
     448        4 - create new images from the hdf5 objects 
    436449        5 - compare the 2 images 
    437450     
     
    452465    """Verify that a image file could be initialiazed from a hdf5 image in interlace plane mode : 
    453466     
    454         1 - Initialize a PIL image from file 
    455         2 - create a hdf5 file that will store the hdf5 object corresponding to the image in interlace plane mode 
    456         3 - create the hdf5 image object from the PIL image 
    457         4 - create a new image from the hdf5 object 
     467        1 - Initialize PIL images from file 
     468        2 - create a hdf5 file that will store the hdf5 objects corresponding to the images in interlace plane mode 
     469        3 - create the hdf5 images object from the PIL images 
     470        4 - create new images from the hdf5 objects 
    458471        5 - compare the 2 images 
    459472     
  • branches/packaged_tools/NeuroTools/PythonObjects/__init__.py

    r136 r162  
    1 __path__.append('/home/thierry/Django_Project/UnicDatabase_fromsvn/NeuroTools') 
     1__path__.append('/home/thierry/NeuroTools_Project/NeuroTools') 
    22__all__ = ['spikes'] 
  • branches/packaged_tools/NeuroTools/__init__.py

    r136 r162  
    1 __path__.append('/home/thierry/Django_Project/UnicDatabase_fromsvn') 
     1__path__.append('/home/thierry/NeuroTools_Project') 
    22__path__.append('/usr/lib/python2.5/site-packages') 
    33__all__ = ['PIL', 'tables', 'PythonObjects', 'HDF5Tools'] 
  • branches/packaged_tools/NeuroTools/h5howto.py

    r136 r162  
    1010 
    1111import sys 
    12 sys.path.append('/home/thierry/Django_Project/UnicDatabase_fromsvn') 
     12sys.path.append('/home/thierry/NeuroTools_Project') 
    1313from NeuroTools.HDF5Tools.HDF5Factory.highlevel import openH5File, HDF5File 
    1414from NeuroTools.PythonObjects.spikes import SpikeTrain, SpikeList 
    15 from numpy import ndarray, array 
    1615 
    1716if __name__ == '__main__' : 
    18     print "Init Objects." 
    19     #initialize a spiketrain 
     17    #create a SpikeTrain object 
    2018    times = [1.1,2.4,3.5,4.6,5.9,6.6,7.2,8.1,9.4,10.5] 
    2119    spiketrain = SpikeTrain(times, dt=0.1, t_start=times[0], t_stop=times[-1]) 
    22     tags_1 = {'comment1' : 'comment1 ...', 'comment2' : 'comment2...', 'quality' : 2} #optional 
    23     #initialize a spikelist 
     20    #create a SpikeList object 
    2421    id_list = [1,2,3,4] 
    2522    spikes = [(1,0.1), (1,1.2), (1,2.4), (1,3.6), (1,4.1), (1,5.7), (1,6.3), 
    26                       (2,0.6), (2,1.3), (2,2.4), (2,3.7), (2,5.7), 
    27                       (3,1.2), (3,2.3), (3,4.1), (3,7.9), (3,9.3), 
    28                       (4,0.1), (4,2.4), (4,4.1), (4,7.2), (4,8.5), (4,9.4)] 
     23                   (2,0.6), (2,1.3), (2,2.4), (2,3.7), (2,5.7), 
     24                   (3,1.2), (3,2.3), (3,4.1), (3,7.9), (3,9.3), 
     25                   (4,0.1), (4,2.4), (4,4.1), (4,7.2), (4,8.5), (4,9.4)] 
    2926    spikelist = SpikeList(spikes, id_list,dt=0.1, t_start=0.1, t_stop=9.4) 
    30     tags_2 = {'comment1' : 'comment1 ...', 'comment2' : 'comment2...', 'quality' : 4} #optional 
    31     # 
    32     lst = [[1,2,3,4,5,8,7,8,9,7,], [1,2,3], [8,5,9,6,8,7], ['a', 'b', 'c']] 
    33     tags_3 = {'comment1' : 'comment1 ...', 'comment2' : 'comment2...'} 
    34     #open a h5 file in write mode 
     27    #define the file tree with a dictionary 
     28    structure = {"FirstNode" :{'tags' : {'comment' : "this is the first node"},  
     29                                        'FirstLeaf' : {'dataset' : "file:///tmp/neurons.jpg", 
     30                                                                 'tags' : {'comments' : 'this is an image'}}, 
     31                                        'SecondLeaf':{'dataset' : "file:///tmp/moving_gbar", 
     32                                                                 'tags' : {'comments' : 'this is a movie'}}, 
     33                                        'ThirdLeaf' : {'dataset':spiketrain, 'tags':{'comment':'this is a spiketrain'}}, 
     34                                        'ForthLeaf' : {'dataset':spikelist, 'tags':{'comment':'this is a spikelist'}} 
     35                                     }, 
     36                        "SecondNode":{'tags': {'comment' : "this is a clone of the first node"}, 
     37                                                'FirstCloneLeaf' : {'dataset' : "file:///tmp/neurons.jpg", 
     38                                                                                 'tags' : {'comments' : 'this is the same image'}}, 
     39                                                'SecondCloneLeaf':{'dataset' : "file:///tmp/moving_gbar", 
     40                                                                                 'tags' : {'comments' : 'this is the same movie'}}, 
     41                                                'ThirdLeaf' : {'dataset':spiketrain, 'tags':{'comment':'this is a clone spiketrain'}}, 
     42                                                'ForthLeaf' : {'dataset':spikelist, 'tags':{'comment':'this is a clone spikelist'}} 
     43                                             }, 
     44                        } 
     45    #store data 
    3546    h5file = openH5File('file:///tmp/howto.h5', 'w') 
    36     #set a hdf5 structure  
    37     print "Set a h5file structure" 
    38     structure = {'array' : {'dataset' : [1,2,3], 'dataset' : [[1,2,3,4],[7,8,9,8,7,8]], 'attr1' :10, 'attr2' :20}, 
    39                         'spiketrain' : {'dataset' : spiketrain, 'attr1' :10, 'attr2' :20, 'tags' : tags_1}, 
    40                         'spikelist' : {'dataset' : spikelist, 'attr1' :10, 'attr2' :20, 'tags' : tags_2}, 
    41                         'list' : {'dataset' : lst, 'attr1':20, 'attr2' : 30, 'tags' : tags_3}} 
    42     h5file.setStructure(structure, '/Group1', createparents=True, overwrite=True) 
    43     h5file.setStructure(structure, '/Group2', createparents=True, overwrite=True) 
    44     print "Structure done." 
    45     struct = h5file.getStructure("/", raw = False, attrset = 'user') 
    46     print struct 
    47     print "Structure done."    
    48      
    49     #put data in hdf5 file : 
    50     print "Add data to h5file." 
    51     #convert the spiketrain into a h5 object under a specified node and append some tags  
    52     h5spiketrain = h5file.createSpikeTrain(spiketrain, '/Group3', 'SpikeTrain', 'SpikeTrain', tags=tags_1, createparents=True) 
    53     #convert the spiketrain into a h5 object under a specified node and append some tags  
    54     h5spikelist = h5file.createSpikeList(spikelist, '/Group3', 'SpikeList', 'SpikeList', tags=tags_2, createparents=True) 
    55     #add an image under a specified node and add some tags 
    56     tags = {'comment1' : 'comment1', 'quality' : 3} 
    57     h5image = h5file.createImage('file:///tmp/image.jpg', '/Group3', 'Image_Pixel', title='Image Pixel', interlace = 'INTERLACE_PIXEL', tags = tags) 
    58     h5image = h5file.createImage('file:///tmp/image.jpg', '/Group3', 'Image_Plane', title='Image Plane', interlace = 'INTERLACE_PLANE', tags = tags) 
    59     #make movie from a folder that contains multiple image file under specified node  and add some tags 
    60     tags = {'comment1' : 'comment1', 'quality' : 2} 
    61     h5image = h5file.createMovie('file:///tmp/movie', '/Group3', 'Movie_Pixel', title='Movie Pixel', interlace = 'INTERLACE_PIXEL', tags = tags, createparents=True) 
    62     h5image = h5file.createMovie('file:///tmp/movie', '/Group3', 'Movie_Plane', title='Movie Plane', interlace = 'INTERLACE_PLANE', tags = tags, createparents=True) 
    63     #make a known object into the h5 tree 
    64     ar = ndarray([3,2], dtype = 'int8') 
    65     ar[:] = [[4,5],[8,9],[10,11]] 
    66     obj = h5file.store(ar, "/Group3", "NDArray", createparents=True) 
     47    h5file.setStructure(structure, "/AllNodes", createparents=True) 
    6748    h5file.list() 
    6849    h5file.close() 
    69     print "Data added." 
    70     print "Retrieve data from h5file." 
    71     #retrieve data from each node 
     50     
     51    #retrieve data 
    7252    h5file = openH5File('file:///tmp/howto.h5', 'r') 
    73     #retrieve spiketrain  
    74     h5file.retrieveSpikeTrain('/Group3/SpikeTrain') 
    75     #retrieve spikelist 
    76     h5file.retrieveSpikeList('/Group3/SpikeList') 
    77     #retrieve image 
    78     h5file.convertImage('file:///tmp/convertion_pixel.png', "/Group3/Image_Pixel", format = 'png') 
    79     image_1 = h5file.retrieveImage('file:///tmp/convertion_pixel.png', "/Group3/Image_Pixel", format = 'png') 
    80     h5file.convertImage('file:///tmp/convertion_plane.png', "/Group3/Image_Plane", format = 'png') 
    81     image_2 = h5file.retrieveImage('file:///tmp/convertion_plane.png', "/Group3/Image_Plane", format = 'png') 
    82     #retrieve movie 
    83     h5file.convertMovie('file:///tmp/convertion_pixel', "/Group3/Movie_Pixel", format = 'png') 
    84     movie_1 = h5file.retrieveMovie('file:///tmp/convertion_pixel', "/Group3/Movie_Pixel", format = 'png') 
    85     h5file.convertMovie('file:///tmp/convertion_plane', "/Group3/Movie_Plane", format = 'png') 
    86     movie_2 = h5file.retrieveMovie('file:///tmp/convertion_plane', "/Group3/Movie_Plane", format = 'png') 
    87     #retrieve NDArray 
    88     print h5file.root.Group3.NDArray.read() 
     53    structure = h5file.getStructure("/AllNodes", raw=False, attrset='user') 
    8954    h5file.close() 
    90     print "Retrieval ended." 
     55     
     56##    print "Init Objects." 
     57##    #initialize a spiketrain 
     58##    times = [1.1,2.4,3.5,4.6,5.9,6.6,7.2,8.1,9.4,10.5] 
     59##    spiketrain = SpikeTrain(times, dt=0.1, t_start=times[0], t_stop=times[-1]) 
     60##    tags_1 = {'comment1' : 'comment1 ...', 'comment2' : 'comment2...', 'quality' : 2} #optional 
     61##    #initialize a spikelist 
     62##    id_list = [1,2,3,4] 
     63##    spikes = [(1,0.1), (1,1.2), (1,2.4), (1,3.6), (1,4.1), (1,5.7), (1,6.3), 
     64##                      (2,0.6), (2,1.3), (2,2.4), (2,3.7), (2,5.7), 
     65##                      (3,1.2), (3,2.3), (3,4.1), (3,7.9), (3,9.3), 
     66##                      (4,0.1), (4,2.4), (4,4.1), (4,7.2), (4,8.5), (4,9.4)] 
     67##    spikelist = SpikeList(spikes, id_list,dt=0.1, t_start=0.1, t_stop=9.4) 
     68##    tags_2 = {'comment1' : 'comment1 ...', 'comment2' : 'comment2...', 'quality' : 4} #optional 
     69##    # 
     70##    lst = [[1,2,3,4,5,8,7,8,9,7,], [1,2,3], [8,5,9,6,8,7], ['a', 'b', 'c']] 
     71##    tags_3 = {'comment1' : 'comment1 ...', 'comment2' : 'comment2...'} 
     72##    #open a h5 file in write mode 
     73##    h5file = openH5File('file:///tmp/howto.h5', 'w') 
     74##    #set a hdf5 structure  
     75##    print "Set a h5file structure" 
     76##    structure = {'array' : {'dataset' : [1,2,3], 'dataset' : [[1,2,3,4],[7,8,9,8,7,8]], 'attr1' :10, 'attr2' :20}, 
     77##                        'spiketrain' : {'dataset' : spiketrain, 'attr1' :10, 'attr2' :20, 'tags' : tags_1}, 
     78##                        'spikelist' : {'dataset' : spikelist, 'attr1' :10, 'attr2' :20, 'tags' : tags_2}, 
     79##                        'list' : {'dataset' : lst, 'attr1':20, 'attr2' : 30, 'tags' : tags_3}} 
     80##    h5file.setStructure(structure, '/Group1', createparents=True, overwrite=True) 
     81##    h5file.setStructure(structure, '/Group2', createparents=True, overwrite=True) 
     82##    print "Structure done." 
     83##    struct = h5file.getStructure("/", raw = False, attrset = 'user') 
     84##    print struct 
     85##    print "Structure done."    
     86##     
     87##    #put data in hdf5 file : 
     88##    print "Add data to h5file." 
     89##    #convert the spiketrain into a h5 object under a specified node and append some tags  
     90##    h5spiketrain = h5file.createSpikeTrain(spiketrain, '/Group3', 'SpikeTrain', 'SpikeTrain', tags=tags_1, createparents=True) 
     91##    #convert the spiketrain into a h5 object under a specified node and append some tags  
     92##    h5spikelist = h5file.createSpikeList(spikelist, '/Group3', 'SpikeList', 'SpikeList', tags=tags_2, createparents=True) 
     93##    #add an image under a specified node and add some tags 
     94##    tags = {'comment1' : 'comment1', 'quality' : 3} 
     95##    h5image = h5file.createImage('file:///tmp/image.jpg', '/Group3', 'Image_Pixel', title='Image Pixel', interlace = 'INTERLACE_PIXEL', tags = tags) 
     96##    h5image = h5file.createImage('file:///tmp/image.jpg', '/Group3', 'Image_Plane', title='Image Plane', interlace = 'INTERLACE_PLANE', tags = tags) 
     97##    #make movie from a folder that contains multiple image file under specified node  and add some tags 
     98##    tags = {'comment1' : 'comment1', 'quality' : 2} 
     99##    h5image = h5file.createMovie('file:///tmp/movie', '/Group3', 'Movie_Pixel', title='Movie Pixel', interlace = 'INTERLACE_PIXEL', tags = tags, createparents=True) 
     100##    h5image = h5file.createMovie('file:///tmp/movie', '/Group3', 'Movie_Plane', title='Movie Plane', interlace = 'INTERLACE_PLANE', tags = tags, createparents=True) 
     101##    #make a known object into the h5 tree 
     102##    ar = ndarray([3,2], dtype = 'int8') 
     103##    ar[:] = [[4,5],[8,9],[10,11]] 
     104##    obj = h5file.store(ar, "/Group3", "NDArray", createparents=True) 
     105##    h5file.list() 
     106##    h5file.close() 
     107##    print "Data added." 
     108##    print "Retrieve data from h5file." 
     109##    #retrieve data from each node 
     110##    h5file = openH5File('file:///tmp/howto.h5', 'r') 
     111##    #retrieve spiketrain  
     112##    h5file.retrieveSpikeTrain('/Group3/SpikeTrain') 
     113##    #retrieve spikelist 
     114##    h5file.retrieveSpikeList('/Group3/SpikeList') 
     115##    #retrieve image 
     116##    h5file.convertImage('file:///tmp/convertion_pixel.png', "/Group3/Image_Pixel", format = 'png') 
     117##    image_1 = h5file.retrieveImage('file:///tmp/convertion_pixel.png', "/Group3/Image_Pixel", format = 'png') 
     118##    h5file.convertImage('file:///tmp/convertion_plane.png', "/Group3/Image_Plane", format = 'png') 
     119##    image_2 = h5file.retrieveImage('file:///tmp/convertion_plane.png', "/Group3/Image_Plane", format = 'png') 
     120##    #retrieve movie 
     121##    h5file.convertMovie('file:///tmp/convertion_pixel', "/Group3/Movie_Pixel", format = 'png') 
     122##    movie_1 = h5file.retrieveMovie('file:///tmp/convertion_pixel', "/Group3/Movie_Pixel", format = 'png') 
     123##    h5file.convertMovie('file:///tmp/convertion_plane', "/Group3/Movie_Plane", format = 'png') 
     124##    movie_2 = h5file.retrieveMovie('file:///tmp/convertion_plane', "/Group3/Movie_Plane", format = 'png') 
     125##    #retrieve NDArray 
     126##    print h5file.root.Group3.NDArray.read() 
     127##    h5file.close() 
     128##    print "Retrieval ended." 
    91129     
    92130